upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
API for the Serial Camera. More...
The driver was tested with the Serial Camera. There is no protocol documentation currently available, so this module was developed based completely on the Seeed Studio* Arduino* sketch.
It is connected via a UART at 115,200 baud.
Public Types | |
enum | PIC_FORMATS_T { FORMAT_VGA = 7, FORMAT_CIF = 5, FORMAT_OCIF = 3 } |
Public Member Functions | |
SCAM (int uart, uint8_t camAddr=SCAM_DEFAULT_CAMERA_ADDR) | |
~SCAM () | |
bool | dataAvailable (unsigned int millis) |
int | readData (uint8_t *buffer, int len) |
int | writeData (uint8_t *buffer, int len) |
bool | setupTty (speed_t baud=B115200) |
void | drainInput () |
bool | init () |
bool | preCapture (PIC_FORMATS_T fmt=FORMAT_VGA) |
bool | doCapture () |
bool | storeImage (const char *fname) |
int | getImageSize () |
Static Public Attributes | |
static const unsigned int | MAX_PKT_LEN = 128 |
Protected Member Functions | |
int | ttyFd () |
SCAM | ( | int | uart, |
uint8_t | camAddr = SCAM_DEFAULT_CAMERA_ADDR |
||
) |
Serial Camera constructor
uart | Default UART to use (0 or 1) |
camAddr | 3-bit address identifier of the camera; default is 0 |
bool dataAvailable | ( | unsigned int | millis | ) |
Checks to see if there is data available for reading
millis | Number of milliseconds to wait; 0 means no waiting. |
int readData | ( | uint8_t * | buffer, |
int | len | ||
) |
Reads any available data into a user-supplied buffer. Note: the call blocks until data is available to be read. Use dataAvailable() to determine whether there is data available beforehand, to avoid blocking.
buffer | Buffer to hold the data read |
len | Length of the buffer |
int writeData | ( | uint8_t * | buffer, |
int | len | ||
) |
Writes the data in the buffer to the device
buffer | Buffer to hold the data read |
len | Length of the buffer |
bool setupTty | ( | speed_t | baud = B115200 | ) |
Sets up proper tty I/O modes and the baud rate. For this device, the default baud rate is 9,600 (B9600).
baud | Desired baud rate |
void drainInput | ( | ) |
Reads serial input and discards until no more characters are available
bool init | ( | ) |
Initializes the camera
bool preCapture | ( | PIC_FORMATS_T | fmt = FORMAT_VGA | ) |
Tells the camera to prepare for a capture
fmt | One of the PIC_FORMATS_T values |
bool doCapture | ( | ) |
Starts the capture
bool storeImage | ( | const char * | fname | ) |
Stores the captured image in a file
fname | Name of the file to write |
let the games begin...
|
inline |
Returns the picture length. Note: this is only valid after doCapture() has run successfully.