mrgmarsh / wfrog

Automatically exported from code.google.com/p/wfrog
GNU General Public License v3.0
0 stars 0 forks source link

wmr88 with driver wmrs200.py: hundreds bad checksums recoreded per hour [solved] #109

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. start wflogger
2. cat /var/log/wfrog.log.3 | grep bad
2012-03-31 23:30:31,662 WARNING [station.wmrs200] Record: FF 00 42 40 D7 00 2F 
64 00 00 20 0C 02  - bad checksum
2012-03-31 23:30:32,594 WARNING [station.wmrs200] Record: FF B0 60 00 00 1E 17 
1F 03 0C 00 73 01  - bad checksum
2012-03-31 23:31:29,657 WARNING [station.wmrs200] Record: FF 00 42 40 D7 00 2F 
64 00 00 20 0C 02  - bad checksum
2012-03-31 23:31:30,649 WARNING [station.wmrs200] Record: FF 00 48 03 0C 05 50 
00 00 20 CC 00  - bad checksum
2012-03-31 23:32:31,700 WARNING [station.wmrs200] Record: FF 00 42 40 D7 00 2F 
64 00 00 20 0C 02  - bad checksum
2012-03-31 23:32:32,662 WARNING [station.wmrs200] Record: FF B0 60 00 00 20 17 
1F 03 0C 00 75 01  - bad checksum

What is the expected output? What do you see instead?
it's the same error like WMR200 
http://code.google.com/p/wfrog/issues/detail?id=103 but more frequently

What version of the product are you using? On what operating system?
- latest version 0.8.2 svn

Please provide any additional information below.

I dumped the collect of input buffer and there we can see, that wmr88 often 
send three sync Bytes 0xFF before sending datas.
see log:
2012-04-01 01:59:19,575 DEBUG [station.wmrs200] Input Buffer: FF 
2012-04-01 01:59:32,230 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 00 20 66 01 
3D 28 
2012-04-01 01:59:32,234 DEBUG [station.wmrs200] Input Buffer: FF FF 
2012-04-01 01:59:32,244 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 00 20 66 01 
3D 28 
2012-04-01 01:59:32,248 DEBUG [station.wmrs200] Input Buffer: FF FF FF 
2012-04-01 01:59:32,258 DEBUG [station.wmrs200] USB RAW DATA: 07 B0 60 00 00 3B 
01 01 
2012-04-01 01:59:32,263 DEBUG [station.wmrs200] Input Buffer: FF FF FF B0 60 00 
00 3B 01 01 
2012-04-01 01:59:32,273 DEBUG [station.wmrs200] USB RAW DATA: 05 04 0C 00 5D 01 
01 01 
2012-04-01 01:59:32,278 DEBUG [station.wmrs200] Input Buffer: FF FF FF B0 60 00 
00 3B 01 01 04 0C 00 5D 01 
2012-04-01 01:59:33,286 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 0C 00 5D 01 
01 01 
2012-04-01 01:59:33,291 DEBUG [station.wmrs200] Input Buffer: FF FF FF B0 60 00 
00 3B 01 01 04 0C 00 5D 01 FF 
2012-04-01 01:59:33,301 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 0C 00 5D 01 
01 01 
2012-04-01 01:59:33,306 DEBUG [station.wmrs200] Input Buffer: FF FF FF B0 60 00 
00 3B 01 01 04 0C 00 5D 01 FF FF 
2012-04-01 01:59:33,316 DEBUG [station.wmrs200] USB RAW DATA: 07 00 46 EC 33 EC 
13 64 
2012-04-01 01:59:33,322 DEBUG [station.wmrs200] Input Buffer: FF FF FF B0 60 00 
00 3B 01 01 04 0C 00 5D 01 FF FF 00 46 EC 33 EC 13 64 
2012-04-01 01:59:33,326 WARNING [station.wmrs200] Record: FF B0 60 00 00 3B 01 
01 04 0C 00 5D 01  - bad checksum
2012-04-01 01:59:33,336 DEBUG [station.wmrs200] USB RAW DATA: 01 02 46 EC 33 EC 
13 64 
2012-04-01 01:59:33,341 DEBUG [station.wmrs200] Input Buffer: FF FF 00 46 EC 33 
EC 13 64 02 
2012-04-01 01:59:40,355 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 46 EC 33 EC 
13 64 
2012-04-01 01:59:40,360 DEBUG [station.wmrs200] Input Buffer: FF FF 00 46 EC 33 
EC 13 64 02 FF 
2012-04-01 01:59:40,371 DEBUG [station.wmrs200] USB RAW DATA: 01 FF 46 EC 33 EC 
13 64 
2012-04-01 01:59:40,375 DEBUG [station.wmrs200] Input Buffer: FF FF 00 46 EC 33 
EC 13 64 02 FF FF 
2012-04-01 01:59:40,385 DEBUG [station.wmrs200] USB RAW DATA: 07 00 41 00 00 00 
00 08 
2012-04-01 01:59:40,390 DEBUG [station.wmrs200] Input Buffer: FF FF 00 46 EC 33 
EC 13 64 02 FF FF 00 41 00 00 00 00 08 
2012-04-01 01:59:40,401 DEBUG [station.wmrs200] USB RAW DATA: 07 00 0D 00 00 0C 
01 01 
2012-04-01 01:59:40,406 DEBUG [station.wmrs200] Input Buffer: FF FF 00 46 EC 33 
EC 13 64 02 FF FF 00 41 00 00 00 00 08 00 0D 00 00 0C 01 01 
2012-04-01 01:59:40,411 DEBUG [station.wmrs200] Barometer Record: 00 46 EC 33 
EC 13 64 02 

