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

* interface between generated code and device driver works

 * rasta and linux can now communicate
 * still a bug after some periods
 * bugfix : generate the appropriate number of mutexes
   required by RTEMS (see. po_hi_common.h)
 * add a swap function to handle endianness issues (see po_hi_utils.[h|c])
 * need to debug to fix the remaining bug



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@579 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 08584665
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* For more informations, please visit http://ocarina.enst.fr * For more informations, please visit http://ocarina.enst.fr
* *
* Copyright (C) 2007-2008, GET-Telecom Paris. * Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
*/ */
#ifndef __PO_HI_COMMON_H__ #ifndef __PO_HI_COMMON_H__
...@@ -13,33 +14,6 @@ ...@@ -13,33 +14,6 @@
#include <deployment.h> #include <deployment.h>
/*
* Define some values that are dependant of the
* underlying executive.
*/
#if defined(POSIX)
#include <stdlib.h>
#include <stdio.h>
#define __PO_HI_MAIN_NAME main
#define __PO_HI_MAIN_TYPE int
#define __PO_HI_MAIN_ARGS int argc , char *argv[] , char **arge
#define __PO_HI_MAIN_RETURN EXIT_SUCCESS
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#elif defined(RTEMS_PURE)
#define __PO_HI_MAIN_NAME Init
#define __PO_HI_MAIN_TYPE rtems_task
#define __PO_HI_MAIN_ARGS rtems_task_argument argument
rtems_task Init (rtems_task_argument);
#define __PO_HI_MAIN_RETURN 0
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#elif defined(RTEMS_POSIX)
#define __PO_HI_MAIN_NAME POSIX_Init
#define __PO_HI_MAIN_TYPE int
#define __PO_HI_MAIN_ARGS
#define __PO_HI_MAIN_RETURN 0
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#endif
/* /*
* Configure RTEMS executive. * Configure RTEMS executive.
* We have to define the number of tasks inside the executive, * We have to define the number of tasks inside the executive,
...@@ -53,13 +27,21 @@ ...@@ -53,13 +27,21 @@
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER #define CONFIGURE_APPLICATION_NEEDS_NULL_DRIVER
#define CONFIGURE_MAXIMUM_POSIX_TIMERS 40
#define CONFIGURE_MAXIMUM_TIMERS 40
int POSIX_Init (); int POSIX_Init ();
#define CONFIGURE_MAXIMUM_POSIX_THREADS __PO_HI_NB_TASKS + 4 #define CONFIGURE_MAXIMUM_POSIX_THREADS __PO_HI_NB_TASKS + 4
#define CONFIGURE_MAXIMUM_TASKS 16 #define CONFIGURE_MAXIMUM_TASKS 16
#define CONFIGURE_EXTRA_TASK_STACKS (20 * RTEMS_MINIMUM_STACK_SIZE) #define CONFIGURE_EXTRA_TASK_STACKS (20 * RTEMS_MINIMUM_STACK_SIZE)
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES __PO_HI_NB_TASKS + 1 #ifdef __PO_HI_NB_PORTS
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES __PO_HI_NB_TASKS + 1 #define CONFIGURE_MAXIMUM_POSIX_MUTEXES __PO_HI_NB_TASKS + 2 + __PO_HI_NB_PORTS
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES __PO_HI_NB_TASKS + 2 + __PO_HI_NB_PORTS
#else
#define CONFIGURE_MAXIMUM_POSIX_MUTEXES __PO_HI_NB_TASKS + 2 + __PO_HI_NB_PORTS
#define CONFIGURE_MAXIMUM_POSIX_CONDITION_VARIABLES __PO_HI_NB_TASKS + 2 + __PO_HI_NB_PORTS
#endif
#define CONFIGURE_POSIX_INIT_THREAD_TABLE #define CONFIGURE_POSIX_INIT_THREAD_TABLE
#include <po_hi_rtemsconfig.h> #include <po_hi_rtemsconfig.h>
#include <rtems/confdefs.h> #include <rtems/confdefs.h>
......
...@@ -6,11 +6,41 @@ ...@@ -6,11 +6,41 @@
* For more informations, please visit http://ocarina.enst.fr * For more informations, please visit http://ocarina.enst.fr
* *
* Copyright (C) 2007-2008, GET-Telecom Paris. * Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
*/ */
#ifndef __PO_HI_TASK_H__ #ifndef __PO_HI_TASK_H__
#define __PO_HI_TASK_H__ #define __PO_HI_TASK_H__
/*
* Define some values that are dependant of the
* underlying executive.
*/
#if defined(POSIX)
#include <stdlib.h>
#include <stdio.h>
#define __PO_HI_MAIN_NAME main
#define __PO_HI_MAIN_TYPE int
#define __PO_HI_MAIN_ARGS int argc , char *argv[] , char **arge
#define __PO_HI_MAIN_RETURN EXIT_SUCCESS
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#elif defined(RTEMS_PURE)
#define __PO_HI_MAIN_NAME Init
#define __PO_HI_MAIN_TYPE rtems_task
#define __PO_HI_MAIN_ARGS rtems_task_argument argument
rtems_task Init (rtems_task_argument);
#define __PO_HI_MAIN_RETURN 0
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#elif defined(RTEMS_POSIX)
#define __PO_HI_MAIN_NAME POSIX_Init
#define __PO_HI_MAIN_TYPE int
#define __PO_HI_MAIN_ARGS
#define __PO_HI_MAIN_RETURN 0
#define __ERRORMSG(s, args...) fprintf(stderr, s, ##args)
#endif
#if defined(POSIX) || defined (RTEMS_POSIX) #if defined(POSIX) || defined (RTEMS_POSIX)
#include <semaphore.h> #include <semaphore.h>
#include <po_hi_time.h> #include <po_hi_time.h>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* For more informations, please visit http://ocarina.enst.fr * For more informations, please visit http://ocarina.enst.fr
* *
* Copyright (C) 2007-2009, GET-Telecom Paris. * Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
*/ */
#ifndef __PO_HI_UTILS_H__ #ifndef __PO_HI_UTILS_H__
...@@ -24,4 +25,7 @@ int __po_hi_simulate_wcet (__po_hi_time_t time1, __po_hi_time_t time2); ...@@ -24,4 +25,7 @@ int __po_hi_simulate_wcet (__po_hi_time_t time1, __po_hi_time_t time2);
* Take a rate as argument, returns the probability that we meet this rate. * Take a rate as argument, returns the probability that we meet this rate.
*/ */
int __po_hi_compute_miss (__po_hi_uint8_t rate); int __po_hi_compute_miss (__po_hi_uint8_t rate);
unsigned long __po_hi_swap_byte (unsigned long value);
#endif /* __PO_HI_UTILS_H__ */ #endif /* __PO_HI_UTILS_H__ */
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE B19200 #define __PO_HI_DRIVER_SERIAL_LINUX_BAUDRATE B19200
#include <po_hi_debug.h> #include <po_hi_debug.h>
#include <po_hi_utils.h>
#include <po_hi_messages.h> #include <po_hi_messages.h>
#include <po_hi_transport.h> #include <po_hi_transport.h>
/* po-hi-c related files */ /* po-hi-c related files */
...@@ -34,53 +35,38 @@ ...@@ -34,53 +35,38 @@
int po_hi_c_driver_serial_fd; int po_hi_c_driver_serial_fd;
unsigned long ByteSwap (unsigned long nLongNumber)
{
union u {unsigned long vi; unsigned char c[sizeof(unsigned long)];};
union v {unsigned long ni; unsigned char d[sizeof(unsigned long)];};
union u un;
union v vn;
un.vi = nLongNumber;
vn.d[0]=un.c[3];
vn.d[1]=un.c[2];
vn.d[2]=un.c[1];
vn.d[3]=un.c[0];
return (vn.ni);
}
void __po_hi_c_driver_serial_linux_poller (void) void __po_hi_c_driver_serial_linux_poller (void)
{ {
unsigned long* toto; unsigned long* swap_pointer;
unsigned long titi; unsigned long swap_value;
__po_hi_msg_t msg; __po_hi_msg_t msg;
__po_hi_request_t request; __po_hi_request_t request;
int n; int n;
int tmp;
__DEBUGMSG ("Hello, i'm the serial linux poller !\n"); __DEBUGMSG ("Hello, i'm the serial linux poller !\n");
n = read (po_hi_c_driver_serial_fd, &msg, __PO_HI_MESSAGES_MAX_SIZE); n = read (po_hi_c_driver_serial_fd, &(msg.content), __PO_HI_MESSAGES_MAX_SIZE);
__DEBUGMSG ("[LINUX SERIAL] read() returns %d\n", n);
msg.length = n; if (n == -1)
if (n > 0)
{ {
printf ("[LINUX SERIAL] Received: %s\n", msg.content); __DEBUGMSG("[LINUX SERIAL] Cannot read on socket !\n");
toto = (unsigned long*)&msg.content[0]; }
titi = *toto;
*toto = ByteSwap (titi);
toto = (unsigned long*)&msg.content[4];
titi = *toto;
*toto = ByteSwap (titi);
__DEBUGMSG ("[LINUX SERIAL] read() returns %d\n", n);
toto = (unsigned long*)&msg.content[8]; msg.length = n;
titi = *toto;
*toto = ByteSwap (titi);
__po_hi_unmarshall_request (&request, &msg); if (n > 0)
{
for (tmp = 0 ; tmp < n ; tmp += 4)
{
swap_pointer = (unsigned long*) &msg.content[tmp];
swap_value = *swap_pointer;
*swap_pointer = __po_hi_swap_byte (swap_value);
}
printf ("[LINUX SERIAL] Received: %s\n", msg.content);
__po_hi_unmarshall_request (&request, &msg); __po_hi_unmarshall_request (&request, &msg);
...@@ -102,6 +88,10 @@ void __po_hi_c_driver_serial_linux_init (void) ...@@ -102,6 +88,10 @@ void __po_hi_c_driver_serial_linux_init (void)
{ {
__DEBUGMSG ("[LINUX SERIAL] Error while opening device %s\n", __PO_HI_DRIVER_SERIAL_LINUX_DEVICE); __DEBUGMSG ("[LINUX SERIAL] Error while opening device %s\n", __PO_HI_DRIVER_SERIAL_LINUX_DEVICE);
} }
else
{
__DEBUGMSG ("[LINUX SERIAL] Device successfully opened, fd=%d\n", po_hi_c_driver_serial_fd);
}
tcgetattr (po_hi_c_driver_serial_fd, &oldtio); /* save current serial port settings */ tcgetattr (po_hi_c_driver_serial_fd, &oldtio); /* save current serial port settings */
bzero (&newtio, sizeof(newtio)); /* clear struct for new port settings */ bzero (&newtio, sizeof(newtio)); /* clear struct for new port settings */
...@@ -162,8 +152,15 @@ void __po_hi_c_driver_serial_linux_init (void) ...@@ -162,8 +152,15 @@ void __po_hi_c_driver_serial_linux_init (void)
/* /*
* clean the serial line and activate the settings for the port * clean the serial line and activate the settings for the port
*/ */
tcflush (po_hi_c_driver_serial_fd, TCIFLUSH); if (tcflush (po_hi_c_driver_serial_fd, TCIOFLUSH) == -1)
tcsetattr (po_hi_c_driver_serial_fd, TCSANOW, &newtio); {
__DEBUGMSG ("[LINUX SERIAL] Error in tcflush()\n");
}
if (tcsetattr (po_hi_c_driver_serial_fd, TCSANOW, &newtio) == -1)
{
__DEBUGMSG ("[LINUX SERIAL] Error in tcsetattr()\n");
}
__DEBUGMSG ("[LINUX SERIAL] End of init\n"); __DEBUGMSG ("[LINUX SERIAL] End of init\n");
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
/* included files from the generated code */ /* included files from the generated code */
#include <po_hi_config.h> #include <po_hi_config.h>
#include <po_hi_common.h>
#include <po_hi_returns.h> #include <po_hi_returns.h>
#include <po_hi_task.h> #include <po_hi_task.h>
#include <po_hi_debug.h> #include <po_hi_debug.h>
...@@ -35,6 +36,33 @@ void __po_hi_initialize_add_task () ...@@ -35,6 +36,33 @@ void __po_hi_initialize_add_task ()
int __po_hi_initialize () int __po_hi_initialize ()
{ {
/*
#include <sys/time.h>
struct timeval tv;
struct timezone tz;
tz.tz_dsttime = DST_USA;
tz.tz_minuteswest = 0;
tv.tv_sec = 10;
tv.tv_usec = 0;
settimeofday (&tv, &tz);
*/
#ifdef RTEMS_POSIX
#include <rtems/rtems/clock.h>
rtems_status_code status;
rtems_time_of_day time;
time.year = 1988;
time.month = 12;
time.day = 31;
time.hour = 9;
time.minute = 0;
time.second = 0;
time.ticks = 0;
status = rtems_clock_set( &time );
#endif
if (pthread_mutex_init (&mutex_init, NULL) != 0 ) if (pthread_mutex_init (&mutex_init, NULL) != 0 )
{ {
return (__PO_HI_ERROR_PTHREAD_MUTEX); return (__PO_HI_ERROR_PTHREAD_MUTEX);
......
...@@ -49,3 +49,20 @@ int __po_hi_compute_miss (__po_hi_uint8_t rate) ...@@ -49,3 +49,20 @@ int __po_hi_compute_miss (__po_hi_uint8_t rate)
return 1; return 1;
} }
unsigned long __po_hi_swap_byte (unsigned long value)
{
union u {unsigned long vi; unsigned char c[sizeof(unsigned long)];};
union v {unsigned long ni; unsigned char d[sizeof(unsigned long)];};
union u un;
union v vn;
un.vi = value;
vn.d[0]=un.c[3];
vn.d[1]=un.c[2];
vn.d[2]=un.c[1];
vn.d[3]=un.c[0];
return (vn.ni);
}
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