Squonk wrote:Please check that you are running at least BB r39212!
BB r39404
What is strange is that Arduino UNO /dev/ttxACMx device is affected but not Arduino 2009 /dev/ttyUSBx device.
How can be affected one kind of USB serial device and not another ?
How do I observe the problem?
I've written a small Arduino program which justs do a special echo, it answers the decimal character code:
void setup() {
Serial.begin(9600);
}
void loop() {
int c;
c = Serial.read();
if (c != -1) Serial.println(c, DEC);
}
If I use picocom to communicate with Arduino UNO: no problems.
If I use a cgi script which communicates with Arduino UNO: sometimes problems.
I receive sometimes an empty line, sometimes twice responses.
Remark: I've cut the RESET tiny wire between RESET pads of Arduino.
I think the problem is at open/close /dev/ttyACMx, detect EOL.
I observe that sometimes the input buffer is not flushed after close/before open /dev/ttyACMx.
I observe that sometimes the input line is not correctly detected.
I observe that if I replace the line:
if (c != -1) Serial.println(c, DEC);
by:
if (c != -1) {
Serial.print(c / 10);
delay(100);
Serial.print(c % 10);
delay(100);
Serial.print("\n");
delay(100);
}
the result is better.
The result is good if I unplug/plug the Arduino UNO and I send the cgi request after.
I confirm that /dev/ttyUSBx don't have any problems.
There are also another kind of problem with /dev/ttyACMx when I connect a MSP-430EXPG2 or MSP-430F5529.
When opening with picocom, the driver wait a lot of seconds at open/close. And no characters are sent/received.
The CGI SH script:
#!/bin/sh
echo "Cache-Control: no-cache"
echo "Expires: 0"
echo "Access-Control-Allow-Origin: *"
echo "Content-Type: text/plain"
echo ""
device="/dev/ttyACM0"
form_urldecode()
{
local v
v="${1//+/ }"
v="${v//\\%/\\x}"
echo -e "$v"
}
qs=$QUERY_STRING
while [ ! -z "$qs" ]; do
p="${qs%%&*}" # get first part of query string
k="${p%%=*}" # get the key (variable name) from it
v="${p#*=}" # get the value from it
qs="${qs#$p*}" # strip first part from query string
qs="${qs#&*}" # strip first part from query string
eval v="\"`form_urldecode $v`\""
eval $k="\"$v\""
done
result="#undefined error"
if [ ! -c $device ]; then #not character device ?
result="#device not ready"
else
if [ -z "$command" ]; then #null command ?
result="" #set empty result
else
result="#timeout" #set default result in case of timeout
set +e
exec 6<&0 <$device 7>&1 >$device
echo -n "$command"
read -t 1 -s result #set result with 1st line (next lines are forgotten)
exec <&6 6<&- >&7 7>&-
set -e
fi
fi
echo -n "$result" #output result
How to debug that device problem?
If you help me how to locate the source, I will study it.
(Last edited by jmparatte on 29 Jan 2014, 09:52)