i wrote a python script to read serial data: import serial ser=serial.Serial('/dev/ttyMCC',115200) while True: print ser.readline() but while running it produces these errors: Traceback (most recent call last): File "test.py", line 2, in <module> ser=serial.Serial('/dev/ttyMCC',115200) File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 180, in __init__ self.open() File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 311, in open self._update_dtr_state() File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 605, in _update_dtr_state fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str) IOError: [Errno 22] Invalid argument there is no problem reading data from a usb to serial converter connected to the usb port...... any help please
Try this tutorial http://www.doctormonk.com/2012/04/raspberry-pi-and-arduino.html?m=1 Its work for me on my udoo neo full. Sent from my iPhone using Tapatalk
Thanks for the reply, the method followed is same but the udoo neo serial port is a virtual one, physical ports and usb serial ports works fine, maybe due to that a9 and m4 chips share the same port, more help appreciated!!!!
Where do you want to connect to with the python program? To the Arduino side? If so can you see data when you open the serial reader from Arduino IDE?
this is the arduino code: void setup() { Serial.begin(115200); Serial0.begin(115200); } void loop() { Serial.write(Serial0.read()); Serial0.write(Serial.read()); } i am able to see the data received to the arduino by using: cat /dev/ttyMCC or cu -l /dev/ttyMCC -s 115200 but cant connect to port /dev/ttyMCC via pyserial..... pyserial successfully connected to /dev/ttyUSB0 port of my us serial adapter connected to an arduino on breadboard I even tried linking /dev/ttyMCC to /dev/ttyS0 by sudo ln /dev/ttyMCC /dev/ttyS0 and tried using /dev/ttyS0 in pyserial but failed with same error
ca you set a timeout like serial.Serial('/dev/ttyMCC', 9600,timeout=.1) ? and then in code time.sleep(2) before you try to read for the first time? Here is the python code I used to test .. btw. for the Arduino side I used the example multiserial (from communication) and changed seria1 to serial0 #! /usr/bin/env python import serial import time ports = [serial.Serial('/dev/ttyMCC', 9600,timeout=.1)]#, def gateway(): for port in ports: # send synch/start command to all avr's port.write("PING") port.write("\r\n") print "aaaa" while 1: for port in ports: daten = port.readline() if(len(daten) > 0): print daten if __name__ == '__main__': #wait for avr to calm time.sleep(2) # this must be here #flush all garbage for port in ports: port.flushInput() port.flushOutput() gateway()
Thanks for the code and help, but............ Tried your code but still getting the same errors as below: Traceback (most recent call last): File "test.py", line 5, in <module> ports = [serial.Serial('/dev/ttyMCC', 9600,timeout=.1)]#, File "/usr/local/lib/python2.7/dist-packages/serial/serialutil.py", line 180, in __init__ self.open() File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 311, in open self._update_dtr_state() File "/usr/local/lib/python2.7/dist-packages/serial/serialposix.py", line 605, in _update_dtr_state fcntl.ioctl(self.fd, TIOCMBIS, TIOCM_DTR_str) IOError: [Errno 22] Invalid argument where did you install pyserial from i did it using pip pip install pyserial i wonder whether its an issue with pyserial
i think it was sudo apt-get install pyserial can you also change the arduino side with void setup() { // initialize both serial ports: Serial.begin(9600); Serial0.begin(9600); } void loop() {: if (Serial0.available()) { int inByte = Serial0.read(); Serial.write(inByte); } // read from port 0, send to port 1: if (Serial.available()) { int inByte = Serial.read(); Serial0.write(inByte); } } EDIT: btw. you can use minicom -D /dev/ttyMCC - b 9600 and then i think it was ctrl + A and'e' for Echo (to see what you tipe also) or just ctrl +A and then 'z' for options
Hi Pilif, thanks for your valuable information and fast reply, but I'm still getting the same errors when executing the python script, which version of udoobuntu are you using???? FYI: i'm getting output in serial console and also minicom, the only problem is the python script
Strange, I use the same code on RC1 to setup the connection and have no issues sending data viceversa: I do not use Serial0 Python: arduino = serial.Serial('/dev/ttyMCC',115200,timeout=0) arduino.flushOutput() arduino.flushInput() serial_data = arduino.read() Arduino: Serial.begin(115200); delay(100); Serial.println("W"); //send commands to python
Its work for me. Im download and install pyserial-2.7 then use python 2 for programming. Sent from my iPhone using Tapatalk
Issue resolved!!!! i had to remove pyserial installed using pio and installed python-serial and everything works like charm sudo pip uninstall pyserial sudo apt-get install python-serial Thanks everyone
A big thanks from me to every one, After struggling with exactly the same problem for an entire day, I logged into the forum to post the problem. How lucky! Noel Georgi has already posted the same problem and got the solution also. The trick worked for me and ended my misery. Thanks once again, all of you.
@Andrea Rovai In the manual http://www.udoo.org/docs-neo/Arduin...EO_Serial_Libraries_And_How_To_Port_Them.html it is stated This seems to be incorrect according the above mentioned experiences. It should be sudo apt-get install python-serial
Do you mean the python-serial that you get from apt-get or the Udoo python serial? The first I don't know. The second is in UDOOboard github. Will add the link with an edit. Edit: https://github.com/UDOOboard/serial_libraries_examples