Pages: [1]   Go Down
Author Topic: serial comm with Perl only after launching Arduino  (Read 668 times)
0 Members and 1 Guest are viewing this topic.
Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

EDIT: nevermind! I was forgetting to call $serial->write_settings after configuring the port

hello
I programmed my Arduino to send bytes 0 and 128 from time to time
if I unplug the USB, plug it again and run my Perl program (below), it reads sometimes 127, sometimes 0... depending on the byte I send, some other "random" value (28, which is 00011100 and 224, which is 11100000, are some common values)

if, however, I open Arduino program for PC (windows), use the serial communication and THEN run my perl program, it works perfectly until I unplug the USB (then I have to do it again after pluging back)

any ideas on which kind of setting the Arduino program can be running?
I'm currently using, on Perl:
Code:
$serial->databits(8);
$serial->baudrate(19200);
$serial->parity("none");
$serial->stopbits(1);

and, on the Arduino program, I only do a Serial.begin(19200), so the other values are all default (which I guess are parity=none, stopbits=1)

any ideas on what may be happening?

since I don't change anything on the Perl program reading from COM7, I'm guessing the Arduino program instructs the Arduino hardware to actually change some configuration on how it was sending data
« Last Edit: November 18, 2010, 11:49:04 pm by lem0n » Logged

Brazil
Offline Offline
Newbie
*
Karma: 0
Posts: 19
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just had an idea to print all 0-255 characters and see what I got in the perl program

those are the only bytes that came:
0
14
28
112
126
128
142
224
240
252
254

so, for instance, 240, 247, 249, 250, 251 are received as 224 (11100000)

I could notice that all those numbers have somewhere "111" (except 0) and ends with "0"
maybe perl is not considering stopbits?

or maybe arduino is not sending them (otherwise, why would the same perl program work after I run the arduino program?)?

PS: the problem persists even if I set perl to $serial->stopbits(0);


EDIT: if I set baudrate to 9600 (on both Arduino program and perl program), I only get "0" or "224" on my perl program
« Last Edit: November 18, 2010, 06:40:23 pm by lem0n » Logged

Pages: [1]   Go Up
Jump to: