Problems with bidirectional communication

Discussion in 'Arduino IDE' started by KFK-mpg, Feb 3, 2014.

  1. KFK-mpg

    KFK-mpg New Member

    Joined:
    Feb 3, 2014
    Messages:
    3
    Likes Received:
    0
    Hi @all,

    i`m working for a project on a bidrirectional communication with due and imx. But i have some trouble with that. My aim is to send the current time + date to the sam and get humidty + temperature back. For testing, i use a LED and write the current time back. At first i have configure the serial port:

    Code:
    stty -F /dev/ttymxc3 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts
    ok, that works.

    now i have upload the arduino sketch (with ide 1.5.4):

    Code:
    int clockMinute[2];
    char checkRecievingData;
    void setup() {
      // initialize serial communication:
      Serial.begin(1152000);
      pinMode(13, OUTPUT);
    }
    
    void loop() {
      Serial.println('S'); //send 'S' to imx,to instructs imx, send the time to sam (on imx, the time sends by python or manual from terminal (arduino ide)
      checkRecievingData='S';
      delay(1000);
      int i = 0;
      char recievedData[17];
      while(Serial.available()){
        char recievedCharacter = Serial.read();
        if(i < 2){
          recievedData[i] = recievedCharacter;
          i++;      
        }    
        checkRecievingData = 'R';
      }
     
      clockMinute[0] = recievedData[0];
      clockMinute[1] = recievedData[1];
      
      if(checkRecievingData [0] != 'S'){
        Serial.print('T:');  
        Serial.print(clockMinute);
        Serial.println();
        Serial.flush();
        
        int convertedMinute = atoi(clockMinute);
        Serial.println(convertedMinute , DEC);
        if(convertedMinute >= 35){
          digitalWrite(13, HIGH);
        }else{
          digitalWrite(13, LOW);
        }    
        delay(60000);
      }
    }
    The communication doesn`t work. I can`t see anything in console (arduino ide) and it doens`t turn on or off the led. So, i`m a little bit confused, because it works on mac with a duemilanove.

    So, i try something else:

    Code:
    int clockMinute[2];
    char checkRecievingData;
    void setup() {
      // initialize serial communication:
      Serial.begin(1152000);
      pinMode(13, OUTPUT);
    }
    
    void loop() {
      Serial.println('S'); //send 'S' to imx,to instructs imx, send the time to sam (on imx, the time sends by python or manual from terminal (arduino ide)
      checkRecievingData='S';
      delay(1000);
      int i = 0;
      char recievedData[17];
      while(Serial.available()){
        char recievedCharacter = Serial.read();
        if(i < 2){
          recievedData[i] = recievedCharacter;
          i++;      
        }    
        checkRecievingData = 'R';
      }
     
      clockMinute[0] = recievedData[0];
      clockMinute[1] = recievedData[1];
      
      if(checkRecievingData [0] != 'S'){
        Serial.print('T:');  
        Serial.print(clockMinute);
        Serial.println();
        Serial.flush();
        
        //int convertedMinute = atoi(clockMinute);
        //Serial.println(convertedMinute , DEC);
        if(clockMinute[0] > 51 || (clockMinute[0] == 51 && clockMinute[1] >= 53)){
          digitalWrite(13, HIGH);
        }else{
          digitalWrite(13, LOW);
        }    
        delay(60000);
      }
    }
    And this works fine. but it isn`t really comfortable, because i need the transfered characters as integers. (i get '35' as characters and have to processed as 35 integer)
    Thus, "atoi()" is the problem. Knows anybody the problem or can anybody help me?

    Although, my Arduino IDE erase a Warning, that it can`t reference to "_sbrk". Have anybody the same warning?

    I hope anybody can help me.

    best regards
    daniel
     
  2. EchoWarp

    EchoWarp New Member

    Joined:
    Feb 3, 2014
    Messages:
    11
    Likes Received:
    0
    I also have had this exact issue. Compiling and uploading from an external computer seems to help, but not entirely.
     
  3. KFK-mpg

    KFK-mpg New Member

    Joined:
    Feb 3, 2014
    Messages:
    3
    Likes Received:
    0
    Thanks, i will test it next time.
    I hope this problem will be solved by updates, because for me the combination of both systems and the communication channel is the main advantage to use udoo.

    best regards
     

Share This Page