PDA

View Full Version : What is the best language for serial port programming?


Bootes
12-13-2008, 03:02 AM
Hello all,

I am working on a electronics/computer project and have hit a wall. I need to have a circuit that I'm designing talk to my PC and if I can get that to work, possibly the PC talking to my circuit. I consider myself to be a "somewhat advanced" java programmer. The problem is there is nothing in the api that will allow this communication. I have searched out a few projects that are having marginal luck with custom packages. simply put, java was created to be a multi-platform language and to run on a virtual machine, It was just not designed for this type of application.

As my programming knowledge is limited so java I ask: do other languages offer better/easier/simpler solution to programming communication to the serial port?

I found a guy who has done something VERY similar to my project, and he used Visual Basic for his language.

http://www.riccibitti.com/pc_therm.htm

I would really like to stay as far away from Microsoft as I can get. I am a MAJOR supporter of Open Source. I am curious as to what the other languages offer as far as Serial Port Communication.

Maybe VB is the best option but I wanted to ask around and see what C++ and other languages have to offer

Bootes

oracleguy
12-13-2008, 04:38 AM
You can do it in C (and by extension, C++) fairly painlessly. As far as the exact function calls to do it, I'm not sure if they are in the ANSI C standard and are probably platform dependent. However if you want to make your program cross platform it would be fairly easy to wrap the serial API with your own functions. Then just have some preprocessor definitions to handle each platform.

Hopefully that made some sense. I don't know the function names off of the top of my head but if you can't find some information on them, I know a project I did a while back that used them and I could look in the code.

oesxyl
12-13-2008, 06:11 AM
as oracleguy said, c/c++. You can use swig to binding c/c++ with java:

http://www.swig.org/
see java example:
http://www.swig.org/tutorial.html

...or you can use tcl/tk,:)
http://www.hume.com/html85/mann/comm.html
regards

stevegee
01-06-2009, 12:45 AM
You might want to take a look at a free scripting language called AUTOIT http://www.autoitscript.com/autoit3/ I've used it a lot for small quick applications and I just did a search on the site for "serial port" and there is considerable support available. The advantages of autoit are (1) It's free (2) It's not Microsoft (3) You can run it as a script or compile it to an exe (4) It requires no runtime packages other than the compiled exe itself.

I hate Microsoft too but...

I have done several projects using VB 6 and the MSCOM control. This combination was so very easy to implement. It's almost perfect for developing support applications for electronic products. The problem is that I believe MS no longer supports VB6 and I don't think that they ever supported it on Vista. If I were to go this route I would look at using the free virtual machine VMWare player vmware.com with a copy of XP and VB6 in a virtual machine. This will then run on a Vista host or linux or any future version of Windows.

Don't forget that serial ports are all but obsolete now. I had this problem the last time I had a job like this. We couldn't rely on buying pcs with com ports - especialy notebooks. We ended up using Ethernet instead. More expensive and complicated but more future proof.

Hope this helps.

Steve

Nito
01-06-2009, 04:55 AM
The problem is that I believe MS no longer supports VB6 and I don't think that they ever supported it on Vista.

VB6 is supported, but you have to make minor alterations to your references, which means that you'd have to create two separate applications for XP and below/Vista and up, depending on the ref's and components you use within the software. This is due to Vista not having all the compatible runtimes that vb6 requires, as well as the registry being set a tiny bit different.

I still develop personal projects in vb6, on a Vista Ultimate OS (Choosing not to install Visual C++ will allow you to install vb6 on a Vista machine(Funny how C is the problem, eh? lol)) - They work fine with some tweaking though.

Aside from that, if you already have experience in C/C++, you would probably be best going with those. If you're not too familiar with the working of either of those languages, Steve's suggestion for AutoIt would be your best bet. I've also used it, and it's a nice flexible and stable language to write in.

-Nito

stevegee
01-06-2009, 10:51 AM
I get realy ticked off by Microsoft when I spend months developing stuff only to find that they bring out a new OS which isn't backwards compatible. I end up either having to modify the software or recode from scratch. Most often it gets left and will die as soon as users refuse to use the OS it was developed for. I try to look for future proofed options but it isn't easy.

Steve

VB6 is supported, but you have to make minor alterations to your references, which means that you'd have to create two separate applications for XP and below/Vista and up, depending on the ref's and components you use within the software. This is due to Vista not having all the compatible runtimes that vb6 requires, as well as the registry being set a tiny bit different.

I still develop personal projects in vb6, on a Vista Ultimate OS (Choosing not to install Visual C++ will allow you to install vb6 on a Vista machine(Funny how C is the problem, eh? lol)) - They work fine with some tweaking though.

Aside from that, if you already have experience in C/C++, you would probably be best going with those. If you're not too familiar with the working of either of those languages, Steve's suggestion for AutoIt would be your best bet. I've also used it, and it's a nice flexible and stable language to write in.

-Nito

oracleguy
01-06-2009, 06:29 PM
I get realy ticked off by Microsoft when I spend months developing stuff only to find that they bring out a new OS which isn't backwards compatible. I end up either having to modify the software or recode from scratch. Most often it gets left and will die as soon as users refuse to use the OS it was developed for. I try to look for future proofed options but it isn't easy.

Steve

VB6 is also 10 years old, you can only maintain backward compatibility for so long. Now days if you really want to use VB, if you use VB.net at least you will have a future proof product for at least the next several years for sure since it doesn't look like the .net framework is going anywhere.