[−][src]Struct tinkerforge::can_v2_bricklet::CanV2Bricklet
Communicates with CAN bus devices
Methods
impl CanV2Bricklet
[src]
pub const DEVICE_IDENTIFIER: u16
[src]
pub const DEVICE_DISPLAY_NAME: &'static str
[src]
pub fn new<T: GetRequestSender>(uid: &str, req_sender: T) -> CanV2Bricklet
[src]
Creates an object with the unique device ID uid
. This object can then be used after the IP Connection ip_connection
is connected.
pub fn get_response_expected(
&mut self,
fun: CanV2BrickletFunction
) -> Result<bool, GetResponseExpectedError>
[src]
&mut self,
fun: CanV2BrickletFunction
) -> Result<bool, GetResponseExpectedError>
Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.
For getter functions this is enabled by default and cannot be disabled, because those
functions will always send a response. For callback configuration functions it is enabled
by default too, but can be disabled by set_response_expected
.
For setter functions it is disabled by default and can be enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.
See set_response_expected
for the list of function ID constants available for this function.
pub fn set_response_expected(
&mut self,
fun: CanV2BrickletFunction,
response_expected: bool
) -> Result<(), SetResponseExpectedError>
[src]
&mut self,
fun: CanV2BrickletFunction,
response_expected: bool
) -> Result<(), SetResponseExpectedError>
Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is send and errors are silently ignored, because they cannot be detected.
pub fn set_response_expected_all(&mut self, response_expected: bool)
[src]
Changes the response expected flag for all setter and callback configuration functions of this device at once.
pub fn get_api_version(&self) -> [u8; 3]
[src]
Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
pub fn get_frame_read_low_level_callback_receiver(
&self
) -> ConvertingCallbackReceiver<FrameReadLowLevelEvent>
[src]
&self
) -> ConvertingCallbackReceiver<FrameReadLowLevelEvent>
ⓘImportant traits for ConvertingHighLevelCallbackReceiver<PayloadT, ResultT, T>pub fn get_frame_read_callback_receiver(
&self
) -> ConvertingHighLevelCallbackReceiver<u8, FrameReadResult, FrameReadLowLevelEvent>
[src]
&self
) -> ConvertingHighLevelCallbackReceiver<u8, FrameReadResult, FrameReadLowLevelEvent>
This receiver is triggered if a data or remote frame was received by the CAN transceiver.
The identifier
return value follows the identifier format described for
write_frame
.
For details on the data
return value see read_frame
.
A configurable read filter can be used to define which frames should be
received by the CAN transceiver and put into the read queue (see
set_queue_configuration
).
To enable this receiver, use set_frame_read_callback_configuration
.
pub fn write_frame_low_level(
&self,
frame_type: u8,
identifier: u32,
data_length: u8,
data_data: [u8; 15]
) -> ConvertingReceiver<WriteFrameLowLevel>
[src]
&self,
frame_type: u8,
identifier: u32,
data_length: u8,
data_data: [u8; 15]
) -> ConvertingReceiver<WriteFrameLowLevel>
Writes a data or remote frame to the write queue to be transmitted over the CAN transceiver.
The Bricklet supports the standard 11-bit (CAN 2.0A) and the additional extended
29-bit (CAN 2.0B) identifiers. For standard frames the Bricklet uses bit 0 to 10
from the identifier
parameter as standard 11-bit identifier. For extended
frames the Bricklet uses bit 0 to 28 from the identifier
parameter as
extended 29-bit identifier.
The data
parameter can be up to 15 bytes long. For data frames up to 8 bytes
will be used as the actual data. The length (DLC) field in the data or remote
frame will be set to the actual length of the data
parameter. This allows
to transmit data and remote frames with excess length. For remote frames only
the length of the data
parameter is used. The actual data
bytes are
ignored.
Returns true if the frame was successfully added to the write queue. Returns
false if the frame could not be added because write queue is already full or
because the write buffer or the write backlog are configured with a size of
zero (see set_queue_configuration
).
The write queue can overflow if frames are written to it at a higher rate
than the Bricklet can transmitted them over the CAN transceiver. This may
happen if the CAN transceiver is configured as read-only or is using a low baud
rate (see set_transceiver_configuration
). It can also happen if the CAN
bus is congested and the frame cannot be transmitted because it constantly loses
arbitration or because the CAN transceiver is currently disabled due to a high
write error level (see get_error_log
).
Associated constants:
- CAN_V2_BRICKLET_FRAME_TYPE_STANDARD_DATA
- CAN_V2_BRICKLET_FRAME_TYPE_STANDARD_REMOTE
- CAN_V2_BRICKLET_FRAME_TYPE_EXTENDED_DATA
- CAN_V2_BRICKLET_FRAME_TYPE_EXTENDED_REMOTE
pub fn write_frame(
&self,
frame_type: u8,
identifier: u32,
data: &[u8]
) -> Result<bool, BrickletRecvTimeoutError>
[src]
&self,
frame_type: u8,
identifier: u32,
data: &[u8]
) -> Result<bool, BrickletRecvTimeoutError>
Writes a data or remote frame to the write queue to be transmitted over the CAN transceiver.
The Bricklet supports the standard 11-bit (CAN 2.0A) and the additional extended
29-bit (CAN 2.0B) identifiers. For standard frames the Bricklet uses bit 0 to 10
from the identifier
parameter as standard 11-bit identifier. For extended
frames the Bricklet uses bit 0 to 28 from the identifier
parameter as
extended 29-bit identifier.
The data
parameter can be up to 15 bytes long. For data frames up to 8 bytes
will be used as the actual data. The length (DLC) field in the data or remote
frame will be set to the actual length of the data
parameter. This allows
to transmit data and remote frames with excess length. For remote frames only
the length of the data
parameter is used. The actual data
bytes are
ignored.
Returns true if the frame was successfully added to the write queue. Returns
false if the frame could not be added because write queue is already full or
because the write buffer or the write backlog are configured with a size of
zero (see set_queue_configuration
).
The write queue can overflow if frames are written to it at a higher rate
than the Bricklet can transmitted them over the CAN transceiver. This may
happen if the CAN transceiver is configured as read-only or is using a low baud
rate (see set_transceiver_configuration
). It can also happen if the CAN
bus is congested and the frame cannot be transmitted because it constantly loses
arbitration or because the CAN transceiver is currently disabled due to a high
write error level (see get_error_log
).
pub fn read_frame_low_level(&self) -> ConvertingReceiver<ReadFrameLowLevel>
[src]
Tries to read the next data or remote frame from the read queue and returns it.
If a frame was successfully read, then the success
return value is set to
true and the other return values contain the frame. If the read queue is
empty and no frame could be read, then the success
return value is set to
false and the other return values contain invalid data.
The identifier
return value follows the identifier format described for
write_frame
.
The data
return value can be up to 15 bytes long. For data frames up to the
first 8 bytes are the actual received data. All bytes after the 8th byte are
always zero and only there to indicate the length of a data or remote frame
with excess length. For remote frames the length of the data
return value
represents the requested length. The actual data
bytes are always zero.
A configurable read filter can be used to define which frames should be
received by the CAN transceiver and put into the read queue (see
set_read_filter_configuration
).
Instead of polling with this function, you can also use receivers. See the
set_frame_read_callback_configuration
function and the get_frame_read_callback_receiver
callback.
Associated constants:
- CAN_V2_BRICKLET_FRAME_TYPE_STANDARD_DATA
- CAN_V2_BRICKLET_FRAME_TYPE_STANDARD_REMOTE
- CAN_V2_BRICKLET_FRAME_TYPE_EXTENDED_DATA
- CAN_V2_BRICKLET_FRAME_TYPE_EXTENDED_REMOTE
pub fn read_frame(
&self
) -> Result<(Vec<u8>, ReadFrameResult), BrickletRecvTimeoutError>
[src]
&self
) -> Result<(Vec<u8>, ReadFrameResult), BrickletRecvTimeoutError>
Tries to read the next data or remote frame from the read queue and returns it.
If a frame was successfully read, then the success
return value is set to
true and the other return values contain the frame. If the read queue is
empty and no frame could be read, then the success
return value is set to
false and the other return values contain invalid data.
The identifier
return value follows the identifier format described for
write_frame
.
The data
return value can be up to 15 bytes long. For data frames up to the
first 8 bytes are the actual received data. All bytes after the 8th byte are
always zero and only there to indicate the length of a data or remote frame
with excess length. For remote frames the length of the data
return value
represents the requested length. The actual data
bytes are always zero.
A configurable read filter can be used to define which frames should be
received by the CAN transceiver and put into the read queue (see
set_read_filter_configuration
).
Instead of polling with this function, you can also use receivers. See the
set_frame_read_callback_configuration
function and the get_frame_read_callback_receiver
callback.
pub fn set_frame_read_callback_configuration(
&self,
enabled: bool
) -> ConvertingReceiver<()>
[src]
&self,
enabled: bool
) -> ConvertingReceiver<()>
Enables and disables the get_frame_read_callback_receiver
receiver.
By default the receiver is disabled.
pub fn get_frame_read_callback_configuration(&self) -> ConvertingReceiver<bool>
[src]
Returns true if the get_frame_read_callback_receiver
receiver is enabled, false otherwise.
pub fn set_transceiver_configuration(
&self,
baud_rate: u32,
sample_point: u16,
transceiver_mode: u8
) -> ConvertingReceiver<()>
[src]
&self,
baud_rate: u32,
sample_point: u16,
transceiver_mode: u8
) -> ConvertingReceiver<()>
Sets the transceiver configuration for the CAN bus communication.
The CAN transceiver has three different modes:
- Normal: Reads from and writes to the CAN bus and performs active bus error detection and acknowledgement.
- Loopback: All reads and writes are performed internally. The transceiver is disconnected from the actual CAN bus.
- Read-Only: Only reads from the CAN bus, but does neither active bus error detection nor acknowledgement. Only the receiving part of the transceiver is connected to the CAN bus.
Associated constants:
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_NORMAL
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_LOOPBACK
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_READ_ONLY
pub fn get_transceiver_configuration(
&self
) -> ConvertingReceiver<TransceiverConfiguration>
[src]
&self
) -> ConvertingReceiver<TransceiverConfiguration>
Returns the configuration as set by set_transceiver_configuration
.
Associated constants:
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_NORMAL
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_LOOPBACK
- CAN_V2_BRICKLET_TRANSCEIVER_MODE_READ_ONLY
pub fn set_queue_configuration_low_level(
&self,
write_buffer_size: u8,
write_buffer_timeout: i32,
write_backlog_size: u16,
read_buffer_sizes_length: u8,
read_buffer_sizes_data: [i8; 32],
read_backlog_size: u16
) -> ConvertingReceiver<SetQueueConfigurationLowLevel>
[src]
&self,
write_buffer_size: u8,
write_buffer_timeout: i32,
write_backlog_size: u16,
read_buffer_sizes_length: u8,
read_buffer_sizes_data: [i8; 32],
read_backlog_size: u16
) -> ConvertingReceiver<SetQueueConfigurationLowLevel>
Sets the write and read queue configuration.
The CAN transceiver has 32 buffers in total in hardware for transmitting and receiving frames. Additionally, the Bricklet has a backlog for 768 frames in total in software. The buffers and the backlog can be freely assigned to the write and read queues.
write_frame
writes a frame into the write backlog. The Bricklet moves
the frame from the backlog into a free write buffer. The CAN transceiver then
transmits the frame from the write buffer to the CAN bus. If there are no
write buffers (write_buffer_size
is zero) or there is no write backlog
(write_backlog_size
is zero) then no frames can be transmitted and
write_frame
returns always false.
The CAN transceiver receives a frame from the CAN bus and stores it into a
free read buffer. The Bricklet moves the frame from the read buffer into the
read backlog. read_frame
reads the frame from the read backlog and
returns it. If there are no read buffers (read_buffer_sizes
is empty) or
there is no read backlog (read_backlog_size
is zero) then no frames can be
received and read_frame
returns always false.
There can be multiple read buffers, because the CAN transceiver cannot receive
data and remote frames into the same read buffer. A positive read buffer size
represents a data frame read buffer and a negative read buffer size represents
a remote frame read buffer. A read buffer size of zero is not allowed. By
default the first read buffer is configured for data frames and the second read
buffer is configured for remote frame. There can be up to 32 different read
buffers, assuming that no write buffer is used. Each read buffer has its own
filter configuration (see set_read_filter_configuration
).
A valid queue configuration fulfills these conditions::
write_buffer_size + abs(read_buffer_size_0) + abs(read_buffer_size_1) + ... + abs(read_buffer_size_31) <= 32 write_backlog_size + read_backlog_size <= 768
The write buffer timeout has three different modes that define how a failed frame transmission should be handled:
- Single-Shot (< 0): Only one transmission attempt will be made. If the transmission fails then the frame is discarded.
- Infinite (= 0): Infinite transmission attempts will be made. The frame will never be discarded.
- Milliseconds (> 0): A limited number of transmission attempts will be made. If the frame could not be transmitted successfully after the configured number of milliseconds then the frame is discarded.
The current content of the queues is lost when this function is called.
pub fn set_queue_configuration(
&self,
write_buffer_size: u8,
write_buffer_timeout: i32,
write_backlog_size: u16,
read_backlog_size: u16,
read_buffer_sizes: &[i8]
) -> Result<(), BrickletRecvTimeoutError>
[src]
&self,
write_buffer_size: u8,
write_buffer_timeout: i32,
write_backlog_size: u16,
read_backlog_size: u16,
read_buffer_sizes: &[i8]
) -> Result<(), BrickletRecvTimeoutError>
Sets the write and read queue configuration.
The CAN transceiver has 32 buffers in total in hardware for transmitting and receiving frames. Additionally, the Bricklet has a backlog for 768 frames in total in software. The buffers and the backlog can be freely assigned to the write and read queues.
write_frame
writes a frame into the write backlog. The Bricklet moves
the frame from the backlog into a free write buffer. The CAN transceiver then
transmits the frame from the write buffer to the CAN bus. If there are no
write buffers (write_buffer_size
is zero) or there is no write backlog
(write_backlog_size
is zero) then no frames can be transmitted and
write_frame
returns always false.
The CAN transceiver receives a frame from the CAN bus and stores it into a
free read buffer. The Bricklet moves the frame from the read buffer into the
read backlog. read_frame
reads the frame from the read backlog and
returns it. If there are no read buffers (read_buffer_sizes
is empty) or
there is no read backlog (read_backlog_size
is zero) then no frames can be
received and read_frame
returns always false.
There can be multiple read buffers, because the CAN transceiver cannot receive
data and remote frames into the same read buffer. A positive read buffer size
represents a data frame read buffer and a negative read buffer size represents
a remote frame read buffer. A read buffer size of zero is not allowed. By
default the first read buffer is configured for data frames and the second read
buffer is configured for remote frame. There can be up to 32 different read
buffers, assuming that no write buffer is used. Each read buffer has its own
filter configuration (see set_read_filter_configuration
).
A valid queue configuration fulfills these conditions::
write_buffer_size + abs(read_buffer_size_0) + abs(read_buffer_size_1) + ... + abs(read_buffer_size_31) <= 32 write_backlog_size + read_backlog_size <= 768
The write buffer timeout has three different modes that define how a failed frame transmission should be handled:
- Single-Shot (< 0): Only one transmission attempt will be made. If the transmission fails then the frame is discarded.
- Infinite (= 0): Infinite transmission attempts will be made. The frame will never be discarded.
- Milliseconds (> 0): A limited number of transmission attempts will be made. If the frame could not be transmitted successfully after the configured number of milliseconds then the frame is discarded.
The current content of the queues is lost when this function is called.
pub fn get_queue_configuration_low_level(
&self
) -> ConvertingReceiver<QueueConfigurationLowLevel>
[src]
&self
) -> ConvertingReceiver<QueueConfigurationLowLevel>
Returns the queue configuration as set by set_queue_configuration
.
pub fn get_queue_configuration(
&self
) -> Result<(Vec<i8>, QueueConfigurationResult), BrickletRecvTimeoutError>
[src]
&self
) -> Result<(Vec<i8>, QueueConfigurationResult), BrickletRecvTimeoutError>
Returns the queue configuration as set by set_queue_configuration
.
pub fn set_read_filter_configuration(
&self,
buffer_index: u8,
filter_mode: u8,
filter_mask: u32,
filter_identifier: u32
) -> ConvertingReceiver<()>
[src]
&self,
buffer_index: u8,
filter_mode: u8,
filter_mask: u32,
filter_identifier: u32
) -> ConvertingReceiver<()>
Set the read filter configuration for the given read buffer index. This can be used to define which frames should be received by the CAN transceiver and put into the read buffer.
The read filter has four different modes that define if and how the filter mask and the filter identifier are applied:
- Accept-All: All frames are received.
- Match-Standard-Only: Only standard frames with a matching identifier are received.
- Match-Extended-Only: Only extended frames with a matching identifier are received.
- Match-Standard-And-Extended: Standard and extended frames with a matching identifier are received.
The filter mask and filter identifier are used as bit masks. Their usage depends on the mode:
- Accept-All: Mask and identifier are ignored.
- Match-Standard-Only: Bit 0 to 10 (11 bits) of filter mask and filter identifier are used to match the 11-bit identifier of standard frames.
- Match-Extended-Only: Bit 0 to 28 (29 bits) of filter mask and filter identifier are used to match the 29-bit identifier of extended frames.
- Match-Standard-And-Extended: Bit 18 to 28 (11 bits) of filter mask and filter identifier are used to match the 11-bit identifier of standard frames, bit 0 to 17 (18 bits) are ignored in this case. Bit 0 to 28 (29 bits) of filter mask and filter identifier are used to match the 29-bit identifier of extended frames.
The filter mask and filter identifier are applied in this way: The filter mask is used to select the frame identifier bits that should be compared to the corresponding filter identifier bits. All unselected bits are automatically accepted. All selected bits have to match the filter identifier to be accepted. If all bits for the selected mode are accepted then the frame is accepted and is added to the read buffer.
Filter Mask Bit | Filter Identifier Bit | Frame Identifier Bit | Result |
---|---|---|---|
0 | X | X | Accept |
1 | 0 | 0 | Accept |
1 | 0 | 1 | Reject |
1 | 1 | 0 | Reject |
1 | 1 | 1 | Accept |
For example, to receive standard frames with identifier 0x123 only, the mode can be set to Match-Standard-Only with 0x7FF as mask and 0x123 as identifier. The mask of 0x7FF selects all 11 identifier bits for matching so that the identifier has to be exactly 0x123 to be accepted.
To accept identifier 0x123 and identifier 0x456 at the same time, just set filter 2 to 0x456 and keep mask and filter 1 unchanged.
There can be up to 32 different read filters configured at the same time,
because there can be up to 32 read buffer (see set_queue_configuration
).
The default mode is accept-all for all read buffers.
Associated constants:
- CAN_V2_BRICKLET_FILTER_MODE_ACCEPT_ALL
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_STANDARD_ONLY
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_EXTENDED_ONLY
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_STANDARD_AND_EXTENDED
pub fn get_read_filter_configuration(
&self,
buffer_index: u8
) -> ConvertingReceiver<ReadFilterConfiguration>
[src]
&self,
buffer_index: u8
) -> ConvertingReceiver<ReadFilterConfiguration>
Returns the read filter configuration as set by set_read_filter_configuration
.
Associated constants:
- CAN_V2_BRICKLET_FILTER_MODE_ACCEPT_ALL
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_STANDARD_ONLY
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_EXTENDED_ONLY
- CAN_V2_BRICKLET_FILTER_MODE_MATCH_STANDARD_AND_EXTENDED
pub fn get_error_log_low_level(&self) -> ConvertingReceiver<ErrorLogLowLevel>
[src]
Returns information about different kinds of errors.
The write and read error levels indicate the current level of stuffing, form, acknowledgement, bit and checksum errors during CAN bus write and read operations. For each of this error kinds there is also an individual counter.
When the write error level extends 255 then the CAN transceiver gets disabled and no frames can be transmitted or received anymore. The CAN transceiver will automatically be activated again after the CAN bus is idle for a while.
The write buffer timeout, read buffer and backlog overflow counts represents the number of these errors:
- A write buffer timeout occurs if a frame could not be transmitted before the
configured write buffer timeout expired (see
set_queue_configuration
). - A read buffer overflow occurs if a read buffer of the CAN transceiver
still contains the last received frame when the next frame arrives. In this
case the last received frame is lost. This happens if the CAN transceiver
receives more frames than the Bricklet can handle. Using the read filter
(see
set_read_filter_configuration
) can help to reduce the amount of received frames. This count is not exact, but a lower bound, because the Bricklet might not able detect all overflows if they occur in rapid succession. - A read backlog overflow occurs if the read backlog of the Bricklet is already
full when the next frame should be read from a read buffer of the CAN
transceiver. In this case the frame in the read buffer is lost. This
happens if the CAN transceiver receives more frames to be added to the read
backlog than are removed from the read backlog using the
read_frame
function. Using theget_frame_read_callback_receiver
receiver ensures that the read backlog can not overflow.
The read buffer overflow counter counts the overflows of all configured read
buffers. Which read buffer exactly suffered from an overflow can be figured
out from the read buffer overflow occurrence list
(read_buffer_overflow_error_occurred
).
Associated constants:
- CAN_V2_BRICKLET_TRANSCEIVER_STATE_ACTIVE
- CAN_V2_BRICKLET_TRANSCEIVER_STATE_PASSIVE
- CAN_V2_BRICKLET_TRANSCEIVER_STATE_DISABLED
pub fn get_error_log(
&self
) -> Result<(Vec<bool>, ErrorLogResult), BrickletRecvTimeoutError>
[src]
&self
) -> Result<(Vec<bool>, ErrorLogResult), BrickletRecvTimeoutError>
Returns information about different kinds of errors.
The write and read error levels indicate the current level of stuffing, form, acknowledgement, bit and checksum errors during CAN bus write and read operations. For each of this error kinds there is also an individual counter.
When the write error level extends 255 then the CAN transceiver gets disabled and no frames can be transmitted or received anymore. The CAN transceiver will automatically be activated again after the CAN bus is idle for a while.
The write buffer timeout, read buffer and backlog overflow counts represents the number of these errors:
- A write buffer timeout occurs if a frame could not be transmitted before the
configured write buffer timeout expired (see
set_queue_configuration
). - A read buffer overflow occurs if a read buffer of the CAN transceiver
still contains the last received frame when the next frame arrives. In this
case the last received frame is lost. This happens if the CAN transceiver
receives more frames than the Bricklet can handle. Using the read filter
(see
set_read_filter_configuration
) can help to reduce the amount of received frames. This count is not exact, but a lower bound, because the Bricklet might not able detect all overflows if they occur in rapid succession. - A read backlog overflow occurs if the read backlog of the Bricklet is already
full when the next frame should be read from a read buffer of the CAN
transceiver. In this case the frame in the read buffer is lost. This
happens if the CAN transceiver receives more frames to be added to the read
backlog than are removed from the read backlog using the
read_frame
function. Using theget_frame_read_callback_receiver
receiver ensures that the read backlog can not overflow.
The read buffer overflow counter counts the overflows of all configured read
buffers. Which read buffer exactly suffered from an overflow can be figured
out from the read buffer overflow occurrence list
(read_buffer_overflow_error_occurred
).
pub fn set_communication_led_config(&self, config: u8) -> ConvertingReceiver<()>
[src]
Sets the communication LED configuration. By default the LED shows CAN-Bus traffic, it flickers once for every 40 transmitted or received frames.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is off.
Associated constants:
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_OFF
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_ON
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION
pub fn get_communication_led_config(&self) -> ConvertingReceiver<u8>
[src]
Returns the configuration as set by set_communication_led_config
Associated constants:
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_OFF
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_ON
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION
pub fn set_error_led_config(&self, config: u8) -> ConvertingReceiver<()>
[src]
Sets the error LED configuration.
By default (show-transceiver-state) the error LED turns on if the CAN
transceiver is passive or disabled state (see get_error_log
). If
the CAN transceiver is in active state the LED turns off.
If the LED is configured as show-error then the error LED turns on if any error occurs. If you call this function with the show-error option again, the LED will turn off until the next error occurs.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is off.
Associated constants:
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_OFF
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_ON
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_TRANSCEIVER_STATE
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_ERROR
pub fn get_error_led_config(&self) -> ConvertingReceiver<u8>
[src]
Returns the configuration as set by set_error_led_config
.
Associated constants:
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_OFF
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_ON
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_TRANSCEIVER_STATE
- CAN_V2_BRICKLET_ERROR_LED_CONFIG_SHOW_ERROR
pub fn get_spitfp_error_count(&self) -> ConvertingReceiver<SpitfpErrorCount>
[src]
Returns the error count for the communication between Brick and Bricklet.
The errors are divided into
- ACK checksum errors,
- message checksum errors,
- framing errors and
- overflow errors.
The errors counts are for errors that occur on the Bricklet side. All Bricks have a similar function that returns the errors on the Brick side.
pub fn set_bootloader_mode(&self, mode: u8) -> ConvertingReceiver<u8>
[src]
Sets the bootloader mode and returns the status after the requested mode change was instigated.
You can change from bootloader mode to firmware mode and vice versa. A change from bootloader mode to firmware mode will only take place if the entry function, device identifier and CRC are present and correct.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
Associated constants:
- CAN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
- CAN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_OK
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT
- CAN_V2_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH
pub fn get_bootloader_mode(&self) -> ConvertingReceiver<u8>
[src]
Returns the current bootloader mode, see set_bootloader_mode
.
Associated constants:
- CAN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE
- CAN_V2_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT
- CAN_V2_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT
pub fn set_write_firmware_pointer(&self, pointer: u32) -> ConvertingReceiver<()>
[src]
Sets the firmware pointer for write_firmware
. The pointer has
to be increased by chunks of size 64. The data is written to flash
every 4 chunks (which equals to one page of size 256).
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
pub fn write_firmware(&self, data: [u8; 64]) -> ConvertingReceiver<u8>
[src]
Writes 64 Bytes of firmware at the position as written by
set_write_firmware_pointer
before. The firmware is written
to flash every 4 chunks.
You can only write firmware in bootloader mode.
This function is used by Brick Viewer during flashing. It should not be necessary to call it in a normal user program.
pub fn set_status_led_config(&self, config: u8) -> ConvertingReceiver<()>
[src]
Sets the status LED configuration. By default the LED shows communication traffic between Brick and Bricklet, it flickers once for every 10 received data packets.
You can also turn the LED permanently on/off or show a heartbeat.
If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
Associated constants:
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_OFF
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_ON
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
pub fn get_status_led_config(&self) -> ConvertingReceiver<u8>
[src]
Returns the configuration as set by set_status_led_config
Associated constants:
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_OFF
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_ON
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT
- CAN_V2_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS
pub fn get_chip_temperature(&self) -> ConvertingReceiver<i16>
[src]
Returns the temperature in °C as measured inside the microcontroller. The value returned is not the ambient temperature!
The temperature is only proportional to the real temperature and it has bad accuracy. Practically it is only useful as an indicator for temperature changes.
pub fn reset(&self) -> ConvertingReceiver<()>
[src]
Calling this function will reset the Bricklet. All configurations will be lost.
After a reset you have to create new device objects, calling functions on the existing ones will result in undefined behavior!
pub fn write_uid(&self, uid: u32) -> ConvertingReceiver<()>
[src]
Writes a new UID into flash. If you want to set a new UID you have to decode the Base58 encoded UID string into an integer first.
We recommend that you use Brick Viewer to change the UID.
pub fn read_uid(&self) -> ConvertingReceiver<u32>
[src]
Returns the current UID as an integer. Encode as Base58 to get the usual string version.
pub fn get_identity(&self) -> ConvertingReceiver<Identity>
[src]
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c' or 'd'.
The device identifier numbers can be found here. |device_identifier_constant|
Trait Implementations
impl Clone for CanV2Bricklet
[src]
fn clone(&self) -> CanV2Bricklet
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl Send for CanV2Bricklet
impl !Sync for CanV2Bricklet
impl Unpin for CanV2Bricklet
impl !UnwindSafe for CanV2Bricklet
impl !RefUnwindSafe for CanV2Bricklet
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self