ejeklint / wloggerdaemon Goto Github PK
View Code? Open in Web Editor NEWMac OS X Daemon that logs weather data from Oregon Scientific WMR100N, RMS300A or WMRS200
Home Page: www.ejeklint.se
Mac OS X Daemon that logs weather data from Oregon Scientific WMR100N, RMS300A or WMRS200
Home Page: www.ejeklint.se
I ran into an issue when I was taking a look at the project. Got it compiled and running, my RMS300A detected just fine, talking to couchdb on another machine just fine. Problem is that I was only getting a reading every once in a while...the rest of the time I was getting a ton of debug error messages saying that it was "Discarding reading with wrong length or wrong checksum". The data included after the error message looked like a fragmented data stream to me. So, looking into it, I determined that I was getting situations where I had the 0xFF 0xFF marker in the middle of the buffer, but what was left when it passed off to the postReadingAndPrepareForNew in src/WMR100NDeviceController.m was the beginning of a new packet of data. This was getting dropped so the next time I came to process it, it was missing the beginning of data.
For example, here are some of the "data" included after the error message. You'll note a distict pattern:
<42301c01 35003000 305401>
<301c0135 00300030 5401>
<1c013500 30003054 01>
What appeared to be happening was the beginning of the packet was being chopped off. So I stepped through the code in WMR100NDeviceController. Inside the inputReport method, I found the culprit. What was happening was this:
Ideally it would have been nice if the NSMutableObject class gave us a way to drop data off the front and shift it, but alas it does not...we're just allowed to truncate it. My fix went like this:
Here's my hacked solution (grr the webform mangled my patch data...no way to attach a file apparently...):
change the line in inputReport method inside WMR100NDeviceController.m (line 150 in the 2009-12-05 version):
[buffer setLength:0];
to:
if ((i + 2) < len) { // if data exists after the 0xFF 0xFF marker
char *bufferData=[buffer mutableBytes];
memmove(bufferData,(bufferData + i + 2),(len - i - 2));
}
[buffer setLength:(len - i - 2)];
This seems to have fixed my issue. Comments?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.