Serial comms between A9 and M4

Discussion in 'UDOO NEO' started by knick, Dec 21, 2016.

  1. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    I'm experimenting with the serial communications between the A9 and M4. I have the code below running on the M4, and on the A9 I am using minicom -D /dev/ttyMCC to monitor the serial data. In minicom I see "foo" printed once or twice and that's it. It should be displaying every 2 seconds. The M4 is getting stuck in the call to serial.println() (indicated by the state of the BLINK_PIN). Any idea what I've got wrong here?

    #include <SimpleTimer.h>

    #define SERIAL_A9 Serial
    #define BLINK_PIN 13

    SimpleTimer send_timer;

    void setup()
    {
    send_timer.setInterval(2000,sendRun);
    SERIAL_A9.begin(115200);
    pinMode(BLINK_PIN, OUTPUT);
    delay(2000);
    }

    void loop() {
    send_timer.run();
    }

    static void sendRun()
    {
    digitalWrite(BLINK_PIN, 1);
    SERIAL_A9.println("foo");
    digitalWrite(BLINK_PIN, 0);
    }​
     
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580
    What is the source of the library SimpleTimer.h?
     
  3. Maurice

    Maurice Active Member

    Joined:
    Oct 13, 2015
    Messages:
    394
    Likes Received:
    87
    Note that a
    Code:
    digitalWrite(BLINK_PIN, 1);
    SERIAL_A9.println("foo");
    digitalWrite(BLINK_PIN, 0);
    
    will blink the led so fast that your eyes won't be able to see it.
     
    waltervl likes this.
  4. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    That's what should happen. But it's not. Instead, the LED is turning on and staying on.
     
  5. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    SimpleTimer is just an arduino library for scheduling tasks. I don't think this is the source of the problem. I have simplified the code so that it now uses delays rather than SimpleTimer and the problem is still there. Here is the updated code;

    #define SERIAL_A9 Serial
    #define BLINK_PIN 13

    void setup()
    {
    SERIAL_A9.begin(115200);
    pinMode(BLINK_PIN, OUTPUT);
    delay(2000);
    }

    void loop()
    {
    delay(2000);
    digitalWrite(BLINK_PIN, 1);
    SERIAL_A9.println("foo");
    digitalWrite(BLINK_PIN, 0);
    }

    "foo" get printed a few times in minicom and then stops. The LED (BLINK_PIN) turns on and stays on indefinitely.
     
  6. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    Could the issue be that I also have the udoofota-serial package installed? Will there be a conflict?

    The serial comms looks fine when I monitor remotely in the Arduino Serial Monitor (via the virtual com port). But when I run minicom locally that's when the serial comms falls over.
     
  7. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    I've uninstalled the udoofota-serial package using 'sudo apt remove udoofota-serial'. But I'm still seeing the serial data in my remote Arduino Serial Console. Is there something else that I need to do to disable this?
     
  8. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    The issue only seems to occur when using minicom. If I access the serial port through a c program it works fine.
     
  9. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,314
    Likes Received:
    580

Share This Page