FRDM-IMX93 for NXP CUP
FRDM-IMX93 support for NXP CUP
 
Loading...
Searching...
No Matches
pixy2_protocol.h File Reference

Pixy2 protocol layer API. More...

#include "pixy2_transport.h"

Go to the source code of this file.

Macros

#define PIXY2_REQUEST_GET_VERSION   0xe
 
#define PIXY2_REQUEST_SET_LED   0x14
 
#define PIXY2_REQUEST_SET_LAMP   0x16
 
#define PIXY2_REQUEST_GET_MAIN_FEATURES   0x30
 
#define PIXY2_REPLY_GET_VERSION   0xf
 
#define PIXY2_REPLY_SET_LED   0x1
 
#define PIXY2_REPLY_SET_LAMP   0x1
 
#define PIXY2_REPLY_GET_MAIN_FEATURES   0x31
 
#define PIXY2_REPLY_ERROR   0x3
 
#define PIXY2_OK   0
 
#define PIXY2_ERROR   -1
 
#define PIXY2_BUSY   -2
 
#define PIXY2_CHECKSUM_ERROR   -3
 
#define PIXY2_TIMEOUT   -4
 
#define PIXY2_BUTTON_OVERRIDE   -5
 
#define PIXY2_PROG_CHANGING   -6
 
#define PIXY2_REQUEST_SYNC0_NO_CHECKSUM   0xae
 
#define PIXY2_REQUEST_SYNC1_NO_CHECKSUM   0xc1
 
#define PIXY2_REQUEST_SYNC0_CHECKSUM   0xaf
 
#define PIXY2_REQUEST_SYNC1_CHECKSUM   0xc1
 
#define PIXY2_REPLY_SYNC0   0xaf
 
#define PIXY2_REPLY_SYNC1   0xc1
 
#define PIXY2_REQUEST_SYNC0(checksum)
 Get the value of SYNC0 based on checksum being enabled or not.
 
#define PIXY2_REQUEST_SYNC1(checksum)
 Get the value of SYNC1 based on checksum being enabled or not.
 

Functions

int pixy2_to_errno (int32_t result)
 Convert a Pixy2 status code to errno-like code.
 
int pixy2_protocol_transceive (struct pixy2_transport *t, struct pixy2_message *req, struct pixy2_message *reply)
 Send a request, wait for its reply and validate it.
 

Detailed Description

Pixy2 protocol layer API.

This file offers the protocol layer API required for delivering and receiving messages to/from the Pixy2 camera. As opposed to the transport layer, the protocol layer also performs some extra validations on the received messages.

Function Documentation

◆ pixy2_protocol_transceive()

int pixy2_protocol_transceive ( struct pixy2_transport t,
struct pixy2_message req,
struct pixy2_message reply 
)

Send a request, wait for its reply and validate it.

This function is used to send a request to the Pixy2 camera, wait for its reply and then perform some basic sanity checks on it. Upper layers should use this instead of pixy2_transport_transceive.

Parameters
tpointer to the generic transport layer data
reqpointer to the request data
replypointer to the reply data
Return values
0if success
negativeerrno code if error

◆ pixy2_to_errno()

int pixy2_to_errno ( int32_t  result)

Convert a Pixy2 status code to errno-like code.

Parameters
resultstatus code from a Pixy2 reply
Return values
errno-likeconverted status code