CanControllerApiWrapper Class
Namespace: GHIElectronics.TinyCLR.Devices.Can.Provider · Assembly: GHIElectronics.TinyCLR.Devices.Can
Concrete ICanControllerProvider backed by the native TinyCLR CAN HAL.
public sealed class CanControllerApiWrapper : ICanControllerProvider
Constructors
CanControllerApiWrapper(NativeApi api)
public CanControllerApiWrapper(NativeApi api)
Wraps the given native API as a provider.
| Parameter | Type | Description |
|---|---|---|
api | NativeApi |
Properties
Api
public NativeApi Api { get; }
The underlying native API descriptor.
WriteBufferSize
public extern int WriteBufferSize { get; set; }
Size in bytes of the transmit buffer. (inherited)
ReadBufferSize
public extern int ReadBufferSize { get; set; }
Size in bytes of the receive buffer. (inherited)
MessagesToWrite
public extern int MessagesToWrite { get; }
Messages currently queued for transmission. (inherited)
MessagesToRead
public extern int MessagesToRead { get; }
Messages currently available to read. (inherited)
CanWriteMessage
public extern bool CanWriteMessage { get; }
True when the transmit queue has room. (inherited)
CanReadMessage
public extern bool CanReadMessage { get; }
True when at least one received message is available. (inherited)
WriteErrorCount
public extern int WriteErrorCount { get; }
Current transmit error counter (TEC). (inherited)
ReadErrorCount
public extern int ReadErrorCount { get; }
Current receive error counter (REC). (inherited)
SourceClock
public extern int SourceClock { get; }
Source clock feeding the CAN prescaler, in Hz. (inherited)
Methods
Dispose()
public void Dispose()
Releases the native controller.
Enable()
public extern void Enable()
Re-enables interrupts after a matching Disable. (inherited)
Disable()
public extern void Disable()
Disables interrupts on the current core. Always pair with Enable. (inherited)
WriteMessages(CanMessage[] messages, int offset, int count)
public extern int WriteMessages(CanMessage[] messages, int offset, int count)
Queues a slice of messages for transmission. Returns count actually queued. (inherited)
| Parameter | Type | Description |
|---|---|---|
messages | CanMessage[] | |
offset | int | |
count | int |
Returns int
ReadMessages(CanMessage[] messages, int offset, int count)
public extern int ReadMessages(CanMessage[] messages, int offset, int count)
Dequeues up to count received messages. Returns count actually read. (inherited)
| Parameter | Type | Description |
|---|---|---|
messages | CanMessage[] | |
offset | int | |
count | int |
Returns int
SetNominalBitTiming(CanBitTiming bitTiming)
public extern void SetNominalBitTiming(CanBitTiming bitTiming)
Configures arbitration-phase bit timing. (inherited)
| Parameter | Type | Description |
|---|---|---|
bitTiming | CanBitTiming |
SetDataBitTiming(CanBitTiming bitTiming)
public extern void SetDataBitTiming(CanBitTiming bitTiming)
Configures CAN-FD data-phase bit timing. (inherited)
| Parameter | Type | Description |
|---|---|---|
bitTiming | CanBitTiming |
ClearWriteBuffer()
public extern void ClearWriteBuffer()
Empties the transmit buffer. (inherited)
ClearReadBuffer()
public extern void ClearReadBuffer()
Empties the receive buffer. (inherited)
AddFilter(Filter.IdType idType, Filter.FilterType filterType, uint id1, uint id2)
public extern void AddFilter(Filter.IdType idType, Filter.FilterType filterType, uint id1, uint id2)
Installs an acceptance filter. (inherited)
| Parameter | Type | Description |
|---|---|---|
idType | Filter.IdType | |
filterType | Filter.FilterType | |
id1 | uint | |
id2 | uint |
RejectRemoteFrame(Filter.IdType idType)
public extern void RejectRemoteFrame(Filter.IdType idType)
Filters out RTR frames of the given ID width. (inherited)
| Parameter | Type | Description |
|---|---|---|
idType | Filter.IdType |
ClearFilter()
public extern void ClearFilter()
Removes every installed filter. (inherited)
Events
MessageReceived
public event MessageReceivedEventHandler MessageReceived
Raised when messages arrive. (inherited)
ErrorReceived
public event ErrorReceivedEventHandler ErrorReceived
Raised when a frame/parity/overrun error is detected. (inherited)