Go Down

Topic: serial comm with Perl only after launching Arduino (Read 1 time) previous topic - next topic


Nov 19, 2010, 12:21 am Last Edit: Nov 19, 2010, 05:49 am by lem0n Reason: 1
EDIT: nevermind! I was forgetting to call $serial->write_settings after configuring the port

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: [Select]

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


Nov 19, 2010, 12:31 am Last Edit: Nov 19, 2010, 12:40 am by lem0n Reason: 1
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:

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

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131