Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
retoor116456dI had today a malloc with a wrong size. That's noob shit too. Doesn't happen since long time.
Or a while ago, I had an object (struct representing a js object), requested a property value from it. When i was done, i free' it. But that property was just still part of that object, so the code further below free'd the whole object and needed that property too. So I got double free. Bit sad, I did make all properties managed by the object for a reason, to free in a normal way. That means, if a string is set for example, i duplicate the string and don't use the pointer. It's in theory slow, in practice, meh. It does give you some memory safety so -
kobenz8456dSnippets, for shit like that I've got snippets and more snippets so I don't need to reinvent the wheel more than once
-
I did get this shit working today. But I am finding that the standard for modbus is not followed, or my library I am using for communication is hiding implementation details. The data in a register (16 bits) is supposed to be big endian. What I am getting is little endian. I looked through the source code and I can't see anywhere where they interpret the byte order at all. Perhaps it is hidden somewhere I cannot find it. I also tested with a perl library and it is returning little endian words. I am trying to create a generic interface so I added a byte endianess parameter in case we end up with devices that do it differently. Everything I am reading is saying manufacturers will just do it how they want anyway. Expecting everyone to just fix it in software.
Related Rants
-
linuxxx32*client calls in* Me: good morning, how can I help you? Client: my ip is blocked, could you unblock it for m...
-
DRSDavidSoft28Found this in our codebase, apparently one of my co-workers had written this
-
linuxxx23*client calls* "hello, we forgot the password to our WiFi router. Could you reset that for us?" 😐😶😮...
Staring at computer trying to figure out why I can't read a float from modbus. I swapped the bytes correctly for my platform. I also ensured the endianess of the words matched my platform (byte endianess is not the sames as word endianess, fml). Was driving home thinking about what could be wrong. My mind saw this code:
uint32_t newint;
for(int count=0; count<2; count++){
newint |= words[count] << count;
}
Then I am fuck! It should be:
newint |= words[count] << (count*16);
This was later turned into float. I kept getting values in the 1e-40 or some shit. Now it makes sense. The upper word was not set.
This is such newb shit. Fuck you newb shit I should just know!
Reading more I realized that the endianess of words can vary between devices even though the spec calls for big endian words. Fuck you non-compliant vendors! So I gotta add a flag for fucked up devices. Fine. The pay off is a generic way to add modbus to our opcua server. I want this easily editable in the field. For now it is readonly. So that makes it nicer.
Just a little torqued that I solved this driving home instead of at work. Too close to the code. I think tomorrow I will have my boss review it to tell me of other logical crap I missed.
rant
bits
bytes
words
wtf