George Gallen on 5 Nov 2004 18:45:03 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

RE: [PLUG] ok..Trying to get PERL to read/write to a tty port...


Title: RE: [PLUG] ok..Trying to get PERL to read/write to a tty port...

>
>I don't get any error on file open
>but the process hangs.
>I used stty to set the port to 9600/e/7/1
>
>If I run minicom, and I manually type "W" <ENTER>
>I do get a response back from the scale
>
>Any ideas.
>
>#!/usr/local/bin/perl
>
>use CGI qw/:standard/;
>
>my $filename_in="/dev/usb/ttyUSB0";
>my $filename_out="/dev/usb/ttyUSB0";
>
>open (SERIALOUT,"+< $filename_out") || die("Can't Open
>$filename_out! for reading/writing");
>
>print SERIALOUT "W\r";
>
>my $charin = getc(SERIALOUT);
>print $charin "\n\n";
>

I did make one change

print "$charin \n\n";

But what was stranger...

I added in:

print "W wrote out \n";

after the print SERIALOUT...

and when I ran it, it caused a panic, and crashed the system.

after I removed it, made the above change, it still hangs, but
   at least the system doesn't crash.

Why would printing the above cause the system to crash?
Or did I need to specify STDOUT?

I have yet to do any I/O in PERL (except for file I/O)

Below are the stty settings:

[root@swede1 tmp]# stty -a < /dev/ttyUSB0
speed 9600 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
parenb -parodd cs7 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff
-iuclc -ixany -imaxbel
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
[root@swede1 tmp]#

This is: 9600 7/e/1 isn't it.
I wanted the xon/xoff disabeled, and CTS/RTS disabled as well.

I'm running the perl routine as root, so permissions on the port
   shouldn't be an issue.

George