Talking to Arduino from Scala - scala

Is there a standard way to control an Arduino from Scala? If not I am interested in hacking one together, but am unsure of where I should start. The Firmata library seemed like the way to go but there is no Java or Scala interface. SPDE supports Processing pretty well, but I see no Arduino functionality there. I also have a few snippets of Java<->Arduino example code scoured from the Arduino playground and other sources, but nothing comprehensive.
If anyone knows of a Scala or straight Java (I can just wrap it in Scala) way to do this, or has suggestions on rolling my own interface, I would like to hear about it.
Thanks.

Any programming language can be used to communicate between the serial ports of the PC and arduino,as long as the programs running on both sides can make make sense of the data exchanged.RxTX is a java library for serial port communication.Hope this helps.

You might want to check out apache MINA, which provides some nice wrapping around the RXTX libraries and offers an API that's friendly to idiomatic Scala.
I've already had some success with this approach in driving an X10 controller for home automation.

Related

gRPC - Using code other than Java to create a Service Implementation

I'm a student. For my Distributed Systems project, I'm expected to create a gRPC project. I'm creating the project in Eclipse.
Two service implementation are to be coded in Java and the other is to be done in another coding language.
I've tried searching for help online but the results I'm getting are related to gRPC and how gRPC works, not about the coding or using other coding.
Ideally, I would like to use Python as the other language and to create it in Eclipse if possible. Does anyone have any information, documentation or examples I could look at, so I could can reference it?
I am able to see online searches for both Java and Python, but I'm not sure how to use both in one project.
Thank you.
So I got a lot of feedback for lecturers and classmates.
The server doesn't care what programming language is used.
So Java, Python, Node.js etc, could all be sent to the server.
A generalised simplistic idea of how I was able to understand is: Python converts its code to binary and sends it to the server. Same with Java and Node.js.
I don't know why, but I was digging myself deeper trying to figure out what code (i.e. the binary) that needed to be the communication between the server and code. I was trying to encapsulate Python into Java and vice versa.
Why did I think this? Your guess is as good as mine.

How about Akka-grpc with flatbuffers, thoughts?

I have started working with Akka-GRPC using ProtoBuffers, the samples online are very clean and concise, but with Flatbuffers being faster than ProtoBuffers and GRPC stating out of box support for FlatBuffers, can we use flatbuffers with Akka-Grpc, I have started working on it and FlatBuffers seems much more work than what ProtoBuffer offers, so my question is, is it worth using FlatBuffers, is it possible to use FlatBuffers with AkkaGrpc(Since, its JVM at the end, still unsure though) and are there any child projects to do the same.
I understand we have Filo but any other alternatives
https://github.com/velvia/filo
Likely no. First, GRPC for FlatBuffers currently works for C++, Go, and is being worked on for other languages, but does not exist for Java (or Scala) as far as I know.
Even if it did exist, I'm not familiar with Akka, but if it integrates directly with Protobuf (which it looks like it does) then supporting FlatBuffers would require more work by the Akka developers. I'd ask with them.

porting java code to contiki-os

i am using contiki-os to simulate some motes which would have semantic capabilities. As the contiki-os (erbium) is written in C but our semantic libraries are written in java.
can anyone here guide me if it is possible to exploit these libraries in erbium or contiki-os. or i have to rewrite everything from scratch ?
update
just a minor update to the question. is it possible to use java code on the cooja simulator?
Cooja is indeed written in Java.
You can extend or modify Cooja if you need.
You can find out more about Cooja on the Contiki wiki as well as in numerous papres by Fredrik Ă–sterlind. Perhaps you should also take a look at Fredrik's PhD thesis "Improving Low-Power Wireless Protocols with Timing-Accurate Simulation", which is mostly about Cooja.
You might be able to use something like this:
http://www.codemesh.com/products/junction/
It appears to have a code generator that takes a java bytecode and create C code from it... but it might also need a runtime library that's platform specific.
With all that in mind, I don't think you will be successful. Most of the platforms are nearly out of space and/or flash by the time you are working with Erbuim; I doubt you'll have resources to process java code somehow.
And if you did get some success from this approach it would probably take a lot of time and effort to do so. With that time and effort you probably could have written the C code to do what you need instead.

Socket.io Scala client

I'm looking for a socket.io client for Scala. I'm well aware of this, but I cringe at the idea of using it in Scala as it wouldn't feel quite natural nor would it allow for an idiomatic implementation. Does any of you, thus, have a suggestion as to where could I find a Scala client?
If so, just the lines for SBT and a link to the doc will suffice as an answer ;)
I'm afraid I don't know any already implemented libraries or apparent solutions for Scala. But I'll present two very simple approaches that should be very easy to use if you have the time to DIY :-)
But of course it really depends on what you want. As you probably already could imagine a plain WebSocket implementation of Java's standard library can be quite efficient if you need to process simple requests. I found one at scala-lang.org implementing a server calculating random numbers. If it is of interest there's also something brewing at the nightly build which might reveal some handy tricks.
If you want to go for simplicity and for pure Scala in all its might the Actors (in particular a RemoteActor) are immensly powerful. It requires Scala on both ends naturally, but it gives you a messaging-system almost instantly. This is a pretty good start-guide if you aren't already familiar with them.
Anyway. If no good library surfaces I hope this helped. Good luck.

Using libpcap with Scala

What's the best way to use libpcap with Scala? I need to capture from live network devices, so it will most likely need a native binding.
I've found a couple like JPcap and JNetPcap but nothing particularly for Scala...
Any recommendations?
Since the libraries run on JVM already there is no need for an additional wrapper for Scala. Just pick the best library and pimp it to your needs.
JNetPcap seems like the most updated one here.