If you have timeout=0
and do a readline()
immediately after sending, the answer is probably not yet received.
Better try timeout=.5
and adjust the value according to your observations.
In this case, it might as well be that the balance doesn't write correct "lines". In these cases try bal.read(100)
. The timeout will stop as soon as no further characters are coming.