-512

 

 

-

(-)

()

7F

XX

XX

XX

XX

1

2

3

4

5

 

,

- 1

         10XX.XXXX (XX- 1, 8 , - )

 

(-) 1 1 ,

 

1 - ( )

 

() 1 1 ( 01010101), 1 .

 

 

-

(-)

1

(1)

8

(8)

7F

XX

XX

XX

XX

 

XX

XX

1

2

3

4

5

 

18

19

 

,

- 1

         101X.XXXX ( XX 1, 8 )

 

(-) 1 1 ,

 

1 -

 

() 1 1 1 ,

 

:

1.      ( )

2.     

3.     


 

FormatBuffer512(char *buf, short len)

{

unsigned i,k,l,m;

 

/*----------------------------------------------------------*/

 

b_out[0] = 0x7f; // Flag message

b_out[1] = buf[0];

 

k=0;

for( i=0; i<8; i++ ) k += (buf[0]>>i)&1;

if( k&1 ) b_out[2] = (~buf[0]);

else b_out[2] = ( buf[0]);

 

l = ((buf[0]&0xF0) == 0x50)? 8:1; // ?

for( i=0; i<l; i++ )

{

b_out[(i*2)+3] = buf[1+i];

k=0;

for( m=0; m<8; m++ ) k += (buf[1+i]>>m)&1;

if( k&1 ) b_out[(i*2)+4] = ( buf[1+i] )^0x55;

else b_out[(i*2)+4] = (~buf[1+i] )^0x55;

}

len_out = ((buf[0]&0xF0) == 0x50)?19:5;

return 0;

}