]> rtime.felk.cvut.cz Git - sysless.git/commitdiff
Modified applications to be compliant against new OI API, MCS51
authorsmolik <smolik>
Thu, 12 Mar 2009 12:49:10 +0000 (12:49 +0000)
committersmolik <smolik>
Thu, 12 Mar 2009 12:49:10 +0000 (12:49 +0000)
arch/mcs51/generic/libs/ulan/Makefile.omk
arch/mcs51/generic/libs/ulan/ul_l_c2a.c
arch/mcs51/generic/libs/ulan/ul_utsubst.h [new file with mode: 0644]
arch/mcs51/generic/libs/ulan/ulan.h

index fe7a456252eb964fd36bf530eda6a34d87170cfd..cc3358ca1454d05bb2fd781bfbe6f043ce2e3c12 100644 (file)
@@ -11,7 +11,7 @@ default_CONFIG += ULAN_ID=$(ULAN_ID)
 
 LOCAL_CONFIG_H = ulan_config.h
 
-renamed_include_HEADERS = ulan.h->ul_lib/ulan.h 
+renamed_include_HEADERS = ulan.h->ul_lib/ulan.h ul_utsubst.h->ul_lib/ul_utsubst.h
 
 INCLUDES += -I . 
 
index 2387063830a93a5bea4251b32c25ff1a0daacefc..dd457c57dc0e7704c2156ed3c65fa3a29874ca57 100644 (file)
@@ -919,6 +919,21 @@ int ul_fd_wait(ul_fd_t ul_fd, int wait_sec)
   return 0;
 }
 
+int uloi_con_ulan_set_cmd_fd(uloi_coninfo_t *coninfo, int cmd,
+                             ul_fd_t rdfd, ul_fd_t wrfd)
+{
+  uloi_con_ulan_t *con_ulan = UL_CONTAINEROF(coninfo, uloi_con_ulan_t, con);
+  if(!cmd)
+    cmd=UL_CMD_OISV;
+  con_ulan->cmd=cmd;
+  con_ulan->sn=0;
+  con_ulan->bsn=0;
+  con_ulan->rdfd=rdfd;
+  con_ulan->wrfd=wrfd;
+  return 0;
+}
+
+
 #if 0
 int test_fnc(int i)
 {
diff --git a/arch/mcs51/generic/libs/ulan/ul_utsubst.h b/arch/mcs51/generic/libs/ulan/ul_utsubst.h
new file mode 100644 (file)
index 0000000..e89f1ff
--- /dev/null
@@ -0,0 +1,54 @@
+#ifndef _UL_UTSUBST_H
+#define _UL_UTSUBST_H
+
+#ifndef _SIZE_T_DEFINED
+#define _SIZE_T_DEFINED
+  typedef unsigned int size_t;
+#endif
+
+#ifndef UL_OFFSETOF
+/* offset of structure field */
+#define UL_OFFSETOF(_type,_member) \
+                ((size_t)&(((_type*)0)->_member))
+#endif /*UL_OFFSET*/
+
+#ifndef UL_CONTAINEROF
+#ifdef  __GNUC__
+#define UL_CONTAINEROF(_ptr, _type, _member) ({ \
+        const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \
+        (_type *)( (char *)__mptr - UL_OFFSETOF(_type,_member) );})
+#else /*!__GNUC__*/
+#define UL_CONTAINEROF(_ptr, _type, _member) \
+        ((_type *)( (char *)_ptr - UL_OFFSETOF(_type,_member)))
+#endif /*__GNUC__*/
+#endif /*UL_CONTAINEROF*/
+
+/* GNUC neat features */
+
+#ifdef __GNUC__
+#ifndef UL_ATTR_UNUSED
+#define UL_ATTR_PRINTF( format_idx, arg_idx )  \
+  __attribute__((format (printf, format_idx, arg_idx)))
+#define UL_ATTR_SCANF( format_idx, arg_idx )   \
+  __attribute__((format (scanf, format_idx, arg_idx)))
+#define UL_ATTR_FORMAT( arg_idx )              \
+  __attribute__((format_arg (arg_idx)))
+#define UL_ATTR_NORETURN                       \
+  __attribute__((noreturn))
+#define UL_ATTR_CONST                          \
+  __attribute__((const))
+#define        UL_ATTR_UNUSED                          \
+  __attribute__((unused))
+#endif  /*UL_ATTR_UNUSED*/
+#else  /* !__GNUC__ */
+#ifndef UL_ATTR_UNUSED
+#define UL_ATTR_PRINTF( format_idx, arg_idx )
+#define UL_ATTR_SCANF( format_idx, arg_idx )
+#define UL_ATTR_FORMAT( arg_idx )
+#define UL_ATTR_NORETURN
+#define UL_ATTR_CONST
+#define        UL_ATTR_UNUSED
+#endif  /*UL_ATTR_UNUSED*/
+#endif /* !__GNUC__ */
+
+#endif /*_UL_UTSUBST_H*/
index 3173d62eba9382ea1c4b700b6bcafe9fce60ebbe..d7fa961020870a2dff1f2bca26c5847bdd5e3f84 100644 (file)
@@ -5,6 +5,8 @@
 /*extern "C" {*/
 #endif
 
+#include <ul_lib/ul_utsubst.h>
+
 #ifndef uchar
  #define uchar unsigned char
 #endif
@@ -186,19 +188,26 @@ int ul_send_query_wait(ul_fd_t ul_fd,int dadr,int cmd,int flg,
 #define ULOI_ERRCLR 31 /* clear error status */
 
 typedef struct uloi_coninfo_t {
+  uchar error; /* error condition occurred */
+  uchar state; /* internal state */
+  int array_idx;/* array index */
+} uloi_coninfo_t;
+
+typedef struct uloi_con_ulan_t {
+  uloi_coninfo_t con;
   uchar adr;   /* address of target module */
   uchar cmd;   /* service/cmd number for uLOI on target */
   uchar bcmd;  /* service/cmd number for returned messages */
   uchar sn;    /* sequence counter */
   uchar bsn;   /* sequence counter of target module */
   uchar outflg;        /* flags used for outgoing messages */
-  ul_fd_t ul_fd;/* handle for ul_drv */
-  ul_fd_t ul_fd1;/* the auxiliary handle for ULOI direct reply */
+  ul_fd_t rdfd;/* handle for ul_drv */
+  ul_fd_t wrfd;/* the auxiliary handle for ULOI direct reply */
   int timeout; /* timeout */
-  uchar error; /* error condition occurred */
-  uchar state; /* internal state */
-  int array_idx;/* array index */
-} uloi_coninfo_t;
+} uloi_con_ulan_t;
+
+int uloi_con_ulan_set_cmd_fd(uloi_coninfo_t *coninfo, int cmd,
+                             ul_fd_t rdfd, ul_fd_t wrfd);
 
 /* definitions of basic uLan OI functions */