I changed the line 192 in wmrs200.py and now we can decode messages with 3 and 
more header bytes 0xff. 
The checksums and data is ok.

Code old:
for i in range(len(input_buffer) - 2):
   if input_buffer[i] == 0xff and input_buffer[i + 1] == 0xff:
   startSep = i
   break

Code new:
for i in range(1,len(input_buffer) - 2):
   if input_buffer[i] == 0xff and input_buffer[i + 1] != 0xff:  
   startSep = i-1
   break

Original issue reported on code.google.com by f.friedr...@googlemail.com on 1 Apr 2012 at 12:54

GoogleCodeExporter commented 9 years ago
I think is better for checking at least two sync bytes 0xFF

this works also fine:

for i in range(len(input_buffer) - 2):
if input_buffer[i] == 0xff and input_buffer[i + 1] == 0xff and input_buffer[i + 
2] != 0xff:
     startSep = i
     break

Original comment by f.friedr...@googlemail.com on 1 Apr 2012 at 1:13

GoogleCodeExporter commented 9 years ago
This modification makes sense, however I think you should also change the for 
scope. I.e:

for i in range(len(input_buffer) - 3):
if input_buffer[i] == 0xff and input_buffer[i + 1] == 0xff and input_buffer[i + 
2] != 0xff:
     startSep = i
     break

Original comment by jordi.pu...@gmail.com on 3 Apr 2012 at 7:17

GoogleCodeExporter commented 9 years ago
You are right. This prevents a buffer overflow.
I have not noticed it, because the 2 or 3 sync bytes 0xFF are always at the 
first position of input buffer.

-------------
another questions to wmrs200.py:
The wmr88 generates every minute a USB timeout (line 168)
This is not a problem, but is this by design (like the wmr200)?

012-04-04 00:32:53,461 ERROR [station.wmrs200] Exception reading interrupt: 
[Errno 110] Operation timed out
Traceback (most recent call last):
  File "/volumeUSB1/usbshare/wfrog/wfdriver/station/wmrs200.py", line 168, in _run
    raise e
USBError: [Errno 110] Operation timed out
2012-04-04 00:32:56,487 INFO [station.wmrs200] Wind Battery Ok: True direction: 
14 (315/NW), gust: 0 m/s, avg. speed: 0 m/s
2012-04-04 00:32:57,430 INFO [station.wmrs200] Wind Battery Ok: True direction: 
14 (315/NW), gust: 0 m/s, avg. speed: 0 m/s
2012-04-04 00:33:05,320 INFO [station.wmrs200] Temp Battery Ok: True Sensor th1 
 Temperature: 5.8 C (Steady), Humidity: 87 % (Fair, Steady), Dew Point: 4 C
2012-04-04 00:33:20,371 ERROR [station.wmrs200] Exception reading interrupt: 
[Errno 110] Operation timed out
Traceback (most recent call last):
  File "/volumeUSB1/usbshare/wfrog/wfdriver/station/wmrs200.py", line 168, in _run
    raise e

Original comment by f.friedr...@googlemail.com on 3 Apr 2012 at 10:42

GoogleCodeExporter commented 9 years ago
I'd say my WMRS200 station doesn't produce this timeouts. I don't have access 
to the logs right now, so I can't check that. There's a 15 seconds hardcoded 
timeout. I believe this value was found experimentally, so could it be that 
WMR88 needs a higher timeout. Maybe you could try with a higher timeout.

Original comment by jordi.pu...@gmail.com on 4 Apr 2012 at 7:37

GoogleCodeExporter commented 9 years ago
I checked the log file from the WMR88A.
There is a max interval of 44-58 seconds between two USB Messages.
I increased the timeout in wfrog/wfdriver/station/wmrs200.py to 59000 
milliseconds and now all works fine.

Original comment by f.friedr...@googlemail.com on 15 Apr 2012 at 1:11

GoogleCodeExporter commented 9 years ago
issue solved. closing.

Original comment by jordi.pu...@gmail.com on 18 Jul 2012 at 7:41