Inverting serial data stream

05 Dec 2010

Hello.

I am receiving data from an IR Link (not standard),  but the transmitting device  has the data inverted (yes,  I am responsible for that)

Is there anyway to invert the data  easily  in s/ware.  I  tried !getc below but no luck.

 

Thanks

/****************************************************************/

void remotecontrol(){

myled=!myled;
pc.putc(remote.getc() + 1); /* get the char and send  to the terminal */

}

 

/*************************************************************/

05 Dec 2010

Hi Andrew,

To invert a value, you can use the bitwise invert operator ~ (tilde):

int value = 0x7145C;
int inverted = ~value;

This may be exactly what you want.

Note that it is not the same as say inverting the sense of a UART (from TTL to RS232), where the whole transmission including framing etc needs to be inverted. For that case, you wouldn't be able to use this technique, as the whole signal needs to be inverted. But I'm assuming that is not what you are doing.

Hope that helps, Simon

05 Dec 2010

Thanks  Simon - I'll try that out.  If  it does'nt fly,  its time to pull  out the soldering iron . . .

Thanks

Andrew