Jump to content

My boneheaded code of the day


Daklu

Recommended Posts

Posted

I recently added this bit of code in my application. As part of my unit testing I was sending a value of "10" to the Pin Number terminal. When the test failed I probed the integer output and was surprised to find the function interpreting the string as binary instead of decimal! It was returning 2, not 10.

Took me about 10 minutes to figure out what the real problem is.

post-7603-0-78558400-1313852149.png

  • Like 2
Posted

What do you mean? I'm talking about the ten degrees on the Kinsey scale - what are you talking about?

It turns out there is only 8.

Therefore, I will change my question to:

You obviously understand octet?

Posted

I had something similar recently, when I wanted to get the first byte from a string:

post-1431-0-16152100-1313922791.png

Unfortunately, I couldn't test this myself with the hardware, so I first found it after I remotely deployed it and found out something wasn't working. At first I didn't have debug data, so my initial reaction was to blame the hardware, which had both problematic documentation and a flaky history. Sigh.

Posted

That would have been even harder to find had the input consisted of only 2 bytes...

Uh, it was actually even harder than that, because the string only had 1 byte, so I was sure the device wasn't sending anything back (why I was getting the first byte of a 1-byte string is irrelevant here, although there was an actual reason for this). Well, I guess that's what happens when you're asked to do something quickly.

  • 2 weeks later...
Posted

Oh thanks, Shaun. I just opened that on a government computer. :o

Big Brother's going to be banging on my cubby door at any moment. You all will visit me in jail, right? :P

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.