po_hi_driver_serial_common.c 2.11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * This is a part of PolyORB-HI-C distribution, a minimal
 * middleware written for generated code from AADL models.
 * You should use it with the Ocarina toolsuite.
 *
 * For more informations, please visit http://ocarina.enst.fr
 *
 * Copyright (C) 2011, European Space Agency (ESA).
 */


#include <deployment.h>

#include <drivers/po_hi_driver_serial_common.h>
15
#include <drivers/configuration/serial.h>
16
17
18
19
20
21
22
23
24
25
26
27
28
29

#if defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_RECEIVER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LINUX_SENDER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_RASTA) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_SENDER) || \
    defined (__PO_HI_NEED_DRIVER_SERIAL_LEON_RECEIVER)

#include <po_hi_transport.h>
#include <po_hi_debug.h>

int __po_hi_c_driver_serial_common_get_speed (const __po_hi_device_id id)
{
30
31
32
33
34
   char*                      conf;
   int                        n;
   int                        speed;
   char                       tmp[10];
   __po_hi_c_serial_conf_t*   serialconf;
35
   
36
   serialconf = (__po_hi_c_serial_conf_t*)__po_hi_get_device_configuration (id);
37

38
   switch (serialconf->speed)
39
   {
40
      case __po_hi_c_b115200:
41
42
43
44
         __PO_HI_DEBUG_INFO ("Get speed 115200 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_115200;
         break;

45
      case __po_hi_c_b57600:
46
47
48
49
         __PO_HI_DEBUG_INFO ("Get speed 57600 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_57600;
         break;

50
      case __po_hi_c_b38400:
51
52
53
54
         __PO_HI_DEBUG_INFO ("Get speed 38400 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_38400;
         break;

55
      case __po_hi_c_b19200:
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
         __PO_HI_DEBUG_INFO ("Get speed 19200 for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_19200;
         break;

      default:
         __PO_HI_DEBUG_INFO ("Unknown speed for device %d\n", id);
         return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_UNKNWON;
         break;
   }

   return __PO_HI_DRIVER_SERIAL_COMMON_SPEED_DEFAULT;
}

#endif