Commit 69b29e67 authored by julien.delange's avatar julien.delange
Browse files

* drivers/po_hi_driver_rasta_serial.c

   drivers/po_hi_driver_serial_common.c
   drivers/po_hi_driver_leon_serial.c
   drivers/po_hi_driver_linux_serial.c
   - Adapt serial drivers to ASN.1 configuration policy
   - Work in Progress, has to be tested



git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@2053 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent d4b9662e
......@@ -20,6 +20,7 @@
#include <po_hi_transport.h>
#include <po_hi_gqueue.h>
#include <drivers/po_hi_driver_serial_common.h>
#include <drivers/configuration/serial.h>
/* po-hi-c related files */
#include <activity.h>
......@@ -125,14 +126,12 @@ void __po_hi_c_driver_serial_leon_poller (void)
void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init sender\n");
memset (devname, '\0', 16);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
return;
......@@ -144,15 +143,15 @@ void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
return;
}
po_hi_c_driver_leon_serial_fd_write = open (devname, O_WRONLY );
po_hi_c_driver_leon_serial_fd_write = open (serialconf->devname, O_WRONLY );
if (po_hi_c_driver_leon_serial_fd_write < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
__PO_HI_DEBUG_DEBUG ("[LEON SERIAL] Device %s successfully opened, fd=%d\n", __po_hi_get_device_naming (id), po_hi_c_driver_leon_serial_fd_write);
__PO_HI_DEBUG_DEBUG ("[LEON SERIAL] Device %s successfully opened, fd=%d\n", serialconf->devname, po_hi_c_driver_leon_serial_fd_write);
}
tcgetattr (po_hi_c_driver_leon_serial_fd_write, &oldtio); /* save current serial port settings */
......@@ -214,16 +213,16 @@ void __po_hi_c_driver_serial_leon_init_sender (__po_hi_device_id id)
defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)
void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init receiver\n");
memset (devname, '\0', 16);
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the configuration of the device !\n");
return;
}
......@@ -233,13 +232,11 @@ void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
return;
}
po_hi_c_driver_leon_serial_fd_read = open( __po_hi_get_device_naming (id), O_RDONLY | O_NOCTTY);
po_hi_c_driver_leon_serial_fd_read = open (serialconf->devname, O_RDONLY | O_NOCTTY);
if (po_hi_c_driver_leon_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
......@@ -307,14 +304,14 @@ void __po_hi_c_driver_serial_leon_init_receiver (__po_hi_device_id id)
void __po_hi_c_driver_serial_leon_init (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Init both sender and receiver\n");
memset (devname, '\0', 16);
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LEON SERIAL] Cannot get the name of the device !\n");
return;
......@@ -326,11 +323,11 @@ void __po_hi_c_driver_serial_leon_init (__po_hi_device_id id)
return;
}
po_hi_c_driver_leon_serial_fd_read = po_hi_c_driver_leon_serial_fd_write = open( __po_hi_get_device_naming (id), O_RDWR | O_NOCTTY | O_NONBLOCK);
po_hi_c_driver_leon_serial_fd_read = po_hi_c_driver_leon_serial_fd_write = open( serialconf->devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_leon_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LEON SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
......
......@@ -9,6 +9,7 @@
*/
#include <drivers/po_hi_driver_linux_serial.h>
#include <drivers/configuration/serial.h>
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
......@@ -122,24 +123,24 @@ void __po_hi_c_driver_serial_linux_poller (void)
void __po_hi_c_driver_serial_linux_init_sender (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init sender\n");
memset (devname, '\0', 16);
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the configuration of the device !\n");
return;
}
po_hi_c_driver_serial_fd_write = open (devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
po_hi_c_driver_serial_fd_write = open (serialconf->devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_serial_fd_write < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
......@@ -248,24 +249,24 @@ void __po_hi_c_driver_serial_linux_init_sender (__po_hi_device_id id)
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER)
void __po_hi_c_driver_serial_linux_init_receiver (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init receiver\n");
memset (devname, '\0', 16);
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
return;
}
po_hi_c_driver_serial_fd_read = open (devname, O_RDONLY | O_NOCTTY);
po_hi_c_driver_serial_fd_read = open (serialconf->devname, O_RDONLY | O_NOCTTY);
if (po_hi_c_driver_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
......@@ -357,24 +358,24 @@ void __po_hi_c_driver_serial_linux_init_receiver (__po_hi_device_id id)
void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
{
char devname[16];
struct termios oldtio,newtio;
memset (devname, '\0', 16);
struct termios oldtio,newtio;
__po_hi_c_serial_conf_t* serialconf;
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Init both sender and receiver\n");
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[LINUX SERIAL] Cannot get the name of the device !\n");
return;
}
po_hi_c_driver_serial_fd_read = po_hi_c_driver_serial_fd_write = open(devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
po_hi_c_driver_serial_fd_read = po_hi_c_driver_serial_fd_write = open(serialconf->devname, O_RDWR | O_NOCTTY | O_NONBLOCK);
if (po_hi_c_driver_serial_fd_read < 0)
{
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[LINUX SERIAL] Error while opening device %s\n", serialconf->devname);
}
else
{
......
......@@ -37,7 +37,7 @@
#include <apbuart_rasta.h>
/* Rasta includes from GAISLER drivers */
#define __PO_HI_DRIVER_SERIAL_RASTA_BAUDRATE 19200
#include <drivers/configuration/serial.h>
int po_hi_c_driver_rasta_serial_fd;
......@@ -95,29 +95,29 @@ void __po_hi_rasta_interrrupt_register(void *handler, int irqno, void *arg);
void __po_hi_c_driver_serial_rasta_init (__po_hi_device_id id)
{
char devname[16];
__po_hi_c_serial_conf_t* serialconf;
__po_hi_c_driver_rasta_common_init ();
memset (devname, '\0', 16);
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
if (! __po_hi_c_driver_serial_common_get_dev (id, devname))
if (serialconf == NULL)
{
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Cannot get the name of the device !\n");
return;
}
/* provide the spacewire driver with AMBA Plug&Play
* info so that it can find the GRSPW cores.
*/
__PO_HI_DEBUG_INFO ("[RASTA SERIAL] Initialization starts !\n");
po_hi_c_driver_rasta_serial_fd = open (devname, O_RDWR);
po_hi_c_driver_rasta_serial_fd = open (serialconf->devname, O_RDWR);
if (po_hi_c_driver_rasta_serial_fd < 0)
{
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s\n", devname);
__PO_HI_DEBUG_CRITICAL ("[RASTA SERIAL] Error while opening device %s\n", serialconf->devname);
}
__PO_HI_DEBUG_DEBUG ("[RASTA SERIAL] Device open, fd=%d\n", po_hi_c_driver_rasta_serial_fd);
......
......@@ -12,6 +12,7 @@
#include <deployment.h>
#include <drivers/po_hi_driver_serial_common.h>
#include <drivers/configuration/serial.h>
#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || \
......@@ -24,57 +25,34 @@
#include <po_hi_transport.h>
#include <po_hi_debug.h>
int __po_hi_c_driver_serial_common_get_dev (const __po_hi_device_id id, char* dev)
{
char* conf;
int tmp;
int n;
conf = __po_hi_get_device_naming (id);
n = sscanf (conf, "dev=%s speed=%d", dev, &tmp);
if (n >= 1)
{
__PO_HI_DEBUG_INFO ("Driver %d has device %s associated\n", id, dev);
return 1;
}
return 0;
}
int __po_hi_c_driver_serial_common_get_speed (const __po_hi_device_id id)
{
char* conf;
int n;
int speed;
char tmp[10];
char* conf;
int n;
int speed;
char tmp[10];
__po_hi_c_serial_conf_t* serialconf;
conf = __po_hi_get_device_naming (id);
n = sscanf (conf, "dev=%s speed=%d", tmp, &speed);
if (n != 2)
{
__PO_HI_DEBUG_INFO ("Default speed for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT;
}
serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
switch (speed)
switch (serialconf->speed)
{
case 115200:
case __po_hi_c_b115200:
__PO_HI_DEBUG_INFO ("Get speed 115200 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200;
break;
case 57600:
case __po_hi_c_b57600:
__PO_HI_DEBUG_INFO ("Get speed 57600 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600;
break;
case 38400:
case __po_hi_c_b38400:
__PO_HI_DEBUG_INFO ("Get speed 38400 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400;
break;
case 19200:
case __po_hi_c_b19200:
__PO_HI_DEBUG_INFO ("Get speed 19200 for device %d\n", id);
return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200;
break;
......
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