Open kalon33 opened 6 years ago
Well, this is going to be a little late, and this likely won't fix your exact issue anyway, but I had a similar issue (not month
, but second must be in 0..59
), and here's how I fixed it.
I ran cs1504.py
with the Python debugger (I use pdbpp), let it run until the error with c, and looked at the values that were being passed to datetime.datetime()
post-mortem.
python2 -m pdb cs1504.py
Based on this traceback
ValueError: second must be in 0..59
```
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py", line 1314, in main
pdb._runscript(mainpyfile)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py", line 1233, in _runscript
self.run(statement)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "
I saw s
had a suspicious value of 255 (1111 11112), which led me to believe maybe my model didn't record timestamps down to the second, so I just clamped s
to zero.
I made the following changes (not all of which will apply in your case; my serial port driver is different, for example), and then the script worked fine.
--- /dev/fd/63 2020-05-02 22:12:26.000000000 -0400
+++ /path/to/bin/cs1504.py 2020-05-02 22:12:20.000000000 -0400
@@ -1,4 +1,7 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
# Copyright (c) 2006-2007, Fazal Majid. All rights reserved
# This code is hereby placed in the public domain
+#
+# source: https://github.com/fazalmajid/cs1504
+#
import sys, time, datetime, serial, struct, pprint
@@ -6,3 +9,4 @@
if sys.platform == 'darwin':
- serial_port = '/dev/cu.usbserial'
+ #serial_port = '/dev/cu.usbserial'
+ serial_port = '/dev/cu.Repleo-PL2303-000013FA'
elif sys.platform == 'linux2':
@@ -199,2 +203,3 @@
y += 2000
+ s = s if 0 <= s <= 59 else 0
ts = datetime.datetime(y, m, d, h, mi, s)
@@ -243,2 +248,3 @@
s = int(t & 0x3f)
+ s = s if 0 <= s <= 59 else 0
ts = datetime.datetime(y, m, d, h, mi, s) + self.delta
Maybe this helps… somebody?
Currently testing the opticon OPN-2001 with your program under Ubuntu 17.04LTS.
On the first run, I got:
And on the second one, and others, I got:
I could not get any barcode from it. Please help me fixing this