/** * Packet management routines * * @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. */ #ifndef __BS_PACKET_H__ #define __BS_PACKET_H__ #define WIN32_LEAN_AND_MEAN #include // // Constants // #define BS_PACKET_START_CODE "{{<<" #define BS_PACKET_END_CODE ">>}}" #define BS_PACKET_HEADER_LEN 32 #define BS_PACKET_TRAILER_LEN 8 #define BS_SINGLE_PACKET_LEN 40 #define BS_MAX_SEND_LEN (4*1024) #define BS_MAX_RECV_LEN (4*1024) #define BS_BROADCAST_ID 0 #define BS_MAX_DATA_LEN (512*1024) // // Byte position of packet components // #define BS_PACKET_START_CODE_POS 0 #define BS_PACKET_START_CODE_LEN 4 #define BS_PACKET_BIOSTATION_ID_POS 4 #define BS_PACKET_BIOSTATION_ID_LEN 4 #define BS_PACKET_RESERVED1_POS 8 #define BS_PACKET_RESERVED1_LEN 4 #define BS_PACKET_INDEX_POS 12 #define BS_PACKET_INDEX_LEN 2 #define BS_PACKET_TOTAL_NO_POS 14 #define BS_PACKET_TOTAL_NO_LEN 2 #define BS_PACKET_PAYLOAD_SIZE_POS 16 #define BS_PACKET_PAYLOAD_SIZE_LEN 4 #define BS_PACKET_COMMAND_POS 20 #define BS_PACKET_COMMAND_LEN 2 #define BS_PACKET_FLAG_POS 22 #define BS_PACKET_FLAG_LEN 2 #define BS_PACKET_RETURN_CODE_POS 22 #define BS_PACKET_RETURN_CODE_LEN 2 #define BS_PACKET_PARAM1_POS 24 #define BS_PACKET_PARAM1_LEN 4 #define BS_PACKET_PARAM2_POS 28 #define BS_PACKET_PARAM2_LEN 4 #define BS_TRAILER_CHECKSUM_POS 0 #define BS_TRAILER_CHECKSUM_LEN 4 #define BS_TRAILER_END_CODE_POS 4 #define BS_TRAILER_END_CODE_LEN 4 #ifdef __cplusplus extern "C" { #endif void BS_MakeSinglePacket( unsigned short command, unsigned id, unsigned short flag, unsigned param1, unsigned param2, unsigned char* packet ); void BS_MakeSinglePacketWithPayload( unsigned short command, unsigned id, unsigned short flag, unsigned param1, unsigned param2, unsigned char* payload, unsigned payloadSize, unsigned char* header, unsigned char* trailer ); void BS_MakePacket( unsigned short command, unsigned id, unsigned short packetIndex, unsigned short totalPacket, unsigned short flag, unsigned param1, unsigned param2, unsigned char* payload, unsigned payloadSize, unsigned char* header, unsigned char* trailer ); unsigned BS_CalculateChecksum( unsigned char* packet, int size ); unsigned short BS_GetUShortValue( unsigned char* packet, int pos ); unsigned BS_GetUIntValue( unsigned char* packet, int pos ); #ifdef __cplusplus } #endif #endif