LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

0x99 overflow

I'm writing a simple modbus software. I need to send the following string.

 

char str_move1[9]={0x01, 0x10, 0x99, 0x00, 0x00, 0x09, 0x12, 0x00, 0x00};

 

but on debugging project i receive an overflow on the 0x99.

Also strange things:

 

1)     strlen(str_move1) give me 3 as result (I think because of the following 0x00)

2)     printing the string via this for statement:

 

             for(i=0;i<9;i++){
             DebugPrintf("%002X.",str_move1[i]);
             }

 

     give me:  01.10.FFFFFF99.00.00.09.12.00.00.

 

Why that overflow? How can I avoid it?

0 Kudos
Message 1 of 3
(3,202 Views)

Hi,

 

1)you're right. The strlen function count the number of characters until it reaches a NULL character (0x00 value).

2) I'm not sure of what means the "002" in the format string.

    Then, as far as I understand, i thinks there's a conversion problem which maybe is due to :

    - your string str_move1 : it is an array of signed characters (1byte) so, one character as to be only between -128 to 127

So there's something causing trouble

Try defining an unsigned char array instead of char. 

 

Hope it helps. 

     

Message Edité par NI_Device_user_sb le 08-20-2008 09:52 AM
0 Kudos
Message 2 of 3
(3,197 Views)
Using unsigned char worked. Thanks! Smiley Very Happy
0 Kudos
Message 3 of 3
(3,194 Views)