[Tutor] Converting a string to a byte array

Cameron Simpson cs at cskk.id.au
Mon Sep 25 17:02:14 EDT 2017


On 25Sep2017 09:29, Phil <phil_lor at bigpond.com> wrote:
[...]
>Just for interest I amended my code to use what you provided and tried it 
>under IDLE. There aren't any errors but but my Arduino is not responding.
>However, if I enter python3 mycode.py then it works perfectly. I'm sure 
>there's an explanation for this.

Just to this. If your serial file handle is a normal buffered one, you may also 
need to call .flush(). When you run from the command line as "python3 
mycode.py" is done automatically at programme exit. In the IDE, the programme 
has not exited, so your bytes may be lurking in the buffer, unsent.

Cheers,
Cameron Simpson <cs at cskk.id.au> (formerly cs at zip.com.au)


More information about the Tutor mailing list