C# 클래스 CyrusBuilt.MonoPi.IO.I2C.I2CBus

An I2C bus implementation for the Raspberry Pi. Derived from the RPi.I2C.Net library by mshmelev at https://github.com/mshmelev/RPi.I2C.Net. As such, this class (and the required methods in UnsafeNativeMethods) is dependent on the underlying LibNativeI2C native library which must be compiled and included with this library.
상속: II2CBus
파일 보기 프로젝트 열기: cyrusbuilt/MonoPi 1 사용 예제들

공개 메소드들

메소드 설명
Close ( ) : void

Closes the connection.

Dispose ( ) : void

Releases all resource used by the CyrusBuilt.MonoPi.IO.I2C.I2CBus object.

Call Dispose when you are finished using the CyrusBuilt.MonoPi.IO.I2C.I2CBus. The Dispose method leaves the CyrusBuilt.MonoPi.IO.I2C.I2CBus in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.IO.I2C.I2CBus so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.IO.I2C.I2CBus was occupying.

I2CBus ( BoardRevision boardRev ) : System

Initializes a new instance of the CyrusBuilt.MonoPi.IO.I2C.I2CBus class with the path the I2C bus.

Open ( BoardRevision boardRev ) : I2CBus

Gets an open I2C connection instance.

Open ( ) : void

Open a connection to the I2C bus.

Read ( Int32 address ) : Byte

Reads a single byte from the device at the specified address.

ReadBytes ( Int32 address, Int32 count ) : Byte[]

Reads bytes from the device at the specified address.

WriteByte ( Int32 address, Byte b ) : void

Writes a single byte to the specified device address.

WriteBytes ( Int32 address, Byte bytes ) : void

Writes an array of bytes to the specified device address.

Currently, RPi drivers do not allow writing more than 3 bytes at a time. As such, if an array of greater than 3 bytes is provided, an exception is thrown.

WriteCommand ( Int32 address, Byte command, Byte data ) : void

Writes a command with data to the specified device address.

WriteCommand ( Int32 address, Byte command, Byte data1, Byte data2 ) : void

Writes a command with data to the specified device address.

WriteCommand ( Int32 address, Byte command, ushort data ) : void

Writes a command with data to the specified device address.

보호된 메소드들

메소드 설명
Dispose ( System.Boolean disposing ) : void

Releases all resource used by the CyrusBuilt.MonoPi.IO.I2C.I2CBus object.

메소드 상세

Close() 공개 메소드

Closes the connection.
public Close ( ) : void
리턴 void

Dispose() 공개 메소드

Releases all resource used by the CyrusBuilt.MonoPi.IO.I2C.I2CBus object.
Call Dispose when you are finished using the CyrusBuilt.MonoPi.IO.I2C.I2CBus. The Dispose method leaves the CyrusBuilt.MonoPi.IO.I2C.I2CBus in an unusable state. After calling Dispose, you must release all references to the CyrusBuilt.MonoPi.IO.I2C.I2CBus so the garbage collector can reclaim the memory that the CyrusBuilt.MonoPi.IO.I2C.I2CBus was occupying.
public Dispose ( ) : void
리턴 void

Dispose() 보호된 메소드

Releases all resource used by the CyrusBuilt.MonoPi.IO.I2C.I2CBus object.
protected Dispose ( System.Boolean disposing ) : void
disposing System.Boolean /// Set true if disposing managed resources as well as unmanaged. ///
리턴 void

I2CBus() 공개 메소드

Initializes a new instance of the CyrusBuilt.MonoPi.IO.I2C.I2CBus class with the path the I2C bus.
public I2CBus ( BoardRevision boardRev ) : System
boardRev BoardRevision /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. ///
리턴 System

Open() 공개 정적인 메소드

Gets an open I2C connection instance.
/// This instance has been disposed. /// /// Unable to open the bus connection. ///
public static Open ( BoardRevision boardRev ) : I2CBus
boardRev BoardRevision /// Specifies the revision of the RPi board in use. This /// used to determine the path to the system file associated /// with the i2c bus. ///
리턴 I2CBus

Open() 공개 메소드

Open a connection to the I2C bus.
/// This instance has been disposed. /// /// Unable to open the bus connection. ///
public Open ( ) : void
리턴 void

Read() 공개 메소드

Reads a single byte from the device at the specified address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public Read ( Int32 address ) : Byte
address System.Int32 /// The address of the device to read from. ///
리턴 Byte

ReadBytes() 공개 메소드

Reads bytes from the device at the specified address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public ReadBytes ( Int32 address, Int32 count ) : Byte[]
address System.Int32 /// The address of the device to read from. ///
count System.Int32 /// The number of bytes to read. ///
리턴 Byte[]

WriteByte() 공개 메소드

Writes a single byte to the specified device address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public WriteByte ( Int32 address, Byte b ) : void
address System.Int32 /// The address of the target device. ///
b Byte /// The byte to write. ///
리턴 void

WriteBytes() 공개 메소드

Writes an array of bytes to the specified device address.
Currently, RPi drivers do not allow writing more than 3 bytes at a time. As such, if an array of greater than 3 bytes is provided, an exception is thrown.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// cannot be greater than 3 elements in length. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public WriteBytes ( Int32 address, Byte bytes ) : void
address System.Int32 /// The address of the target device. ///
bytes Byte /// The byte array to write. ///
리턴 void

WriteCommand() 공개 메소드

Writes a command with data to the specified device address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public WriteCommand ( Int32 address, Byte command, Byte data ) : void
address System.Int32 /// The address of the target device. ///
command Byte /// The command to send to the device. ///
data Byte /// The data to send with the command. ///
리턴 void

WriteCommand() 공개 메소드

Writes a command with data to the specified device address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public WriteCommand ( Int32 address, Byte command, Byte data1, Byte data2 ) : void
address System.Int32 /// The address of the target device. ///
command Byte /// The command to send to the device. ///
data1 Byte /// The data to send as the first parameter. ///
data2 Byte /// The data to send as the second parameter. ///
리턴 void

WriteCommand() 공개 메소드

Writes a command with data to the specified device address.
/// This instance has been disposed and can no longer be used. /// /// You must open a conection to the I2C bus by calling /// first. /// /// An I/O error occurred. The specified address is inacessible or the /// I2C transaction failed. ///
public WriteCommand ( Int32 address, Byte command, ushort data ) : void
address System.Int32 /// The address of the target device. ///
command Byte /// The command to send to the device. ///
data ushort /// The data to send with the command. ///
리턴 void