SerialDevice
pyaer.device.SerialDevice()
Base class for serial devices.
The base class for devices that use the serial port. eDVS is the only current supported device in this family.
open
open(device_type, device_id=1, serial_port_name='/dev/ttyUSB0', serial_baud_rate=12000000)
Open USB deivce.
Arguments
- device_type:
int
Device type:
libcaer.CAER_DEVICE_DVS128
,libcaer.CAER_DEVICE_EDVS
,libcaer.CAER_DEVICE_DAVIS
,libcaer.CAER_DEVICE_DAVIS_FX2
,libcaer.CAER_DEVICE_DAVIS_FX3
,libcaer.CAER_DEVICE_DAVIS_RPI
,libcaer.CAER_DEVICE_DYNAPSE
. - device_id:
int
a unique ID to identify the device from others. Will be used as the source for EventPackets being generate from its data.
default is 1
. - serial_port_name:
str
name of the serial port device to open.
default is /dev/ttyUSB0
- serial_baud_rate:
uint32_t
baud-rate for serial port communication.
default is 12M
data_start
data_start()
Start data transmission.
Returns
- flag:
bool
ReturnTrue
if the data transmission is initialized successfully. OtherwiseFalse
.
data_stop
data_stop()
Stop data transmission.
This method stops the data transmission only.
Note that this method does not destroy the respective
device handle
.
close
close()
Close USB device.
This method closes an opened USB device if the respective handle is not None.
shutdown
shutdown()
Shutdown device.
This method is a combination of data_stop
and close
.
This is a preferred way of shutting down a device.
send_default_config
send_default_config()
Send default configuration.
Each type of devices has a set of default configurations (e.g. bias)
that are pre-defined in the libcaer
library.
Note that the default configuration might not be suitable for your
needs.
Returns
- flag:
bool
returnTrue
if the default config is set successfully,False
otherwise.
set_data_exchange_blocking
set_data_exchange_blocking(exchange_blocking=True)
Set data exchange blocking.
Arguments
- exchange_blocking:
bool
whether to start all the data producer modules on the device (DVS, APS, Mux, ...) automatically when starting the data transfer thread withcaerDeviceDataStart()
or not. If disabled, be aware you will have to start the right modules manually, which can be useful if you need precise control over which ones are running at any time.
The default isTrue
.
set_config
set_config(mod_addr, param_addr, param)
Set configuration.
The main function of setting configurations (e.g., bias).
Arguments
- mod_addr:
int
a module address, used to specify which configuration module one wants to update. Negative addresses are used for host-side configuration, while positive addresses (including zero) are used for device-side configuration. - param_addr:
int
a parameter address, to select a specific parameter to update from this particular configuration module. Only positive numbers (including zero) are allowed. - param:
int
orbool
a configuration parameter's new value.
Returns
- flag:
bool
returnsTrue
if the config is set successfully,False
otherwise.
get_config
get_config(mod_addr, param_addr)
Get Configuration.
Arguments
- mod_addr:
int
a module address, used to specify which configuration module one wants to update. Negative addresses are used for host-side configuration, while positive addresses (including zero) are used for device-side configuration. - param_addr:
int
a parameter address, to select a specific parameter to update from this particular configuration module. Only positive numbers (including zero) are allowed.
Returns
- param:
int
orbool
a configuration parameter's new value. Returns None if the handle is not valid.
get_event
get_event()
Get Event.
This abstract method should be implemented in all derived classes. This method returns a packet of events according to the type of the sensor.
get_packet_container
get_packet_container()
Get event packet container.
Returns
- packet_container:
caerEventPacketContainer
a container that consists of event packets. - packet_number:
int
number of event packet in the container.
get_packet_header
get_packet_header(packet_container, idx)
Get a single packet header.
Arguments
- packet_container:
caerEventPacketContainer
the event packet container - idx:
int
the index of the packet header
Returns
- packet_header:
caerEventPacketHeader
the header that represents a event packet - packet_type:
caerEventPacketType
the type of the event packet
get_polarity_event
get_polarity_event(packet_header)
Get a packet of polarity event.
Arguments
- packet_header:
caerEventPacketHeader
the header that represents a event packet
Returns
- events:
numpy.ndarray
a 2-D array that has the shape of (N, 4) where N is the number of events in the event packet. Each row in the array represents a single polarity event. The first number is the timestamp. The second number is the X position of the event. The third number is the Y position of the event. The fourth number represents the polarity of the event (positive or negative). - num_events:
int
number of the polarity events available in the packet.