read temperature test
This commit is contained in:
65
gomspace/libgscsp/include/gs/csp/address.h
Normal file
65
gomspace/libgscsp/include/gs/csp/address.h
Normal file
@ -0,0 +1,65 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_ADDRESS_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_ADDRESS_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Default CSP addresses for nodes in the satellite - often changed for each project.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Default address for OBC (On Board Computer).
|
||||
Example: a3200-sdk.
|
||||
*/
|
||||
#define GS_CSP_ADDR_OBC 1
|
||||
/**
|
||||
Power supply.
|
||||
Example: nano-power.
|
||||
*/
|
||||
#define GS_CSP_ADDR_EPS 2
|
||||
/**
|
||||
Payload address.
|
||||
*/
|
||||
#define GS_CSP_ADDR_PAYLOAD_3 3
|
||||
/**
|
||||
Default address for ADCS.
|
||||
Example: a3200-adcs.
|
||||
*/
|
||||
#define GS_CSP_ADDR_ADCS 4
|
||||
/**
|
||||
Default address for radio.
|
||||
Example: nanocom-ax.
|
||||
*/
|
||||
#define GS_CSP_ADDR_NANOCOM 5
|
||||
/**
|
||||
Payload address.
|
||||
*/
|
||||
#define GS_CSP_ADDR_PAYLOAD_6 6
|
||||
/**
|
||||
Battery pack.
|
||||
Example: nano-power-bpx.
|
||||
*/
|
||||
#define GS_CSP_ADDR_BPX 7
|
||||
/**
|
||||
Payload address.
|
||||
*/
|
||||
#define GS_CSP_ADDR_PAYLOAD_8 8
|
||||
/**
|
||||
Reaction wheels.
|
||||
Example: gsw-600.
|
||||
*/
|
||||
#define GS_CSP_ADDR_GSW600 9
|
||||
/**
|
||||
Antenna module.
|
||||
Example: ant2150.
|
||||
*/
|
||||
#define GS_CSP_ADDR_ANT2150 10
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
25
gomspace/libgscsp/include/gs/csp/command.h
Normal file
25
gomspace/libgscsp/include/gs/csp/command.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_COMMAND_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_COMMAND_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP commands.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Register CSP commands.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_register_commands(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
26
gomspace/libgscsp/include/gs/csp/conn.h
Normal file
26
gomspace/libgscsp/include/gs/csp/conn.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_CONN_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_CONN_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Extensions to standard libcsp connection interface.
|
||||
*/
|
||||
|
||||
#include <gs/util/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Return number of open connections.
|
||||
|
||||
@return number of open connections.
|
||||
*/
|
||||
size_t gs_csp_conn_get_open(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
202
gomspace/libgscsp/include/gs/csp/csp.h
Normal file
202
gomspace/libgscsp/include/gs/csp/csp.h
Normal file
@ -0,0 +1,202 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_CSP_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_CSP_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Extensions to standard libcsp.
|
||||
*/
|
||||
|
||||
#include <gs/csp/error.h>
|
||||
#include <gs/csp/port.h>
|
||||
#include <gs/csp/rtable.h>
|
||||
#include <csp/csp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Default CSP timeout (mS).
|
||||
|
||||
Default timeout value for communicating with a satellite, based on round-trip time of approximately 500 mS.
|
||||
*/
|
||||
#define GS_CSP_TIMEOUT 3000
|
||||
|
||||
/**
|
||||
Check if address is a valid CSP adddress.
|
||||
@param[in] address CSP address to verify
|
||||
@return \a true if address is valid.
|
||||
*/
|
||||
bool gs_csp_is_address_valid(uint8_t address);
|
||||
|
||||
/**
|
||||
gscsp and csp configuration.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Forward CSP logs to GomSpace log (libutil).
|
||||
*/
|
||||
bool use_gs_log;
|
||||
|
||||
/**
|
||||
Use command line options.
|
||||
Configure interfaces specified on the command line.
|
||||
@note Only supported on Linux - ignored on platforms without command line options.
|
||||
*/
|
||||
bool use_command_line_options;
|
||||
|
||||
/**
|
||||
Size of a CSP buffer (in bytes).
|
||||
@see csp_buffer_init().
|
||||
*/
|
||||
size_t csp_buffer_size;
|
||||
/**
|
||||
Number of CSP buffers to allocate.
|
||||
@see csp_buffer_init().
|
||||
*/
|
||||
size_t csp_buffers;
|
||||
|
||||
/**
|
||||
CSP address of the system
|
||||
*/
|
||||
uint8_t address;
|
||||
/**
|
||||
Host name, returned by the #CSP_CMP_IDENT request.
|
||||
@note String must remain valid as long as the application is running.
|
||||
*/
|
||||
const char *hostname;
|
||||
/**
|
||||
Model, returned by the #CSP_CMP_IDENT request.
|
||||
@note String must remain valid as long as the application is running.
|
||||
*/
|
||||
const char *model;
|
||||
/**
|
||||
Revision, returned by the #CSP_CMP_IDENT request
|
||||
@note String must remain valid as long as the application is running.
|
||||
*/
|
||||
const char *revision;
|
||||
|
||||
} gs_csp_conf_t;
|
||||
|
||||
/**
|
||||
Get default CSP configuration for server systems.
|
||||
@param[in] conf user supplied configuration struct.
|
||||
*/
|
||||
void gs_csp_conf_get_defaults_server(gs_csp_conf_t * conf);
|
||||
|
||||
/**
|
||||
Get default CSP configuration for embedded systems.
|
||||
@param[in] conf user supplied configuration struct.
|
||||
*/
|
||||
void gs_csp_conf_get_defaults_embedded(gs_csp_conf_t * conf);
|
||||
|
||||
/**
|
||||
Initialize CSP.
|
||||
|
||||
Wraps initialization of libcsp, by calling following functions
|
||||
- hooks CSP log system into GomSpace log system.
|
||||
- initializes CSP buffers by calling csp_buffer_init()
|
||||
- initializes CSP by calling csp_init()
|
||||
- configure interfaces specificed on command line
|
||||
- configure routing table specificed on command line, or default if only one interface is present.
|
||||
|
||||
@param[in] conf configuration.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_init(const gs_csp_conf_t * conf);
|
||||
|
||||
/**
|
||||
Perform an entire request/reply transaction,
|
||||
|
||||
Copies both input buffer and reply to output buffer.
|
||||
Also makes the connection and closes it again
|
||||
Differ from 'csp_transaction()' by limiting input buffer size when input length is unknown
|
||||
|
||||
@param[in] prio CSP Prio
|
||||
@param[in] dest CSP Dest
|
||||
@param[in] port CSP Port
|
||||
@param[in] timeout timeout in ms
|
||||
@param[in] tx_buf pointer to outgoing data buffer
|
||||
@param[in] tx_len length of request to send
|
||||
@param[out] rx_buf pointer to incoming data buffer
|
||||
@param[in] rx_max_len length of expected reply (input buffer size)
|
||||
@param[out] rx_len pointer to length of reply
|
||||
@param[in] opts connection options.
|
||||
@return GS_ERROR_OVERFLOW when input length larger than buffer - it still updates rx_buf
|
||||
@return GS_ERROR_IO when 'csp_send()' or 'csp_read()' fails
|
||||
@return GS_ERROR_ALLOC when 'csp_get_buffer()' fails
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_transaction2(uint8_t prio,
|
||||
uint8_t dest,
|
||||
uint8_t port,
|
||||
uint32_t timeout,
|
||||
const void * tx_buf,
|
||||
size_t tx_len,
|
||||
void * rx_buf,
|
||||
size_t rx_max_len,
|
||||
size_t * rx_len,
|
||||
uint32_t opts);
|
||||
|
||||
/**
|
||||
Perform an entire request/reply transaction,
|
||||
|
||||
@param[in] prio CSP Prio
|
||||
@param[in] dest CSP Dest
|
||||
@param[in] port CSP Port
|
||||
@param[in] timeout timeout in ms
|
||||
@param[in] tx_buf pointer to outgoing data buffer
|
||||
@param[in] tx_len length of request to send
|
||||
@param[out] rx_buf pointer to incoming data buffer
|
||||
@param[in] rx_max_len length of expected reply (input buffer size)
|
||||
@param[out] rx_len pointer to length of reply
|
||||
@return GS_ERROR_OVERFLOW when input length larger than buffer - it still updates rx_buf
|
||||
@return GS_ERROR_IO when 'csp_send()' or 'csp_read()' fails
|
||||
@return GS_ERROR_ALLOC when 'csp_get_buffer()' fails
|
||||
@return_gs_error_t
|
||||
@see gs_csp_transaction2()
|
||||
*/
|
||||
static inline gs_error_t gs_csp_transaction(uint8_t prio,
|
||||
uint8_t dest,
|
||||
uint8_t port,
|
||||
uint32_t timeout,
|
||||
const void * tx_buf,
|
||||
size_t tx_len,
|
||||
void * rx_buf,
|
||||
size_t rx_max_len,
|
||||
size_t * rx_len)
|
||||
{
|
||||
return gs_csp_transaction2(prio, dest, port, timeout, tx_buf, tx_len, rx_buf, rx_max_len, rx_len, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
Use an existing connection to perform a transaction.
|
||||
|
||||
This is only possible if the next packet is on the same port and destination!
|
||||
Differ from 'csp_transaction_persistent()' by limiting input buffer size when input length is unknown
|
||||
|
||||
@param[in] conn pointer to connection structure
|
||||
@param[in] timeout timeout in ms
|
||||
@param[in] tx_buf pointer to outgoing data buffer
|
||||
@param[in] tx_len length of request to send
|
||||
@param[out] rx_buf pointer to incoming data buffer
|
||||
@param[in] rx_max_len length of expected reply (input buffer size)
|
||||
@param[out] rx_len pointer to length of reply
|
||||
@return GS_ERROR_OVERFLOW when input length larger than buffer - it still updates rx_buf
|
||||
@return GS_ERROR_IO when 'csp_send()' or 'csp_read()' fails
|
||||
@return GS_ERROR_ALLOC when 'csp_get_buffer()' fails
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_transaction_persistent(csp_conn_t * conn,
|
||||
uint32_t timeout,
|
||||
const void * tx_buf,
|
||||
size_t tx_len,
|
||||
void * rx_buf,
|
||||
size_t rx_max_len,
|
||||
size_t * rx_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
54
gomspace/libgscsp/include/gs/csp/drivers/can/can.h
Normal file
54
gomspace/libgscsp/include/gs/csp/drivers/can/can.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_CAN_CAN_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_CAN_CAN_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
GomSpace CAN API for CSP.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
#include <csp/csp_types.h>
|
||||
#include <csp/interfaces/csp_if_can.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Default CAN interface name.
|
||||
*/
|
||||
#define GS_CSP_CAN_DEFAULT_IF_NAME "CAN"
|
||||
|
||||
/**
|
||||
Initialize CSP for CAN device.
|
||||
|
||||
@param[in] device CAN device
|
||||
@param[in] csp_addr CSP address.
|
||||
@param[in] mtu MTU, normally CSP_CAN_MTU.
|
||||
@param[in] name name of CSP interface, if NULL #GS_CSP_CAN_DEFAULT_IF_NAME will be used.
|
||||
@param[in] set_default_route if \a true, the device will be set as default route.
|
||||
@param[out] csp_if the added CSP interface.
|
||||
@return #GS_ERROR_EXIST if device already exists.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_can_init2(uint8_t device, uint8_t csp_addr, uint32_t mtu, const char * name, bool set_default_route, csp_iface_t ** csp_if);
|
||||
|
||||
/**
|
||||
Initialize CSP for CAN device.
|
||||
|
||||
@param[in] device CAN device
|
||||
@param[in] csp_addr CSP address.
|
||||
@param[in] mtu MTU, normally CSP_CAN_MTU.
|
||||
@param[in] name name of CSP interface, if NULL #GS_CSP_CAN_DEFAULT_IF_NAME will be used.
|
||||
@param[out] csp_if the added CSP interface.
|
||||
@return #GS_ERROR_EXIST if device already exists.
|
||||
@return_gs_error_t
|
||||
@see gs_csp_can_init2()
|
||||
*/
|
||||
gs_error_t gs_csp_can_init(uint8_t device, uint8_t csp_addr, uint32_t mtu, const char * name, csp_iface_t ** csp_if);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
29
gomspace/libgscsp/include/gs/csp/drivers/i2c/i2c.h
Normal file
29
gomspace/libgscsp/include/gs/csp/drivers/i2c/i2c.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_I2C_I2C_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_I2C_I2C_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
GomSpace I2C API for CSP.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Initialize CSP for I2C device.
|
||||
@note I2C device must be initialized allready with the same I2C address as the CSP address.
|
||||
|
||||
@param[in] device I2C device.
|
||||
@param[in] csp_addr CSP address.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_i2c_init(uint8_t device, uint8_t csp_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
30
gomspace/libgscsp/include/gs/csp/drivers/kiss/kiss.h
Normal file
30
gomspace/libgscsp/include/gs/csp/drivers/kiss/kiss.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_KISS_KISS_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_DRIVERS_KISS_KISS_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
|
||||
/**
|
||||
@file
|
||||
|
||||
GomSpace KISS API for CSP.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
#include <csp/interfaces/csp_if_kiss.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Initialize CSP for KISS device.
|
||||
@note KISS/UART device must be initialized all ready.
|
||||
|
||||
@param[in] device KISS/UART device.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_kiss_init(uint8_t device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
28
gomspace/libgscsp/include/gs/csp/error.h
Normal file
28
gomspace/libgscsp/include/gs/csp/error.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_ERROR_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_ERROR_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Converting CSP error codes to #gs_error_t
|
||||
*/
|
||||
|
||||
#include <csp/csp_error.h>
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Convert CSP error.
|
||||
|
||||
@param[in] csp_error CSP error
|
||||
@return GS error code representing the CSP error.
|
||||
*/
|
||||
gs_error_t gs_csp_error(int csp_error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
24
gomspace/libgscsp/include/gs/csp/linux/command_line.h
Normal file
24
gomspace/libgscsp/include/gs/csp/linux/command_line.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef GS_CSP_LINUX_COMMAND_LINE_H
|
||||
#define GS_CSP_LINUX_COMMAND_LINE_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Command line support.
|
||||
*/
|
||||
|
||||
#include <gs/util/linux/argp.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Command line options.
|
||||
*/
|
||||
extern const struct argp_child gs_csp_command_line_options;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
27
gomspace/libgscsp/include/gs/csp/log.h
Normal file
27
gomspace/libgscsp/include/gs/csp/log.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_LOG_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_LOG_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP log hook.
|
||||
*/
|
||||
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Hook into CSP log system.
|
||||
All CSP logs will be logged through Log (libutil).
|
||||
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_log_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
111
gomspace/libgscsp/include/gs/csp/port.h
Normal file
111
gomspace/libgscsp/include/gs/csp/port.h
Normal file
@ -0,0 +1,111 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_PORT_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_PORT_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Port definitions for standard CSP and GomSpace services.
|
||||
*/
|
||||
|
||||
#include <csp/csp_types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Port definitions for standard CSP and GomSpace services.
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
CSP Management Protocol - standard CSP service.
|
||||
*/
|
||||
GS_CSP_CMP = CSP_CMP, // 0
|
||||
/**
|
||||
Ping - standard CSP service.
|
||||
*/
|
||||
GS_CSP_PING = CSP_PING, // 1
|
||||
/**
|
||||
Show process status - standard CSP service.
|
||||
*/
|
||||
GS_CSP_PS = CSP_PS, // 2
|
||||
/**
|
||||
Show memory free - standard CSP service.
|
||||
*/
|
||||
GS_CSP_MEM_FREE = CSP_MEMFREE, // 3
|
||||
GS_CSP_MEMFREE = GS_CSP_MEM_FREE,
|
||||
/**
|
||||
Reboot/reset request - standard CSP service.
|
||||
*/
|
||||
GS_CSP_REBOOT = CSP_REBOOT, // 4
|
||||
/**
|
||||
Show number of free CSP buffers - standard CSP service.
|
||||
*/
|
||||
GS_CSP_BUF_FREE = CSP_BUF_FREE, // 5
|
||||
/**
|
||||
Show uptime (time since last reset) - standard CSP service.
|
||||
*/
|
||||
GS_CSP_UPTIME = CSP_UPTIME, // 6
|
||||
/**
|
||||
Parameter service (libparam)
|
||||
*/
|
||||
GS_CSP_PORT_RPARAM = 7,
|
||||
/**
|
||||
File Transfer Service (libftp)
|
||||
*/
|
||||
GS_CSP_PORT_FTP = 9,
|
||||
/**
|
||||
Remote log service (liblog)
|
||||
*/
|
||||
GS_CSP_PORT_RLOG = 11,
|
||||
/**
|
||||
Remote GOSH service (librgosh)
|
||||
*/
|
||||
GS_CSP_PORT_RGOSH = 12,
|
||||
/**
|
||||
AIS command port (libais).
|
||||
*/
|
||||
GS_CSP_PORT_AIS = 13,
|
||||
/**
|
||||
ADS-B command port (libadsb).
|
||||
*/
|
||||
GS_CSP_PORT_ADSB = 14,
|
||||
|
||||
/**
|
||||
GomSpace Sensor Bus (libgssb).
|
||||
*/
|
||||
GS_CSP_PORT_GSSB = 16,
|
||||
/**
|
||||
Flight Planner (libfp).
|
||||
*/
|
||||
GS_CSP_PORT_FP = 18,
|
||||
/**
|
||||
ADCS (libadcs).
|
||||
*/
|
||||
GS_CSP_PORT_ADCS = 20,
|
||||
/**
|
||||
House Keeping (libhk).
|
||||
*/
|
||||
GS_CSP_PORT_HK = 21,
|
||||
/**
|
||||
G(omSpace) script service (libgosh)
|
||||
*/
|
||||
GS_CSP_PORT_GSCRIPT = 22,
|
||||
/**
|
||||
Remote shell (libgosh).
|
||||
Executes shell commands (linux server only).
|
||||
Requires CSP_O_RDP.
|
||||
*/
|
||||
GS_CSP_PORT_REMOTE_SHELL = 27,
|
||||
/**
|
||||
House keeping beacon port (libhk).
|
||||
Default port for sending beacons from satellite to ground (configurable).
|
||||
*/
|
||||
GS_CSP_PORT_HK_BEACON = 30,
|
||||
|
||||
} gs_csp_port_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
36
gomspace/libgscsp/include/gs/csp/router.h
Normal file
36
gomspace/libgscsp/include/gs/csp/router.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_ROUTER_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_ROUTER_H
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP router task, with support for stopping/terminating router task.
|
||||
*/
|
||||
|
||||
#include <gs/util/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Start CSP router (task/thread).
|
||||
@param[in] stack_size stack size in bytes, minimum 300 bytes.
|
||||
@param[in] priority task priority, normally GS_THREAD_PRIORITY_HIGH.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_router_task_start(size_t stack_size, gs_thread_priority_t priority);
|
||||
|
||||
/**
|
||||
Stop CSP router task (for testing).
|
||||
|
||||
Signal stop to the router and waits for it to terminate (join).
|
||||
@note Join is performed, which may hang forever if the router doesn't respond to the stop request.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_router_task_stop(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
31
gomspace/libgscsp/include/gs/csp/rtable.h
Normal file
31
gomspace/libgscsp/include/gs/csp/rtable.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef GS_CSP_RTABLE_H
|
||||
#define GS_CSP_RTABLE_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP routing table support.
|
||||
*/
|
||||
|
||||
#include <gs/csp/csp.h>
|
||||
#include <csp/csp_rtable.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Load routing table.
|
||||
Extension to csp_rtable_load().
|
||||
|
||||
@param[in] rtable string containing the routing table to set/load.
|
||||
@param[in] set_default_route if \a true, sets a default route if no routing table specified and only one interface configured.
|
||||
@param[in] use_command_line_option if \a true (and command line supported), use command line options to configure routing.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_rtable_load(const char * rtable, bool set_default_route, bool use_command_line_option);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
124
gomspace/libgscsp/include/gs/csp/service_dispatcher.h
Normal file
124
gomspace/libgscsp/include/gs/csp/service_dispatcher.h
Normal file
@ -0,0 +1,124 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_SERVICE_DISPATCHER_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_SERVICE_DISPATCHER_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP Service Dispatcher.
|
||||
|
||||
The dispatcher is a task/thread, listening on a configured number of ports and forwards the the incoming connection
|
||||
to a configured CSP service handler.
|
||||
The dispatcher touches a software watchdog for every handled connection.
|
||||
*/
|
||||
|
||||
#include <gs/csp/service_handler.h>
|
||||
#include <gs/csp/port.h>
|
||||
#include <gs/util/thread.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
CSP service dispatcher configuration.
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
Name of dispatcher.
|
||||
*/
|
||||
const char * name;
|
||||
/**
|
||||
Array of service handlers - index'ed by CSP port number.
|
||||
*/
|
||||
const gs_csp_service_handler_t * handler_array;
|
||||
/**
|
||||
Array size of \a handler_array.
|
||||
*/
|
||||
unsigned int handler_array_size;
|
||||
/**
|
||||
Bind to any unbound ports (CSP_ANY).
|
||||
Only one task/dispatcher can bind to any ports. This can be used to log unexpected incoming connections.
|
||||
*/
|
||||
bool bind_any;
|
||||
/**
|
||||
Disable watchdog.
|
||||
The watchdog is created with a fixed timeout of 20 seconds.
|
||||
*/
|
||||
bool disable_watchdog;
|
||||
/**
|
||||
CSP connection backlog.
|
||||
If 0 (zero), the backlog is set to 10.
|
||||
*/
|
||||
size_t listen_backlog;
|
||||
/**
|
||||
Callback after timeout or processsed connection.
|
||||
The return value is the next timeout in milli seconds.
|
||||
Return UINT32_MAX to use default timeout.
|
||||
*/
|
||||
unsigned int (*callback)(void);
|
||||
/**
|
||||
Socket options.
|
||||
*/
|
||||
uint32_t socket_options;
|
||||
} gs_csp_service_dispatcher_conf_t;
|
||||
|
||||
/**
|
||||
Basic CSP service handlers.
|
||||
|
||||
Can be used to configure handlers for all basic CSP services.
|
||||
*/
|
||||
#define GS_CSP_BASIC_SERVICE_HANDLERS \
|
||||
[GS_CSP_CMP] = gs_csp_cmp_service_handler, \
|
||||
[GS_CSP_PING] = gs_csp_ping_service_handler, \
|
||||
[GS_CSP_PS] = gs_csp_ps_service_handler, \
|
||||
[GS_CSP_MEMFREE] = gs_csp_mem_free_service_handler, \
|
||||
[GS_CSP_REBOOT] = gs_csp_reboot_service_handler, \
|
||||
[GS_CSP_BUF_FREE] = gs_csp_buf_free_service_handler, \
|
||||
[GS_CSP_UPTIME] = gs_csp_uptime_service_handler
|
||||
|
||||
/**
|
||||
Service dispatcher handle.
|
||||
@see gs_csp_service_dispatcher_create(), gs_csp_service_dispatcher_close()
|
||||
*/
|
||||
typedef struct gs_csp_service_dispatcher * gs_csp_service_dispatcher_t;
|
||||
|
||||
/**
|
||||
Create service dispatcher (task/thread).
|
||||
|
||||
@param[in] conf configuration - must remain valid as long as the dispatcher is running.
|
||||
@param[in] stack_size thread stack size.
|
||||
@param[in] priority thread priority.
|
||||
@param[out] return_handle created dispatcher - use NULL if not used.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_service_dispatcher_create(const gs_csp_service_dispatcher_conf_t * conf,
|
||||
size_t stack_size,
|
||||
gs_thread_priority_t priority,
|
||||
gs_csp_service_dispatcher_t * return_handle);
|
||||
|
||||
/**
|
||||
Wake up service dispatcher.
|
||||
|
||||
This will cause the disapther to wake up (from listing for new connections), and invoke the configured \a callback function,
|
||||
before listing for new connections.
|
||||
|
||||
@param[in] handle dispatcher.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_service_dispatcher_wake_up(gs_csp_service_dispatcher_t handle);
|
||||
|
||||
/**
|
||||
Destroy/close service dispatcher (for testing).
|
||||
|
||||
Signal stop to the dispatcher and waits for it to terminate (join).
|
||||
|
||||
@note Join is performed, which may hang forever if the dispatcher doesn't respond to the stop request.
|
||||
@param[in] handle dispatcher.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_service_dispatcher_destroy(gs_csp_service_dispatcher_t handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
102
gomspace/libgscsp/include/gs/csp/service_handler.h
Normal file
102
gomspace/libgscsp/include/gs/csp/service_handler.h
Normal file
@ -0,0 +1,102 @@
|
||||
#ifndef LIBGSCSP_INCLUDE_GS_CSP_SERVICE_HANDLER_H
|
||||
#define LIBGSCSP_INCLUDE_GS_CSP_SERVICE_HANDLER_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
CSP Service handler.
|
||||
*/
|
||||
|
||||
#include <csp/csp.h>
|
||||
#include <gs/util/error.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
CSP Service handler.
|
||||
|
||||
It is the handler's responsibility to process all pakcets on the connection and close the connection when done - even if a failure
|
||||
is returned.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
typedef gs_error_t (*gs_csp_service_handler_t)(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for CSP Management Protocol.
|
||||
|
||||
Invokes standard libcsp service handler.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_cmp_service_handler(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for ping.
|
||||
|
||||
Invokes standard libcsp service handler.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_ping_service_handler(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for getting process list.
|
||||
|
||||
Invokes standard libcsp service handler.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_ps_service_handler(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for getting memory free.
|
||||
|
||||
Invokes GomSpace handler, which doesn't use malloc() to determine \a free memory.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_mem_free_service_handler(csp_conn_t * conn);
|
||||
|
||||
|
||||
/**
|
||||
Service handler for reboot (reset) of node.
|
||||
|
||||
Invokes standard libcsp service handler.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_reboot_service_handler(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for getting free CSP buffers.
|
||||
|
||||
Invokes standard libcsp service handler.
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_buf_free_service_handler(csp_conn_t * conn);
|
||||
|
||||
/**
|
||||
Service handler for getting uptime (in seconds).
|
||||
|
||||
Invokes GomSpace handler (works on Linux).
|
||||
|
||||
@param[in] conn incoming connection.
|
||||
@return_gs_error_t
|
||||
*/
|
||||
gs_error_t gs_csp_uptime_service_handler(csp_conn_t * conn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user