0

I am using this tutorial to connect an Arduino Yun with a browser using Autobahn.

In the python file in the above repo, there is this code:

def controlLed(self, turnOn):
    if turnOn:
        payload = b'1'
    else:
        payload = b'0'
    self.transport.write(payload)

Here's the thing - I need to send whole sketches to my Yun, not just '1' or '0'. I tried sending more to the payload (like payload = b'this is part or all of a sketch') but that doesn't work. I experimented with some other data types but at the moment these are shots in the dark.

How can I send some proper data (like 100 lines of Arduino sketch) with this mechanism? The end goal is that my existing sketch receives the new sketch commands via serial and runs them.

if (port->available()) {
  int commands = port->read();
  // Run commands here
}

I would be hugely appreciative of any help. Thank you!

1 Answer 1

0

Partial answer: to send more information than just a single byte, it is possible to run:

# python
payload = "Here is a longer string"

# arduino
String commands = port->readString();           // Reads the whole thing
String commands = port->readStringUntil('\n');  // Reads until the given separator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.