Commit f8df1d45 authored by julien.delange's avatar julien.delange
Browse files

begin implementation of PUS protocol

also add some debug information for the transport layer



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@1133 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 14692c18
#ifndef __PO_HI_DRIVER_PUS_PACKET_H__
#define __PO_HI_DRIVER_PUS_PACKET_H__
/*
* This correspond to the definition of PUS packets.
* For more information about PUS, please refer
* to the ECSS standard ECSS-E-70-41A.
*/
#include <po_hi_types.h>
#define PO_HI_DRIVER_PUS_PACKET_VERSION 0
#define PO_HI_DRIVER_PUS_PACKET_TYPE_TM 0
#define PO_HI_DRIVER_PUS_PACKET_TYPE_TC 1
#define PO_HI_DRIVER_PUS_PACKET_SEQUENCE_FLAGS_FIRST 1
#define PO_HI_DRIVER_PUS_PACKET_SEQUENCE_FLAGS_CONTINUATION 0
#define PO_HI_DRIVER_PUS_PACKET_SEQUENCE_FLAGS_LAST 1<<1
#define PO_HI_DRIVER_PUS_PACKET_SEQUENCE_FLAGS_STANDALONE (1<<1)|1
#define PO_HI_DRIVER_PUS_PACKET_ACK_ACCEPTANCE 1
#define PO_HI_DRIVER_PUS_PACKET_ACK_EXECUTION_START 1<<1
#define PO_HI_DRIVER_PUS_PACKET_ACK_EXECUTION_PROGRESS 1<<2
#define PO_HI_DRIVER_PUS_PACKET_ACK_EXECUTION_COMPLETION 1<<3
typedef enum
{
__PO_HI_DRIVER_PUS_PACKET_ERROR_NO_ERROR = 0,
__PO_HI_DRIVER_PUS_PACKET_ERROR_VERSION = 1,
__PO_HI_DRIVER_PUS_PACKET_ERROR_FLAG = 2,
__PO_HI_DRIVER_PUS_PACKET_ERROR_DATA_CCSDS_FLAG = 3
}__po_hi_driver_pus_packet_error_t;
typedef enum
{
__PO_HI_DRIVER_PUS_SERVICE_VERIFICATION = 1,
__PO_HI_DRIVER_PUS_SERVICE_DEVICE_COMMAND = 2,
__PO_HI_DRIVER_PUS_SERVICE_HOUSEKEEPING = 3,
__PO_HI_DRIVER_PUS_SERVICE_PARAMETER_STATISTICS = 4,
__PO_HI_DRIVER_PUS_SERVICE_EVENT_REPORTING = 5,
__PO_HI_DRIVER_PUS_SERVICE_MEMORY_MGMT = 6,
__PO_HI_DRIVER_PUS_SERVICE_FUNCTION_MGMT = 8,
__PO_HI_DRIVER_PUS_SERVICE_TIME_MGMT = 9,
__PO_HI_DRIVER_PUS_SERVICE_SCHEDULING = 11,
__PO_HI_DRIVER_PUS_SERVICE_MONITORING = 12,
__PO_HI_DRIVER_PUS_SERVICE_DATA_TRANSFER = 13,
__PO_HI_DRIVER_PUS_SERVICE_FORWARDING = 14,
__PO_HI_DRIVER_PUS_SERVICE_STORAGE = 15,
__PO_HI_DRIVER_PUS_SERVICE_TEST = 17,
__PO_HI_DRIVER_PUS_SERVICE_OPERATIONS_PROCEDURE = 18,
__PO_HI_DRIVER_PUS_SERVICE_EVENT_ACTION = 19,
__PO_HI_DRIVER_PUS_SERVICE_UNUSED = 25
}__po_hi_driver_pus_service_t;
typedef struct
{
struct
{
unsigned version :3;
/* Version = 0, only one version at this time. */
unsigned type :1;
/* Type of the packet : TC or TM. */
unsigned flag :1;
/* Set to 1 if the packet has data, 0 otherwise */
/* TC packet have data, so TC packets must have */
/* this bit set to 1. */
unsigned apid :11;
/* Application-ID whichi is the destination of
* the packet. APID definition are mission-specific.
*/
} id;
struct
{
unsigned flags :2;
/*
* See maccro PO_HI_DRIVER_PUS_PACKET_SEQUENCE_FLAGS_FIRST
* for more information.
*/
unsigned count :14;
/*
* Used to identify uniquely each TC packet.
*/
} seq_control;
__po_hi_uint16_t length;
}__po_hi_driver_pus_packet_header_t;
typedef struct
{
struct
{
unsigned ccsds_secondary_flag :1;
/*
* Must be set to 0.
*/
unsigned pus_version_number :3;
/*
* TC packet PUS version number.
* Must be set to 1.
*/
unsigned ack :4;
/*
* Specify the acceptance or the status of a TC.
* See maccros PO_HI_DRIVER_PUS_PACKET_ACK_*
* for the possible values.
*/
__po_hi_uint8_t sid; /* Service type */
/*
* Values from 0 to 127 are PUS-related
* Values from 128 to 255 are mission specific.
*/
__po_hi_uint8_t ssid; /* Service subtype */
/*
* If 0 < sid < 127, values from 0 to 127 are PUS-specific
* and values from 128 to 255 are mission-specific.
* If 128 < sid < 255, values from 0 to 255 are mission-specific.
*/
char* source_id; /* Optional */
char* spare; /* Optional */
}header;
char* application_data;
char* spare;
__po_hi_uint16_t error_control;
}__po_hi_driver_pus_packet_data_t;
typedef struct
{
__po_hi_driver_pus_packet_header_t header;
__po_hi_driver_pus_packet_data_t data;
}__po_hi_driver_pus_packet_t;
void __po_hi_driver_pus_packet_init (__po_hi_driver_pus_packet_t* pkt);
#endif
#include <po_hi_types.h>
#include <drivers/po_hi_driver_pus_packet.h>
void __po_hi_driver_pus_packet_init (__po_hi_driver_pus_packet_t* pkt)
{
pkt.id.version = 0;
}
__po_hi_driver_pus_packet_error_t __po_hi_driver_pus_packet_check (__po_hi_driver_pus_packet_t* pkt)
{
if ((pkt.header.id.type == PO_HI_DRIVER_PUS_PACKET_TYPE_TC) && (pkt.header.id.flag == 0))
{
return __PO_HI_DRIVER_PUS_PACKET_ERROR_FLAG;
}
if (pkg.header.id.version != 0)
{
return __PO_HI_DRIVER_PUS_PACKET_ERROR_VERSION;
}
if (pkg.data.header.ccsds_secondary_flag != 0)
{
return __PO_HI_DRIVER_PUS_PACKET_ERROR_DATA_CCSDS_FLAG;
}
return __PO_HI_DRIVER_PUS_PACKET_ERROR_NO_ERROR;
}
......@@ -259,15 +259,27 @@ int __po_hi_gqueue_get_value( __po_hi_task_id id,
else
{
memcpy (request,
(void *)&__po_hi_gqueues[id][port]
+ ( __po_hi_gqueues_first[id][port]
+ __po_hi_gqueues_offsets[id][port] )
* sizeof (__po_hi_request_t),
(void *)&__po_hi_gqueues[id][port] + ( __po_hi_gqueues_first[id][port] + __po_hi_gqueues_offsets[id][port] )* sizeof (__po_hi_request_t),
sizeof (__po_hi_request_t));
}
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Task %d get a value on port %d\n", id, port);
__DEBUGMSG ("RECEIVED Value: |");
{
int s;
int i;
unsigned int* tmp;
tmp = (unsigned int*) &request->vars;
s = sizeof (request->vars);
for (i = 0 ; i < s ; i+=4)
{
printf("%x", *tmp);
tmp++;
fflush (stdout);
}
}
__DEBUGMSG ("|\n");
#endif
pthread_mutex_unlock (&__po_hi_gqueues_mutexes[id]);
......
......@@ -74,6 +74,25 @@ int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id, port, __po_hi_port_global_to_entity[port]);
#endif
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("SENT Value: |");
{
int s;
int i;
unsigned int* tmp;
tmp = (unsigned int*) &request->vars;
s = sizeof (request->vars);
for (i = 0 ; i < s ; i+=4)
{
printf("%x", *tmp);
tmp++;
fflush (stdout);
}
}
__DEBUGMSG ("|\n");
#endif
for (i=0 ; i < __po_hi_gqueue_get_destinations_number (id, local_port) ; i++)
{
destination_port = __po_hi_gqueue_get_destination (id, local_port, i);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment