Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

Python • Re: EOFError from input( )

$
0
0
Folks:

After thinking about it, it makes sense. Perhaps it has something to do with the way I am calling it.

The (reduced) version of how I used this function looks something like this (I am writing this from memory so I apologize for any unintended syntax errors in advance):

Code:

import multiprocessingimport serialdef port_send( port, stop_event ) :    while not stop_event.is_set( )        try :            x = input( )            port.write( x.encode( ) )        except KeyboardInterrupt :            stop_event.set( )if __name__ == '__main__' :    port = serial.Serial( PORT, baudrate=19200, timeout=0 )    stop_event = multiprocessing.Event( )    proc_send = multiprocessing.Process( target=port_send, args=(port,stop_event) )    proc_send.start( )    proc_send.join( )    port.close( )
The script is called directly in the RPi.

Somehow I have an inkling that ihe problem I am having might be due to the input buffer not being flushed between successive calls to the input function (see link):

https://stackoverflow.com/questions/17 ... ng-a-line

But I am not sure how I could go about it ...

Thanks again in advance, Gerry.

Statistics: Posted by gerrypkan — Sun Mar 17, 2024 9:25 pm



Viewing all articles
Browse latest Browse all 8082

Trending Articles