Thanks Dennis. In effect stringZVEI doesn't remain empty after the .read method, then the loop is executed 1 time.
How could be a 'while' loop to wait a no empty string from the serial port? Dario. Dennis Lee Bieber ha scritto: > On 7 Sep 2005 07:14:37 -0700, "dario" <[EMAIL PROTECTED]> declaimed the > following in comp.lang.python: > > > Hi, Im new on phyton programming. > > On my GPRS modem with embedded Phyton 1.5.2+ version, I have to receive > > a string from serial port and after send this one enclosed in an > > e-mail. > > All OK if the string is directly generated in the code. But it doesn't > > works if I wait for this inside a 'while' loop. This is the simple > > code: > > > First -- post the real code file would help -- the indentation of > the first two statements below is wrong. > > > global stringZVEI > > > This does nothing at the top level -- if only makes sense INSIDE a > "def" block, where it has the effect of saying "this variable is not > local to the function" > > > while stringZVEI=='': > > MOD.sleep(10) > > There is something wrong with > > import time > time.sleep(<seconds>) > ???? > > > a=SER.send(' sono nel while stringZVEI==st vuota') > > stringZVEI = SER.readbyte() > > #for debug > print "%2X " % stringZVEI > > > a=SER.send(' stringZVEI=') > > a=SER.send(stringZVEI) > > > > MOD and SER are embedded class maked by third part. > > > > >From my very little debug possibility it seem that loop is executed 1 > > time only nevertheless stringZVEI is still empty. The line > > a=SER.send(' stringZVEI=') > > work correctly but > > > > a=SER.send(stringZVEI) > > > What does .readbyte() do if there is no data to be read? Since your > loop is based on a totally empty string, if .readbyte returns /anything/ > (even a "null" byte -- 0x00) your loop will exit; and a null byte may > not be visible on the send... > > -- > > ============================================================== < > > [EMAIL PROTECTED] | Wulfraed Dennis Lee Bieber KD6MOG < > > [EMAIL PROTECTED] | Bestiaria Support Staff < > > ============================================================== < > > Home Page: <http://www.dm.net/~wulfraed/> < > > Overflow Page: <http://wlfraed.home.netcom.com/> < -- http://mail.python.org/mailman/listinfo/python-list