All works perfectly from the Arduino desktop IDE (system currently has KB/mouse/screen), not only blink but also reading analogue ports.
Running pymata_blink.py started well (it compiled and installed the Firmata code) and the LED blinked correctly, but there were error messages:
- Code: Select all
pi@cchd ~/scripts $ ./blink.py
Opening Arduino Serial port /dev/ttyS0
Please wait while Arduino is being detected. This can take up to 5 seconds ...
Error: No dispatch entry for sysex_command 0
Error: No dispatch error for data F7
Error: Caught exception in command handler - pop from an empty deque
Error: No dispatch error for data F7
Board initialized in 1 seconds
Total Number of Pins Detected = 20
Total Number of Analog Pins Detected = 6
and the load average climbed to 1.1 (a puzzle: the time.sleep should take no CPU).
Tried reading A0 and writing it
- Code: Select all
LDR = 0
firmata.set_pin_mode( LDR, firmata.INPUT, firmata.ANALOG)
then in try loop
LDR_value=firmata.analog_read( LDR )
print "LDR" , LDR_value
and the output was (there were time.sleep delays)
- Code: Select all
....
Error: Caught exception in command handler - pop from an empty deque
Error: No dispatch error for data F7
Error: Caught exception in command handler - pop from an empty deque
LDR 687
Error: Caught exception in command handler - pop from an empty deque
Error: Caught exception in command handler - pop from an empty deque
....
with an LDR output roughly every ten exceptions (and that value 687 stayed around there despite altering the light to levels that changed it down to 100 and up to 890 when using the Arduino IDE and its serial console).
The blink script generated no exceptions once it was going, while the script that sent LDR values back generated exceptions all the time (five to ten per value).
I note that I have not set a serial baud rate - not sure at this point how to do it in PyMata. I did so in the IDE and found it worked fine both at 9600 and at 57600 baud, so long, of course, as the program and the serial console were the same.
No difference with ttyAMA0 (which anyway is softlinked from ttyS0), nor with other variations of blink.py, except that one I found including ttyACM0 and a parameter 'firmata_type=PyMata.STANDARD_FIRMATA' gave multiple errors.
CTRL/C halts either program OK with a nice 'Hope to see you soon!' message.
Button on co-op triggers flashes on the green light.
No hanging channels on lsof.
Effects vary between runs (of blink or LDR read). Sometimes Board Auto Discovery fails and avrdude-original: comes in to load flash data, verifying OK: sometimes this involves a complete Firmata recompilation. Often there is a long batch of these errors:
- Code: Select all
Error: Caught exception in command handler - pop from an empty deque
Error: No dispatch error for data F7
Error: Caught exception in command handler - pop from an empty deque
Error: No dispatch error for data F7
which I presume means simply that the command is corrupted so not recognised.
It makes no difference powering the system from a stable TeckNet battery pack instead of a mains USB adaptor.
All software recent. The only additions I have made are to install LAMP, a fixed external IP (so you can access the pi on cchd.eu) and CUPS.
Christopher Dawkins, cchd@pjcd.org