LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   serial port programming: Java or C? (https://www.linuxquestions.org/questions/programming-9/serial-port-programming-java-or-c-323083/)

ar1 05-13-2005 07:15 AM

serial port programming: Java or C?
 
I want to write a program to control a robot arm (a Lynxmotion 5, specifically) using the serial port. Now, I've often been told that serial port programming is a lot easier using Java (with the javax.comm package) as opposed to using C.

I was wondering if you guys had any suggestions or experience to share. Another thing to keep in mind is whether the java code will later be able to be used as part of a device driver which I may write for the same robotic arm.

Thanks

jtshaw 05-13-2005 07:56 AM

If you are planning on writing a device driver for Linux then it must be written in C.

However... if the robot speaks RS-232 then I don't see a good reason for writing a driver in the first place. All you really need is a user space program that users the serial driver already in the kernel. In this case it comes down to a matter of personal preference, as it is quite easy to write to the serial port driver in both C and Java.

ar1 05-13-2005 08:24 AM

Hmm. The driver can provide some additional functionality I think. For example, I can have control timing in kernel space so that I can have 2 servos moving but appearing to move together (I guess like multi-processing). Of course, a side reason is that it'll give me an excuse to write a driver and thus understand the kernel better :D

vladmihaisima 05-14-2005 04:03 PM

It's not that nice to program in kernel space. And the only reason to do that is... to modify or improve the kernel. Now I understand that you want to learn, but wouldn't be nicer if you would do 2 separate things ? Something more meaningfull for kernel space, and a user space program that control the robotic arm.

In any case good luck with your robotic arm! I've done something vaguely similar on serial port, and it's really nice when something it's moving controlled by the computer.

ar1 05-17-2005 12:54 PM

Quote:

All you really need is a user space program that users the serial driver already in the kernel.
The driver is serial_core.c right? I don't understand anything in it. I could try reading the source code of a serial driver already in the kernel, but looking at their sizes I doubt if I'll get anywhere anytime soon. Since I'm working for on a college project the main aim is to get the robot moving, to be honest I don't care for perfection (deadlocks, race conditions and the likes :/)

So, do you guys have any suggestions on how to go about it, would you recommend Java for my purpose then? Or perhaps some source code or documentations that would help me?

Thanks

vladmihaisima 05-19-2005 02:55 PM

My program was made for DOS, and I don't have it on my computer (it must be somewhare bt it wasn't interesting).

This is a tutorial on tldp.

http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/

The examples there are just as complicated as my program was (but of course mine, also transmitted simple commands).

Hope it helps, it's really nothing complicated to be explained. You initialize it and you send charachtesrs, depending on what you want to control.


All times are GMT -5. The time now is 06:05 PM.