/** * Communication channel management * * @author sjlee@suprema.co.kr * @see */ /* * Copyright (c) 2006 Suprema Co., Ltd. All Rights Reserved. * * This software is the confidential and proprietary information of * Suprema Co., Ltd. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Suprema. */ #define WIN32_LEAN_AND_MEAN #include #include #include #include "usb.h" #ifndef __BS_COMM_CHANNEL_H__ #define __BS_COMM_CHANNEL_H__ #define BS_DEFAULT_TIMEOUT 4000 #define BS_INPUT_TIMEOUT 10000 // channel type typedef enum { BS_NOT_USED = -1, BS_COMM_SOCKET = 0, BS_COMM_SOCKET_UDP = 1, BS_COMM_SERIAL = 2, BS_COMM_USB = 3, BS_COMM_SERIAL_485 = 4, BS_COMM_USB_MEMORY = 5, } BS_COMM_CHANNEL; typedef struct { SOCKET handle; WSAEVENT event; struct sockaddr_in biostationAddr; } BSSocketChannel; typedef struct { SOCKET handle; WSAEVENT event; struct sockaddr_in biostationAddr; } BSSocketUDPChannel; typedef struct { HANDLE handle; int baudrate; } BSSerialChannel; typedef struct { usb_dev_handle* handle; } BSUSBChannel; typedef struct { int driveIndex; } BSUSBMemoryChannel; typedef struct { BS_COMM_CHANNEL channelType; unsigned biostationID; int timeout; int inputTimeout; union { BSSocketChannel socketChannel; BSSocketUDPChannel socketUDPChannel; BSSerialChannel serialChannel; BSUSBChannel USBChannel; BSUSBMemoryChannel USBMemoryChannel; } channel; } BSCommChannel; #ifdef __cplusplus extern "C" { #endif int BS_GetAvailableHandle( BS_COMM_CHANNEL channelType ); void BS_ReleaseHandle( int handle ); BOOL BS_IsValidHandle( int handle, BS_COMM_CHANNEL channelType ); BSCommChannel* BS_GetCommChannel( int handle ); __declspec( dllexport ) int BS_ReadChannel( int handle, unsigned char* buf, int size, int timeout ); __declspec( dllexport ) int BS_WriteChannel( int handle, unsigned char* buf, int size, int timeout ); __declspec( dllexport ) int BS_CalculateChannelTimeout( int handle, int dataSize ); __declspec( dllexport ) int BS_ClearChannelReadBuffer( int handle ); __declspec( dllexport ) int BS_ClearChannelWriteBuffer( int handle ); #ifdef __cplusplus } #endif #endif