#ifndef _COMM_H_
#define _COMM_H_
#ifndef _WIN32
#define __cdecl
#endif
#ifndef _LOBYTE
#if (defined(_SOCK1) || defined(_SOCK11))
#define _LOBYTE 1
#define _HIBYTE 1
#else
#define _LOBYTE 2
#define _HIBYTE 0
#endif
#endif
/* type */
#define TCPIP 1
#define SERIAL 2
/* flags */
#define COMMNOFLAG 0x00
#define COMMDELAY 0x01
#define COMMNOREPLY 0x10
/* msgtype */
#define COMMDATA 1
#define COMMACK 2
#define COMMNAK 3
#define COMMREGISTER 4
#define COMMUNREGISTER 5
define COMM_MSG_SIZE 1024
#define COMM_DATAP(cp) ((char *)((struct comm_header_t *)cp+1))
#define COMM_HEADER_SIZE sizeof(struct comm_header_t)
#define COMM_LEN_SIZE 4
#define COMM_UID_SIZE 5
#define COMM_SVC_SIZE 16
#define COMM_ERRCODE_SIZE 4
struct comm_header_t {
char len[COMM_LEN_SIZE]; /* data length: 순수 데이터 길이 */
char msgtype; /* Message type */
char uid[COMM_UID_SIZE]; /* Unique Value: ACK, NAK에서 사용*/
char svc[COMM_SVC_SIZE]; /* Destination Id. */
char errcode[COMM_ERRCODE_SIZE]; /* 미사용: 차후 사용할 예정 */
char flags; /* 위에서 지정한 flag중 하나 */
unsigned char crc; /* Check Byte */
};
typedef struct comm_header_t COMM_HEADER;
#if defined(__cplusplus)
extern "C" {
#endif
/* ------------------ function prototypes ------------------- */
int __cdecl ComOpen(int type, char *id, char *port);
int __cdecl ComDetach(void);
int __cdecl ComClose(void);
int __cdecl ComSend(char *svc, int msgtype, char *data, long len, long flags);
int __cdecl ComRecv(char *svc, int *msgtype, char *data, long *len, long flags);
#if defined (__cplusplus)
}
#endif
#endif /* _COMM_H_ */