Skip to content

Serial write after things get started? #37

@gebl

Description

@gebl

Hello,

I'm trying to work with getting python code to write strings over the Serial link over time.

I've set up a loop that looks like this:

while True:
    avr.run()
    r, w, x = select.select([sys.stdin], [], [], 0)
    if r:
      line = sys.stdin.readline()
      avr.uart.send_string(line+"\n")

This works for a short period of time, but, if i wait to type input or try again later, it is never delivered to the arduino.

the arduino code looks like:

void loop() {
  Serial.print("Looping.\\n");
  Serial.print("Enter Value: \\n");
  while(1) {
    while (Serial.available() > 0) {
      char recieved = Serial.read();

      // Process message when new line character is recieved
      if (recieved == '\\n') {
          Serial.println(inData);
          inData = ""; // Clear recieved buffer
        } else {
          inData += recieved; 
       }
   }

Am i missing something? is there a better way to serial write to the arduino sim?

gabe

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions