Commit 8236a630 authored by julien.delange's avatar julien.delange
Browse files

spacewire driver now works, need to adapt code generation for later use



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@588 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent b2b9cd44
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
#ifdef __PO_HI_NEED_DRIVER_SPACEWIRE_RASTA #ifdef __PO_HI_NEED_DRIVER_SPACEWIRE_RASTA
#include <activity.h>
#include <marshallers.h> #include <marshallers.h>
#include <deployment.h>
#include <po_hi_debug.h> #include <po_hi_debug.h>
#include <po_hi_transport.h> #include <po_hi_transport.h>
#include <po_hi_gqueue.h> #include <po_hi_gqueue.h>
#include <po_hi_messages.h> #include <po_hi_messages.h>
#include <po_hi_messages.h>
#include <drivers/po_hi_rtems_utils.h> #include <drivers/po_hi_rtems_utils.h>
#include <drivers/po_hi_driver_rasta_spacewire.h> #include <drivers/po_hi_driver_rasta_spacewire.h>
...@@ -53,11 +54,11 @@ void po_hi_c_driver_rasta_spacewire_init_pkt(__po_hi_c_driver_spacewire_pkt_hdr_ ...@@ -53,11 +54,11 @@ void po_hi_c_driver_rasta_spacewire_init_pkt(__po_hi_c_driver_spacewire_pkt_hdr_
void __po_hi_c_driver_spacewire_rasta_poller (void) void __po_hi_c_driver_spacewire_rasta_poller (void)
{ {
char buf[1024];
int len; int len;
int j; int j;
int n;
__po_hi_msg_t msg;
__po_hi_request_t request;
__DEBUGMSG ("[RASTA SPACEWIRE] Hello, i'm the poller !\n"); __DEBUGMSG ("[RASTA SPACEWIRE] Hello, i'm the poller !\n");
...@@ -69,20 +70,26 @@ void __po_hi_c_driver_spacewire_rasta_poller (void) ...@@ -69,20 +70,26 @@ void __po_hi_c_driver_spacewire_rasta_poller (void)
{ {
__DEBUGMSG ("[RASTA SPACEWIRE] Error while reading\n"); __DEBUGMSG ("[RASTA SPACEWIRE] Error while reading\n");
} }
/* skip first 2bytes (vchan and dummy) */
if ( (po_hi_c_driver_spacewire_rxpkt[0]==1) && (po_hi_c_driver_spacewire_rxpkt[1]==1) )
{
j=2; /* strip virtual channel protocol, non-ssspw device */
}
else else
{ {
j=0; /* hardware uses virtual channel protocol, hw already stripped it */
}
n = 0; /* skip first 2bytes (vchan and dummy) */
memcpy (buf, po_hi_c_driver_spacewire_rxpkt, 6); if ( (po_hi_c_driver_spacewire_rxpkt[0]==1) && (po_hi_c_driver_spacewire_rxpkt[1]==1) )
buf[6] = '\0'; {
j=2; /* strip virtual channel protocol, non-ssspw device */
}
else
{
j=0; /* hardware uses virtual channel protocol, hw already stripped it */
}
memcpy (&msg.content, &po_hi_c_driver_spacewire_rxpkt[j], __PO_HI_MESSAGES_MAX_SIZE + j);
__po_hi_unmarshall_request (&request, &msg);
printf ("[RASTA SPACEWIRE] Destination port: %d\n", request.port);
__po_hi_main_deliver (&request);
}
} }
void __po_hi_c_driver_spacewire_rasta_init (char* name, char* location) void __po_hi_c_driver_spacewire_rasta_init (char* name, char* location)
...@@ -133,17 +140,33 @@ int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, cons ...@@ -133,17 +140,33 @@ int __po_hi_c_driver_spacewire_rasta_sender (const __po_hi_task_id task_id, cons
{ {
int len = -1; int len = -1;
int i; int i;
__po_hi_local_port_t local_port;
__po_hi_request_t* request;
__po_hi_msg_t msg;
__po_hi_port_t destination_port;
local_port = __po_hi_get_local_port_from_global_port (port);
request = __po_hi_gqueue_get_most_recent_value (task_id, local_port);
destination_port = __po_hi_gqueue_get_destination (task_id, local_port, 0);
__po_hi_msg_reallocate (&msg);
request->port = destination_port;
__po_hi_marshall_request (request, &msg);
__DEBUGMSG ("[RASTA SPACEWIRE] Send packet ..."); __DEBUGMSG ("[RASTA SPACEWIRE] Send packet destination port = %d ...", destination_port);
for(i=0; i<1; i++) for(i=0; i<1; i++)
{ {
po_hi_c_driver_rasta_spacewire_init_pkt(&po_hi_c_driver_spacewire_txpkts[i]); po_hi_c_driver_rasta_spacewire_init_pkt(&po_hi_c_driver_spacewire_txpkts[i]);
} }
memcpy (po_hi_c_driver_spacewire_txpkts[0].data, "bonjour", 6); memcpy (po_hi_c_driver_spacewire_txpkts[0].data, &msg, __PO_HI_MESSAGES_MAX_SIZE);
len = write (po_hi_c_driver_rasta_spacewire_fd,po_hi_c_driver_spacewire_txpkts, __PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE + 4); len = write (po_hi_c_driver_rasta_spacewire_fd, po_hi_c_driver_spacewire_txpkts, __PO_HI_DRIVER_RASTA_SPACEWIRE_PKTSIZE + 4);
if (len < 0) if (len < 0)
{ {
......
Supports Markdown
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