prem
prem

Reputation:

How to send data to port in binary format

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

Upvotes: 0

Views: 1837

Answers (3)

Akash Kava
Akash Kava

Reputation: 39956

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.

Upvotes: 0

Johan S
Johan S

Reputation:

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:

Convert from BitArray to Byte

Upvotes: 1

Akash Kava
Akash Kava

Reputation: 39956

.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.

Upvotes: 0

Related Questions