COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
pic_lib.cpp File Reference
Include dependency graph for pic_lib.cpp:

Functions

int32_t pic_connect (char *dev, pic_handle *handle)
 Connect to PIC. More...
 
int32_t pic_disconnect (pic_handle *handle)
 Disconnect from PIC. More...
 
int32_t pic_getframe (pic_handle *handle)
 
int32_t pic_putframe (pic_handle *handle)
 
int32_t suchi_heater (pic_handle *handle, uint8_t number, uint8_t state)
 
int32_t suchi_shutter (pic_handle *handle, uint8_t number, uint8_t state)
 
int32_t suchi_camera (pic_handle *handle, uint8_t state)
 
int32_t suchi_report (pic_handle *handle)
 

Function Documentation

int32_t pic_getframe ( pic_handle handle)
74 {
75  int32_t iretn;
76  uint16_t size;
77 
78  iretn=cssl_getslip(handle->serial, handle->buffer.raw, sizeof(handle->buffer.raw));
79  if (iretn < 0)
80  return iretn;
81 
82  size = handle->buffer.packet.header.size+PIC_HEADER_SIZE;
83 
84  union
85  {
86  uint16_t crc;
87  uint8_t crcbuf[2];
88  } tbuf;
89  tbuf.crcbuf[0] = handle->buffer.raw[size];
90  tbuf.crcbuf[1] = handle->buffer.raw[size+1];
91  if (tbuf.crc != slip_calc_crc(handle->buffer.raw, size) )
92  return (SLIP_ERROR_CRC);
93 
94  return iretn;
95 }
picstruc buffer
Definition: pic_lib.h:155
int iretn
Definition: rw_test.cpp:37
int32_t cssl_getslip(cssl_t *serial, uint8_t *buf, uint16_t size)
Read SLIP frame.
Definition: cssl_lib.cpp:826
png_uint_32 crc
Definition: png.c:2173
#define PIC_HEADER_SIZE
Definition: pic_lib.h:63
#define SLIP_ERROR_CRC
Definition: cosmos-errno.h:100
uint16_t slip_calc_crc(uint8_t *buf, uint16_t size)
Calculate CRC-16-CCITT.
Definition: sliplib.cpp:322
cssl_t * serial
Definition: pic_lib.h:154
int32_t pic_putframe ( pic_handle handle)
98 {
99  int32_t iretn;
100  uint16_t size;
101 
102  size = (uint16_t)(handle->buffer.packet.header.size+PIC_HEADER_SIZE);
103 
104  union
105  {
106  uint16_t crc;
107  uint8_t crcbuf[2];
108  } tbuf;
109  tbuf.crc = slip_calc_crc(handle->buffer.raw, size);
110  handle->buffer.raw[size] = tbuf.crcbuf[0];
111  handle->buffer.raw[size+1] = tbuf.crcbuf[1];
112 
113  iretn=cssl_putslip(handle->serial, handle->buffer.raw, size+2);
114 
115  return iretn;
116 }
picstruc buffer
Definition: pic_lib.h:155
int iretn
Definition: rw_test.cpp:37
png_uint_32 crc
Definition: png.c:2173
#define PIC_HEADER_SIZE
Definition: pic_lib.h:63
uint16_t slip_calc_crc(uint8_t *buf, uint16_t size)
Calculate CRC-16-CCITT.
Definition: sliplib.cpp:322
cssl_t * serial
Definition: pic_lib.h:154
int32_t cssl_putslip(cssl_t *serial, uint8_t *buf, size_t size)
Definition: cssl_lib.cpp:586
int32_t suchi_camera ( pic_handle handle,
uint8_t  state 
)
153 {
154  if (state)
155  handle->buffer.packet.header.cmd = SUCHI_CMD_SET_CAMERA_ON;
156  else
157  handle->buffer.packet.header.cmd = SUCHI_CMD_SET_CAMERA_OFF;
158  handle->buffer.packet.header.flags = 0;
159  handle->buffer.packet.header.seq = handle->buffer.seq++;
160  handle->buffer.packet.header.size = sizeof(pic_cmd_args0);
161 
162  pic_putframe(handle);
163 
164  return 0;
165 }
picstruc buffer
Definition: pic_lib.h:155
#define SUCHI_CMD_SET_CAMERA_ON
Definition: pic_lib.h:71
int32_t pic_putframe(pic_handle *handle)
Definition: pic_lib.cpp:97
Definition: pic_lib.h:106
#define SUCHI_CMD_SET_CAMERA_OFF
Definition: pic_lib.h:72