34 return (counter + i) % buffer_size;
43 return (counter - i + buffer_size) % buffer_size;
53 if (stack[i] == 255 && (stack[
stereoprot_add(i, 1, buffer_size)] == 0)
67 if (stack[i] == 255 && (stack[
stereoprot_add(i, 1, buffer_size)] == 0)
80 if (dev->check_free_space(dev->periph, &fd, length)) {
81 for (
uint8_t index = 0; index < length; index++) {
82 dev->put_byte(dev->periph, fd, code[index]);
100 int horizontalLine = 0;
101 for (horizontalLine = 0; horizontalLine < array_height; horizontalLine++) {
105 while (
WritePart(fd, b + array_width * horizontalLine, array_width) == 0)
124 uint8_t *stereocam_datalen,
uint8_t *stereocam_data_matrix_width,
uint8_t *stereocam_data_matrix_height)
130 if (
stereoprot_add(*insert_loc, 1, buffer_size) != *extract_loc) {
151 for (k = 0; k < msgProperties.
height; k++) {
152 for (j = 0; j < msgProperties.
width; j++) {
153 msg_buf[index++] = ser_read_buf[i];
158 *stereocam_datalen = msgProperties.
width * msgProperties.
height;
159 *stereocam_data_matrix_width = msgProperties.
width;
160 *stereocam_data_matrix_height = msgProperties.
height;
162 *stereocam_datadata_new = 1;
180 uint16_t i = start, startOfLine = start;
void stereoprot_get_msg_properties(uint8_t *raw, MsgProperties *properties, uint16_t start, uint16_t buffer_size)
Retrieve size of image from message.
struct MsgProperties MsgProperties
uint8_t stereoprot_isEndOfMsg(uint8_t *stack, uint16_t i, uint16_t buffer_size)
Checks if the sequence in the array is equal to 255-0-0-171, as this means that this is the end of an...
standard protocol for TUDelft stereocamera data transfer
void stereoprot_sendArray(struct link_device *fd, uint8_t *b, uint8_t array_width, uint8_t array_height)
uint16_t stereoprot_diff(uint16_t counter, uint16_t i, uint16_t buffer_size)
Decrement circular buffer counter by i.
uint8_t stereoprot_isStartOfMsg(uint8_t *stack, uint16_t i, uint16_t buffer_size)
Checks if the sequence in the array is equal to 255-0-0-171, as this means a new image is starting fr...
MsgProperties msgProperties
uint8_t WritePart(struct link_device *dev, uint8_t *code, uint8_t length)
static const struct usb_device_descriptor dev
uint16_t stereoprot_add(uint16_t counter, uint16_t i, uint16_t buffer_size)
Increment circular buffer counter by i.
uint8_t handleStereoPackage(uint8_t newByte, uint16_t buffer_size, uint16_t *insert_loc, uint16_t *extract_loc, uint16_t *msg_start, uint8_t *msg_buf, uint8_t *ser_read_buf, uint8_t *stereocam_datadata_new, uint8_t *stereocam_datalen, uint8_t *stereocam_data_matrix_width, uint8_t *stereocam_data_matrix_height)
Get all available data from stereo com link and decode any complete messages.
uint8_t ser_read_buf[STEREO_BUF_SIZE]
uint8_t msg_buf[STEREO_BUF_SIZE]