[Cialug] Python failing

David Champion dchamp1337 at gmail.com
Wed Jun 29 23:42:32 CDT 2016


Do you see any system messages about ttyUSB0 having issues?

-dc

On Wed, Jun 29, 2016 at 7:44 PM, Patrick Mcgillan <
patrick.mcgillan at gmail.com> wrote:

> The following script has been running fine for over a year. Now it is
> stopping more than once a day. Kill program and restart and it again runs
> fine for a while. Any thoughts? I know enough about python to be dangerous
> to myself. n arduino uno is sending messages to the server running the
> capture script.
>
> Patrick
>
>
> #!/usr/bin/python
>
> import serial
>
> debug = 0
>
> MySerial = serial.Serial('/dev/ttyUSB0', 9600)
>
> while True:
> data = MySerial.readline();
> print "%s" % (data)
>
> if data.count(":") == 2: who,s1,s2 = data.split(":",3)
> if data.count(":") == 3: who,s1,s2,s3 = data.split(":",4)
> if data.count(":") == 4: who,s1,s2,s3,s4 = data.split(":",5)
> if data.count(":") == 5: who,s1,s2,s3,s4,s5 = data.split(":",6)
> if data.count(":") == 6: who,s1,s2,s3,s4,s5,s6 = data.split(":",7)
>
> if data.count(":") > 1:
> fileout = open ('/var/local/Sensor/' + who + '-Data.txt', 'a');
> fileout.write (data);
> fileout.close();
> if data.count(":") > 1:
> fileout = open ('/var/local/Sensor/' + who + '-Last.txt', 'w');
> fileout.write (data);
> fileout.close();
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> http://cialug.org/mailman/listinfo/cialug
>


More information about the Cialug mailing list