Serial communication error , can not figure it out. Help !!

Discussion in 'Troubleshooting' started by samira, Feb 7, 2014.

  1. samira

    samira New Member

    Joined:
    Oct 26, 2013
    Messages:
    2
    Likes Received:
    0
    Environment : UDOO quad.
    The J18 jumper is not used( empty ).
    CN6 is not connected, ie I am using direct serial connection between iMX6 with SAM arduino.
    Potentiometer is connected to A0 pin on arduino.

    I am trying to send data from analog reading on the Arduino side via serial comm to iMX6.
    I can see the data being generated and print on the arduiono monitor.
    When I run Python code, I can see data on python side for about 8-10 lines then the error. ( see below )

    Code:
    // Adruino code 
    int ADCpin0 = A0;
    void setup() {
      Serial.begin( 9600);
    }
    
    void loop() {
      int myVal = analogRead(ADCpin0);
      Serial.println( myVal, DEC);
      delay(100);
    }
    
    # this is my Udoo linux python code( iMX6 side )
    # reading serial data

    Code:
    #!/usr/bin/python
    import serial 
    ser = serial.Serial(timeout=1);
    ser.port = "/dev/ttymxc3"
    ser.baudrate = 9600 
    ser.open()
    data = ""
    
    try : 
    	while True:
    		ch = ser.read()    # **** 
    		while ch != '\n':
    			data = data + ch
    			ch = ser.read()
    		
    		print "Data: " + data
    		data = ""
    
    except Exception, e : 
    		print "error ::" + str(e )
    
    Result on python screen

    Code:
    Data: 167
    Data: 166
    Data: 12
    error ::device reports readiness to read but 
    returned no data (device disconnected or multiple access on port?)
    
    I also tried
    ser.readline() #****
    It gave the same error.

    Question : what is causing this error mesage ?
    Thanks.
    samira
     

Share This Page