[NCLUG] programming language

Kerry Miller n0wiq at comcast.net
Fri Jun 8 07:25:37 MDT 2012


I use a Black Cat USB to CI-V adapter.  It presents a /dev/ttyUSB0 in my 
system and a user group of dialout  I had to make my user a member of 
the dialout group to use the I/O port.

Kerry N0WIQ
My web site URL is:
http://mywebpages.comcast.net/n0wiq


On 06/07/2012 09:15 PM, Bob Proulx wrote:
> Ben West wrote:
>> I think, given your reply, I'm going to echo Bob here, and suggest you use
>> something high-level, like python, using some c libs for serial interfacing.
> I suggested Python because I believe it to be capable and useful.  But
> that doesn't mean I am a Python person myself!  But I am sure that
> Python can do it without resorting to special C libraries.  Since I am
> still more of a Perl person let me give an example.  In Perl serial
> devices can be managed directly as files.  There isn't any need to do
> anything special with low level C libraries for the serial port.
> Instead just talk to the serial port directly.
>
> Here is an abbreviated Perl example:
>
>      use IO::File;
>      use Expect;
>      ...
>      my $devicename = "/dev/ttyUSB0";
>      my $device = IO::File->new();
>      $device->open($devicename,"w+") or
>          die "Couldn't open $devicename: $!\n";
>      my $mdm = Expect->exp_init($device);
>
> Then I cheat a little bit.  I wanted something portable between HP-UX
> and GNU/Linux machines.  So of course I used 'stty' which is quite
> standard everywhere.
>
>      system("stty speed 19200<  $devicename>/dev/null");
>      system("stty raw -echo cs8 cread clocal crtscts<  $devicename>/dev/null");
>
> I am sure most people looking at shelling out for the external stty
> command will think that is a clunky way to do it.  But it requires no
> additional libraries and is extremely portable.  That worked the same
> on Perl 4 on HP-UX as it does on the current Perl 5 on my Debian
> system with no code changes.  It happens once only and so there isn't
> any need to make it faster.
>
> Once the device is set up then it can be talked to directly.  Here I
> am using the Perl expect library.
>
>      $mdm->send("ATZ\r");
>      $mdm->expect($timeout,"-re","^OK\r?\$")
>          or warn "Failed to get OK\n";
>
> Not knowing much about Python I am sure that it can do at least as
> well and probably much better without too much trouble.
>
> Bob
> _______________________________________________
> NCLUG mailing list       NCLUG at lists.nclug.org
>
> To unsubscribe, subscribe, or modify
> your settings, go to:
> http://lists.nclug.org/mailman/listinfo/nclug
>



More information about the NCLUG mailing list