COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
pic_lib.h
Go to the documentation of this file.
1 /********************************************************************
2 * Copyright (C) 2015 by Interstel Technologies, Inc.
3 * and Hawaii Space Flight Laboratory.
4 *
5 * This file is part of the COSMOS/core that is the central
6 * module for COSMOS. For more information on COSMOS go to
7 * <http://cosmos-project.com>
8 *
9 * The COSMOS/core software is licenced under the
10 * GNU Lesser General Public License (LGPL) version 3 licence.
11 *
12 * You should have received a copy of the
13 * GNU Lesser General Public License
14 * If not, go to <http://www.gnu.org/licenses/>
15 *
16 * COSMOS/core is free software: you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public License
18 * as published by the Free Software Foundation, either version 3 of
19 * the License, or (at your option) any later version.
20 *
21 * COSMOS/core is distributed in the hope that it will be useful, but
22 * WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * Refer to the "licences" folder for further information on the
27 * condititons and terms to use this software.
28 ********************************************************************/
29 
44 #ifndef _PICLIB_H
45 #define _PICLIB_H
46 
47 #include "support/configCosmos.h"
49 #include "support/jsonlib.h"
50 
54 
55 #define PIC_BAUD 9600
56 #define PIC_BITS 8
57 #define PIC_PARITY 0
58 #define PIC_STOPBITS 1
59 
60 #ifdef COSMOS_WIN_BUILD_MSVC
61 #define PIC_HEADER_SIZE 6
62 #else
63 #define PIC_HEADER_SIZE (ptrdiff_t)(((pic_header*)0)+1)
64 #endif
65 #define PIC_DATA_SIZE 300
66 
67 #define SUCHI_CMD_SET_HEATER_ON 0x10
68 #define SUCHI_CMD_SET_HEATER_OFF 0x11
69 #define SUCHI_CMD_SET_SHUTTER_OPEN 0x20
70 #define SUCHI_CMD_SET_SHUTTER_CLOSED 0x21
71 #define SUCHI_CMD_SET_CAMERA_ON 0x30
72 #define SUCHI_CMD_SET_CAMERA_OFF 0x31
73 #define SUCHI_CMD_GET_REPORT 0x41
74 
75 #define SUCHI_STATE_HEATER_ON_1 0x0001
76 #define SUCHI_STATE_HEATER_ON_2 0x0002
77 #define SUCHI_STATE_HEATER_ON_3 0x0004
78 #define SUCHI_STATE_HEATER_ON_4 0x0008
79 #define SUCHI_STATE_SHUTTER_OPEN_1 0x0010
80 #define SUCHI_STATE_SHUTTER_OPEN_2 0x0020
81 #define SUCHI_STATE_SHUTTER_OPEN_3 0x0040
82 #define SUCHI_STATE_SHUTTER_OPEN_4 0x0080
83 #define SUCHI_STATE_CAMERA_ON 0x0100
84 
86 
87 
91 enum
92 {
96 } ;
97 
98 typedef struct
99 {
100  uint8_t cmd;
101  uint8_t flags;
102  uint16_t seq;
103  uint16_t size;
104 } pic_header;
105 
106 typedef struct
107 {
108 } pic_cmd_args0;
109 
110 typedef struct
111 {
112  uint16_t arg;
113 } pic_cmd_args1;
114 
115 typedef struct
116 {
117  uint16_t suchi_state;
118  uint16_t sw_wdt_heaters[4];
119  uint16_t sw_wdt_shutters[4];
120  uint16_t reserved;
121  float temperatures[9];
122  float pressure;
123  uint32_t uptime;
124  uint32_t uart_frames_rx;
127 
128 typedef struct
129 {
130  union
131  {
132  struct
133  {
135  union
136  {
140  uint8_t data[PIC_DATA_SIZE];
141  };
142  } packet;
144  } ;
145  uint16_t seq;
146 #ifdef COSMOS_WIN_BUILD_MSVC
147 } picstruc;
148 #else
149 } __attribute__((__may_alias__)) picstruc;
150 #endif
151 
153 {
155  picstruc buffer;
156 #ifdef COSMOS_WIN_BUILD_MSVC
157 };
158 #else
159 } __attribute__((__may_alias__));
160 #endif
161 
162 int32_t pic_connect(char *dev, pic_handle *handle);
164 int32_t suchi_heater(pic_handle *handle, uint8_t number, uint8_t state);
165 int32_t suchi_shutter(pic_handle *handle, uint8_t number, uint8_t state);
166 int32_t suchi_camera(pic_handle *handle, uint8_t number, uint8_t state);
167 int32_t suchi_report(pic_handle *handle);
168 int32_t isc_power_on(pic_handle *handle, uint8_t number, uint32_t seconds);
170 int32_t isc_put(pic_handle *handle);
171 int32_t isc_get(pic_handle *handle);
172 
173 #endif
174 
176 
int32_t isc_get(pic_handle *handle)
Definition: pic_lib.h:98
pic_res_suchireport suchi_report
Definition: pic_lib.h:139
uint16_t arg
Definition: pic_lib.h:112
int32_t isc_report(pic_handle *handle)
picstruc buffer
Definition: pic_lib.h:155
Definition: pic_lib.h:152
uint32_t uptime
Definition: pic_lib.h:123
int32_t suchi_report(pic_handle *handle)
Definition: pic_lib.cpp:167
int32_t pic_connect(char *dev, pic_handle *handle)
Connect to PIC.
Definition: pic_lib.cpp:40
Simple Serial library header file.
int32_t isc_power_on(pic_handle *handle, uint8_t number, uint32_t seconds)
uint16_t seq
Definition: pic_lib.h:145
#define PIC_HEADER_SIZE
Definition: pic_lib.h:63
uint32_t uart_frames_rx
Definition: pic_lib.h:124
int32_t suchi_camera(pic_handle *handle, uint8_t number, uint8_t state)
float pressure
Definition: pic_lib.h:122
uint8_t flags
Definition: pic_lib.h:101
Definition: pic_lib.h:94
pic_cmd_args0 args_0
Definition: pic_lib.h:138
uint16_t reserved
Definition: pic_lib.h:120
struct pic_handle __attribute__((__may_alias__))
pic_header header
Definition: pic_lib.h:134
int32_t suchi_heater(pic_handle *handle, uint8_t number, uint8_t state)
Definition: pic_lib.cpp:118
int32_t pic_disconnect(pic_handle *handle)
Disconnect from PIC.
Definition: pic_lib.cpp:64
uint16_t size
Definition: pic_lib.h:103
JSON Support definitions.
Headers and definitions common to all COSMOS.
uint8_t cmd
Definition: pic_lib.h:100
Definition: pic_lib.h:110
uint16_t seq
Definition: pic_lib.h:102
gige_handle * handle
Definition: kpc9612p_recv.cpp:33
int32_t isc_put(pic_handle *handle)
uint16_t suchi_state
Definition: pic_lib.h:117
cssl_t * serial
Definition: pic_lib.h:154
uint32_t uart_bytes_discard
Definition: pic_lib.h:125
pic_cmd_args1 args_1_16
Definition: pic_lib.h:137
#define PIC_DATA_SIZE
Definition: pic_lib.h:65
int32_t suchi_shutter(pic_handle *handle, uint8_t number, uint8_t state)
Definition: pic_lib.cpp:135
Definition: pic_lib.h:106
Definition: pic_lib.h:115
Definition: pic_lib.h:93
Definition: pic_lib.h:95
Definition: cssl_lib.h:34