in reply to Open serial port without Device::SerialPort

I suppose your "complicated reason" for not using Device::SerialPort is that you would need to cross-compile the XS part to ARM. I'm not sure why XS is used here but I suspect it may be about signal handling or some timing issue. I haven't tried this in Perl but it looks fairly straightforward.

  • Comment on Re: Open serial port without Device::SerialPort

Replies are listed 'Best First'.
Re^2: Open serial port without Device::SerialPort
by ThomasBrouwer (Initiate) on Aug 05, 2011 at 14:01 UTC

    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!

      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?