WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: cron and serial port errors  (Read 2430 times)

Offline herrMnnn

  • Newbie
  • *
  • Posts: 33
cron and serial port errors
« on: April 29, 2012, 02:17:33 AM »
I'm trying to schedule a Python script I've written to access serial data from a modbus device (Python 2.7, using pySerial 2.6 for serial port access). PIII on Intel mb, 256mb ram, Tinycore booting from usb flash drive, USB-serial converter to access modbus device.

I've run the script  hundreds of times without error on my i5 Asus  laptop running Ubuntu.  It even runs in Windows 7 perfectly.

I can run the script manually every minute from an xterm in TinyCore repeatedly without error.

When I schedule the script using cron it runs as scheduled every minute but every read has serial data errors.  It still writes data and log files etc as it should (albeit containing errors), the problem is in the serial transfer.  Exact same hardware/software in each case, only difference is how I start the script.

I've googled and searched here but can't find a solution.  Cron was set up according to instructions I found on this forum.

Any ideas on where to look for the solution would be most appreciated.

Offline herrMnnn

  • Newbie
  • *
  • Posts: 33
Re: cron and serial port errors
« Reply #1 on: April 29, 2012, 03:08:28 AM »
Does this sound right??

I am loading cron using the  instructions here http://forum.tinycorelinux.net/index.php/topic,4983.msg26436.html#msg26436

In my naive fumbling about it seems I also put cron into my boot options but had forgotten about it. 

I deleted it from the boot options and rebooted and so far (>30 reads, 1 per minute) no data errors.  Previously every read right from boot caused an error.

Is it possible that there were 2 instances of cron running, each running the same python script at almost the same time? This would mean the 2nd script instance would be trying to access the modbus device which was already busy, hence the errors.  That's what it seems like to my inexperienced eyes...

I really hope it's that easy  :)

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: cron and serial port errors
« Reply #2 on: April 29, 2012, 04:17:28 AM »
Yes, that's what likely happened.
The only barriers that can stop you are the ones you create yourself.

Offline herrMnnn

  • Newbie
  • *
  • Posts: 33
Re: cron and serial port errors
« Reply #3 on: April 30, 2012, 08:34:01 PM »
Just as some feedback to finalise this issue, it's been running for 36 hours or so logging every 15 minutes without error, so that does seem to have been the problem. 

I guess I should replace the other cron entry to make sure it raises the errors again, but I'm more focused on just finishing the project for now.  I still need to get ssh working from outside my lan (router firewall issue), sort out voltage and cpu temperature monitoring so I can log it, replace the bios battery in the MB so it keeps it's date in a power failure, source a silent power supply, source or fabricate a case...