views:

388

answers:

3

Hi,

I am newbie in Low level programming. In my project(C#.NET) we are using EDBS protocol(7 bit format) for communication and i have the data in bit format to send like 00101010 so we would please guide me how to send these to port.I know that the serial port class accepts data in binary format but dont know how convert the bit format into byte .

Thanks in advance

prem

+1  A: 

Use the BitConverter class to create basic types (like bytes or ints) from bytes.

http://msdn.microsoft.com/en-us/library/system.bitconverter.aspx

There is also a class called BitArray that can be used to store bit representations:

http://stackoverflow.com/questions/560123/convert-from-bitarray-to-byte

A: 

.Net only receives data in byte (the smallest unit), you can use BitConverter to convert various value type to byte of array and vice verse.

Akash Kava
A: 

There is a class called BitVector32 which lets you encapsulate your bit values into 32 bit number. Sorry about yesterday's answer, I just found this today.

Akash Kava