[Cialug] Python failing
Sean Flattery
sean.r.flattery at gmail.com
Thu Jun 30 12:33:26 CDT 2016
I agree with David, it looks like an issue with input from ttyUSB0. Like
you, I'm no python expert but it appears that the script doesn't have code
to handle lack of input from your serial connection. When your While True
statement turn to false, the program ends. You could modify the code to
wait, or maybe hack up a workaround like a cron job to restart the python
code if it's no longer running.
If journalctl doesn't have the logs you want, try installing and running
syslog-ng.
Date: Thu, 30 Jun 2016 07:00:46 -0500
> From: Patrick Mcgillan <patrick.mcgillan at gmail.com>
> To: Central Iowa Linux Users Group <cialug at cialug.org>
> Subject: Re: [Cialug] Python failing
> Message-ID:
> <CACQ_s3kSEFQgt9ZE85S2WknXKtwVQkh1QCS5mnpaLi-B=
> OTQGA at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> how interesting. there are no system logs. there is a dmesg log, but
> nothing in it past boot of course. the version is known as bbq, picked for
> its small foot print. not been worth it and am thinking of switching back
> to regular debian.
>
> I wonder if there is a missing package that could be loaded to restore
> normal runtime logs. cron works and until you asked i assumed logs were
> working, just never went and looked.
>
>
> --
> Patrick
>
> On Wed, Jun 29, 2016 at 11:42 PM, David Champion <dchamp1337 at gmail.com>
> wrote:
>
> > 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();
> > > _______________________________________________
>
>
More information about the Cialug
mailing list