ArduSat API
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Enumerations
Enumerator
Macros
Pages
nanosat_message.h
Go to the documentation of this file.
1
/*
2
* @file nanosat_message.h
3
* @version 1.0
4
* @name NanoSatisfi Inc.
5
*
6
* @section LICENSE
7
*
8
* see LICENSE and NOTICE files.
9
*
10
* @section DESCRIPTION
11
* Message passing schema between OnboardCommLayer (I2C wrapper) and Payload
12
* supervisor. This interface exposes system calls to user space and sensor
13
* access. The main interaction players are Payload Supervisor(assv) and
14
* experiment nodes.
15
*
16
* @todo Put examples here.
17
* @code Example
18
* @endcode
19
*/
20
#ifndef NANOSAT_MESSAGE_H
21
#define NANOSAT_MESSAGE_H
22
23
#include <inttypes.h>
24
25
#define NODE_COMM_MAX_I2C_BUFFER_SIZE 32
26
#define NODE_COMM_MAX_BUFFER_SIZE 24
27
#define NODE_COMM_MESSAGE_PREFIX 0xAB
28
29
/******************************************************************************
30
* message types
31
******************************************************************************/
32
enum
message_type
{
33
APPEND
,
//append to the experiment file
34
READ
,
//read a value from a sensor
35
SET
,
//set the value of sensor register
36
EXIT
,
//signal the end of an experiment instance
37
SENSOR_REG
,
//register the use of a sensor by a node
38
CAM
,
//camera message (to supervisor)
39
CLOCK
,
//clock message (to supervisor)
40
SUN
,
//sun message (to supervisor)
41
TELEMETRY
,
//telemetry request
42
CONTROL_PITCH
,
//change pitch
43
CONTROL_YAW
,
//change yaw
44
CONTROL_ROLL
//change roll
45
};
46
47
/******************************************************************************
48
* message put on wire
49
******************************************************************************/
50
typedef
struct
__attribute__
((packed)) {
51
uint8_t prefix;
52
uint8_t type;
53
uint8_t node_addr;
// Address of sender
54
uint8_t len;
55
uint8_t buf[
NODE_COMM_MAX_BUFFER_SIZE
];
56
uint16_t checksum;
57
}
nanosat_message_t
;
58
59
//-----------------------------------------------------------
60
// Encode a Fletcher checksum in the last 2 bytes of buffer
61
// @see http://en.wikipedia.org/wiki/Fletcher's_checksum
62
//-----------------------------------------------------------
63
inline
uint16_t
fletcher_encode
(uint8_t buffer[],
long
count );
64
65
//-------------------------------------------------------------
66
// Decode Fletcher Checksum. Returns zero if buffer error-free
67
// @see http://en.wikipedia.org/wiki/Fletcher's_checksum
68
//-------------------------------------------------------------
69
inline
long
fletcher_decode
(uint8_t buffer[],
long
count );
70
71
#endif
/* NANOSAT_MESSAGE_H */
ArduSatSDK-master
nanosat_message
nanosat_message.h
Generated on Fri Jul 26 2013 15:07:55 for ArduSat API by
1.8.3.1