Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: Open serial port without Device::SerialPort

by ThomasBrouwer (Initiate)
on Aug 05, 2011 at 14:01 UTC ( [id://918768]=note: print w/replies, xml ) Need Help??


in reply to Re: Open serial port without Device::SerialPort
in thread Open serial port without Device::SerialPort

Yeah that sounds exactly like it :P one of the employees explained it to me, but due to my lack of expertise in programming I didn't fully understand it.

Thanks also for your link. I tried it, but that program crashes for me (when running that piece of code the program freezes). Now, I came across another piece of code which seems to connect just fine (no error) but which does not properly send or receive any messages. Good thing to know is that when the boards receive a message they reply to it, even when the message sent is completely random. So it's likely that the sending part isn't properly functioning... Here is the code to set up the port:

my $PORT = "/dev/ttyS0"; system ("baud=19200 stop=1 data=8 parity=n"); open DEV,"+<$PORT" or die "Failed to open port\n"; my $ofh = select(DEV); $| = 0; $/='>'; select($ofh);
And here to send one of the 4 byte package and receive the output (and since there is no output, the program freezes there). This message is directed at the first board (that's why @data1 = 1).
my @data = (3, 1, 255, 253); my $packeddata = pack("C*", @data); print DEV $packeddata; my $output = <DEV>; #print "Output: $output ";
Thanks for all the replies so far! Let's hope we can solve this!

Replies are listed 'Best First'.
Re^3: Open serial port without Device::SerialPort
by Anonymous Monk on Aug 06, 2011 at 00:24 UTC

    You can check if the write succeeded by testing the return value of print. e.g. die $! unless print DEV $packeddata;

      I've tried that, but it runs just fine. No error is given, but nothing happens either. Any other ideas, or a different method perhaps?

        Man, I wish I'd bookmarked the sites I visited while researching this... well, anyhow, if you look around, there's some software for Linux that will let you throw up a fake device (some kind of simulator to let you work out programming the serial port). Well, I dunno, google is your friend because this is just something I'm interested in rather than an area of expertise.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://918768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-04-19 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found