Crispin's Content - Netduino Forums
   
Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

Crispin's Content

There have been 4 items by Crispin (Search limited from 29-March 23)


By content type

See this member's

Sort by                Order  

#57815 Two's compliment byte array to int16 - confusing results.

Posted by Crispin on 28 April 2014 - 09:35 PM in General Discussion

thanks folks!

 

CW2 - sorry, I should have said, it gives back 8 bytes which is 2 4-byte values. The second set of 4 bytes there is a second serial number.

 

So, your way works perfectly :D

I understand what you're doing but not why. I last did this stuff in school some 20 years ago and binary has changed so much since then ;) (TiC!)

I'll write it all down and understand it. Thanks for the help.

 

 

Lazy question - is there a lazy-man's wrapper in csharp which could have done this for me?

 

Cheers,

Crispin




#57796 Two's compliment byte array to int16 - confusing results.

Posted by Crispin on 27 April 2014 - 10:40 PM in General Discussion

further confusion - 

 

Another property I have has a value of 60 (it's an int). So says the OEM application.

If I query the property I get 2 bytes coming back = 0x00, 0x3c (in int is 00, 60)

 

if I change it (with the OEM app) to 66 I get back  0x00, 0x42 (in int is 00, 66)

 

if I change it (with the OEM app) to 555 I get back  0x02, 0x2b (in int is 2, 43)

 

I'm lost - hoping someone can help?

 

I know this should be / is simple if you understand it all but I'm lost :(

 

Thanks

Crispin

 

Endianness... Windows / c# is little, the camera clearly states big. Doh. 

Well, that works now so sure I can understand the serial number now.... Maybe  :unsure:




#57795 Two's compliment byte array to int16 - confusing results.

Posted by Crispin on 27 April 2014 - 10:18 PM in General Discussion

further confusion - 

 

Another property I have has a value of 60 (it's an int). So says the OEM application.

If I query the property I get 2 bytes coming back = 0x00, 0x3c (in int is 00, 60)

 

if I change it (with the OEM app) to 66 I get back  0x00, 0x42 (in int is 00, 66)

 

if I change it (with the OEM app) to 555 I get back  0x02, 0x2b (in int is 2, 43)

 

I'm lost - hoping someone can help?

 

I know this should be / is simple if you understand it all but I'm lost :(

 

Thanks

Crispin




#57794 Two's compliment byte array to int16 - confusing results.

Posted by Crispin on 27 April 2014 - 09:11 PM in General Discussion

Hi Folks,

 

I've got something which is really confusing me and I'm lost.

 

I'm talking to a camera via a serial connection. To get the serial number from the camera, I send a command and it replies with the serial number.

 

From the camera's documentation: 

Two’s-complement numbering is used for all signed values. Big-endian ordering is employed

 

For the serial number it says I will get back a 4 byte array which is the equivalent of this:

byte[] buff = new byte[8] { 0x00, 0x01, 0x36, 0xeb, 0x00, 0x0c, 0x45, 0xe3};

The number I am looking for is 79595 (real serial number of the camera)

 

 

I am lost as to how to get this. I've tried bitconvertor but it returns 13825 and 235, flipped it simply negates them and adds 1 (expected)

 

'elp please - I'm lost. How do I convert byte arrays back to meaningful numbers? 

 

 

Thanks

Crispin





home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.