pwillard.com

Floobydust — Open Source experimentation


30 Jun

More on Serial Ports


(Please note: None this applies to LINUX.  Linux is much smarter about “devices” IMHO)

When testing out an idea, it sometimes a lot easier to write a little tidbit of code in PERL to do some concept verification.

Case in point:  I’m developing a a protocol to run over a RS485 bus and need to “act” like a master host from my PC.  Now I haven’t got the MASTER host code written yet and getting a protocol tested from a Serial Terminal program is tedious so I needed a quick way to send oddball strings.  PERL to the rescue…  and then I hit the brick wall.

I tested the code with stationary PC that has a “real” serial port on the motherboard.  It worked as planned so I went to the LAB table where I have a laptop (with no built in serial) and I tried the code.  I have an IOGEAR 2-port USB to SERIAL adapter on that laptop but I had not until then tried to access the device with PERL.

I am using the PERL module WIN32::SerialPort(0.19) and I kept getting “can’t open port” error messages.  I was not getting these on the other PC.  The only difference was that the IOGEAR USB-RS232 adapter was now using COM ports 13 & 14.   When I changed the PERL code to read COM13, it broke.

Here is the fix:

my $myPort = 11;

# COM PORT
# Deal with ports higher than 9 if($myPort < 10){ $myPort_Str = "COM".$myPort; print "low port: $myPort_Str\n"; } else { $myPort_Str = "\\\\.\\COM".$myPort; print "high port: $myPort_Str\n"; }

I guess Microsoft never imagined you would have more than 9 serial ports.

Ports 10 and Higher will not respond to being called “COMx”.  You need to use the following naming method: “\\.\COMxx”.

So when I open the port, I use:

my $port = Win32::SerialPort->new($myPort_Str);

This way, you can use higher number ports that would by default have the system saying, “sorry, port doesn’t exist” .   USB-RS232 drivers have a tendency to assign ports higher than COM9.


No Response Filed under: ramblings
22 May

Serial Ports & User Interfaces


Serial Ports

The Arduino, the Basic Stamp2 and other similar development tools often use the Serial Interface for communicating with attached computers. This is clearly the most efficient and cost effective method since it requires very little overhead, unlike using ETHERNET or Radio Communications, etc.

Creating a user interface for these devices with either a Linux or Windows PC is as simple as writing a terminal program that drives a custom GUI. I could use Visual Basic or C if I wanted stick with windows. To be really flexible, I could use a language like Perl, Python or TCL/TK.

So I did some research. I really like the way TCL/TK works. It understands that you might want to interact directly with the operating system. It has not forgotten that we love our serial ports. In essence, I think TCL/TK is ideal for working with PC’s and micro-controllers via the serial port.

On the other hand, the serial port seems to be destined to become a legacy item. While the Arduino now uses a built in USB-Serial bridge on board, getting connected to the communications port that the USB creates is sometimes a little tricky. You see, serial ports were historically considered to be physically part of a machine. Why would you even need more than 4 or so, right? Now, with the USB, you could easily have many more than 4 since the USB port needs to avoid the potential of stepping on physical ports.

Many Microsoft programming languages and API’s had built in support for up to 9 serial ports. If your USB-Serial bridge created COM11… you might run into trouble writing code to access it. Another problem, many of the freely available terminal programs have limited support for high com ports. Some actually stop at COM4.

Back to TCL/TK

This scripting language is mature and just plain cool.  Few scripting language solutions let you take Graphical User Interface  code written for a UNIX platform and plop it unchanged on a Windows platform (with TCL/TK installed) and have it run… with no modifications.  There is also a solution that wraps the “interpreter”  and script into and executable so a system doesn’t really have to have TCL/TK installed.

TCL/TK is available on the PC for Windows as well a Linux.  This amount of flexibility is really interesting to me.  Being able to use either with practically the same code means that I don’t  have to decide immediately which platform I’m coding for.


No Response Filed under: ramblings
19 May

Starting over from scratch…


“Floobydust” is a contemporary term derived from archaic Latin miscellaneous, whose disputed history probably springs from Greek origins (influenced, of course, by Egyptian linguists) — meaning here “a mixed bag.”

So,  here is yet another web log.  Of couse, I start “blogging” when blogging becomes considered to be something we did “yesterday”, but here I am.  Actually, I’m just looking for a convenient method to share my ideas and plilosophies.  Arriving late is better than not even trying, I suppose.