⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test2_main.c

📁 与secs相关的hsms协议
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    *   (c) Copyright 2008 Philipp Skadorov (philipp_s@users.sourceforge.net) * *   This file is part of FREESECS. * *   FREESECS is free software: you can redistribute it and/or modify *   it under the terms of the GNU General Public License as published by *   the Free Software Foundation, either version 3 of the License, or *   (at your option) any later version. * *   FREESECS is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with FREESECS, see COPYING. *   If not, see <http://www.gnu.org/licenses/>. */#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <semaphore.h>#include "hsmsd_cli.h"#define MAX_DELTA 30struct{    unsigned short  stream;    unsigned short  function;    unsigned char   wbit;    unsigned int    sysbytes;    unsigned int    data_len;    unsigned char   data[2];   } s1f13_msg ={    .stream = 1,    .function = 13,    .wbit = 1,    .sysbytes = 0,    .data_len = 2,    .data = {0x1, 0x0}};struct{    unsigned short  stream;    unsigned short  function;    unsigned char   wbit;    unsigned int    sysbytes;    unsigned int    data_len;    unsigned char   data[343];   } s3f17_msg ={    .stream = 3,    .function = 17,    .wbit = 1,    .sysbytes = 1 << 24,    .data_len = 343,    .data = {   0x1, 0x5, 0xa9, 0x2, 0x0, 0x1, 0x41, 0x4, 0x42, 0x69, 0x6e, 0x64,                0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30,                0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0xa5, 0x1, 0x1, 0x1, 0x5, 0x1,                0x2, 0x41, 0x8, 0x43, 0x61, 0x70, 0x61, 0x63, 0x69, 0x74, 0x79, 0xa5,                0x1, 0x19, 0x1, 0x2, 0x41, 0xe, 0x53, 0x75, 0x62, 0x73, 0x74, 0x72,                0x61, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0xa5, 0x1, 0x0, 0x1,                0x2, 0x41, 0x5, 0x55, 0x73, 0x61, 0x67, 0x65, 0x41, 0x7, 0x50, 0x52,                0x4f, 0x44, 0x55, 0x43, 0x54, 0x1, 0x2, 0x41, 0x7, 0x53, 0x6c, 0x6f,                0x74, 0x4d, 0x61, 0x70, 0x1, 0x19, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1,                0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1, 0x2, 0x41,                0xa, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x4d, 0x61, 0x70, 0x1,                0x19, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0, 0x1, 0x2, 0x41, 0x0, 0x41,                0x0, 0x1, 0x2, 0x41, 0x0, 0x41, 0x0}};struct{    unsigned short  stream;    unsigned short  function;    unsigned char   wbit;    unsigned int    sysbytes;    unsigned int    data_len;    unsigned char   data[343];   } s16f15_msg ={    .stream = 16,    .function = 15,    .wbit = 1,    .sysbytes = 2 << 24,    .data_len = 260,    .data = {   0x1, 0x2, 0xa9, 0x2, 0x0, 0x0, 0x1, 0x3, 0x1, 0x6, 0x41, 0xe,                0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x5f,                0x47, 0x31, 0x21, 0x1, 0xd, 0x1, 0x1, 0x1, 0x2, 0x41, 0x10, 0x43,                0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30,                0x30, 0x30, 0x32, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1, 0x3, 0xa5, 0x1,                0x1, 0x41, 0x16, 0x48, 0x6f, 0x73, 0x74, 0x5c, 0x52, 0x65, 0x61, 0x64,                0x20, 0x61, 0x6e, 0x64, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65,                0x72, 0x1, 0x0, 0x25, 0x1, 0xff, 0x1, 0x0, 0x1, 0x6, 0x41, 0xe,                0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x5f,                0x47, 0x32, 0x21, 0x1, 0xd, 0x1, 0x1, 0x1, 0x2, 0x41, 0x10, 0x43,                0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30,                0x30, 0x30, 0x33, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1, 0x3, 0xa5, 0x1,                0x1, 0x41, 0x16, 0x48, 0x6f, 0x73, 0x74, 0x5c, 0x52, 0x65, 0x61, 0x64,                0x20, 0x61, 0x6e, 0x64, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65,                0x72, 0x1, 0x0, 0x25, 0x1, 0xff, 0x1, 0x0, 0x1, 0x6, 0x41, 0xe,                0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4a, 0x6f, 0x62, 0x5f,                0x47, 0x33, 0x21, 0x1, 0xd, 0x1, 0x1, 0x1, 0x2, 0x41, 0x10, 0x43,                0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30,                0x30, 0x30, 0x34, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1, 0x3, 0xa5, 0x1,                0x1, 0x41, 0x16, 0x48, 0x6f, 0x73, 0x74, 0x5c, 0x52, 0x65, 0x61, 0x64,                0x20, 0x61, 0x6e, 0x64, 0x20, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65,                0x72, 0x1, 0x0, 0x25, 0x1, 0xff, 0x1, 0x0 }};struct{    unsigned short  stream;    unsigned short  function;    unsigned char   wbit;    unsigned int    sysbytes;    unsigned int    data_len;    unsigned char   data[504];   } s14f9_msg ={    .stream = 14,    .function = 9,    .wbit = 1,    .sysbytes = 3 << 24,    .data_len = 504,    .data = {   0x1, 0x3, 0x41, 0x9, 0x45, 0x71, 0x75, 0x69, 0x70, 0x6d, 0x65, 0x6e,                0x74, 0x41, 0xa, 0x43, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x4a, 0x6f,                0x62, 0x1, 0x9, 0x1, 0x2, 0x41, 0x5, 0x4f, 0x62, 0x6a, 0x49, 0x44,                0x41, 0x7, 0x4d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x47, 0x1, 0x2, 0x41,                0x12, 0x44, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,                0x69, 0x6f, 0x6e, 0x50, 0x6c, 0x61, 0x6e, 0x41, 0x0, 0x1, 0x2, 0x41,                0x10, 0x43, 0x61, 0x72, 0x72, 0x69, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75,                0x74, 0x53, 0x70, 0x65, 0x63, 0x1, 0x4, 0x41, 0x10, 0x43, 0x41, 0x52,                0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,                0x31, 0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30,                0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x41, 0x10, 0x43, 0x41, 0x52,                0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,                0x33, 0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30,                0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x1, 0x2, 0x41, 0xb, 0x4d,                0x74, 0x72, 0x6c, 0x4f, 0x75, 0x74, 0x53, 0x70, 0x65, 0x63, 0x1, 0x3,                0x1, 0x2, 0x1, 0x2, 0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45,                0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x32, 0x1, 0x1,                0xa5, 0x1, 0x1, 0x1, 0x2, 0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49,                0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x1,                0x1, 0xa5, 0x1, 0x1, 0x1, 0x2, 0x1, 0x2, 0x41, 0x10, 0x43, 0x41,                0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,                0x30, 0x33, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1, 0x2, 0x41, 0x10, 0x43,                0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30, 0x30, 0x30, 0x30,                0x30, 0x30, 0x31, 0x1, 0x1, 0xa5, 0x1, 0x2, 0x1, 0x2, 0x1, 0x2,                0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30, 0x30,                0x30, 0x30, 0x30, 0x30, 0x30, 0x34, 0x1, 0x1, 0xa5, 0x1, 0x1, 0x1,                0x2, 0x41, 0x10, 0x43, 0x41, 0x52, 0x52, 0x49, 0x45, 0x52, 0x5f, 0x30,                0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x1, 0x1, 0xa5, 0x1, 0x3,                0x1, 0x2, 0x41, 0xf, 0x4d, 0x74, 0x72, 0x6c, 0x4f, 0x75, 0x74, 0x42,                0x79, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x1, 0x0, 0x1, 0x2, 0x41,                0xa, 0x50, 0x61, 0x75, 0x73, 0x65, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x1,                0x0, 0x1, 0x2, 0x41, 0x12, 0x50, 0x72, 0x6f, 0x63, 0x65, 0x73, 0x73,                0x69, 0x6e, 0x67, 0x43, 0x74, 0x72, 0x6c, 0x53, 0x70, 0x65, 0x63, 0x1,                0x3, 0x1, 0x3, 0x41, 0xe, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65,                0x72, 0x4a, 0x6f, 0x62, 0x5f, 0x47, 0x31, 0x1, 0x0, 0x1, 0x0, 0x1,                0x3, 0x41, 0xe, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4a,                0x6f, 0x62, 0x5f, 0x47, 0x32, 0x1, 0x0, 0x1, 0x0, 0x1, 0x3, 0x41,                0xe, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x4a, 0x6f, 0x62,                0x5f, 0x47, 0x33, 0x1, 0x0, 0x1, 0x0, 0x1, 0x2, 0x41, 0x10, 0x50,                0x72, 0x6f, 0x63, 0x65, 0x73, 0x73, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x4d,                0x67, 0x6d, 0x74, 0xa5, 0x1, 0x3, 0x1, 0x2, 0x41, 0xb, 0x53, 0x74,                0x61, 0x72, 0x74, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x25, 0x1, 0x0}};static FILE *fp = NULL;static char msg_flags[15][30];static struct{    sem_t sent_sem;    sem_t recv_sem;    sem_t err_sem;    unsigned long us_timeout;    unsigned int transaction_id;    hsmsd_msg_t* pmsg;}msg_dict[4] = {    {.us_timeout = 1, .transaction_id = 1 << 24, .pmsg = (hsmsd_msg_t*)&s1f13_msg},    {.us_timeout = 1, .transaction_id = 2 << 24, .pmsg = (hsmsd_msg_t*)&s3f17_msg},    {.us_timeout = 1, .transaction_id = 3 << 24, .pmsg = (hsmsd_msg_t*)&s16f15_msg},    {.us_timeout = 1, .transaction_id = 4 << 24, .pmsg = (hsmsd_msg_t*)&s14f9_msg}};static void prepare_dict(void);static void start_threads(void*);static void hsms_msg_handler(hsmsd_msg_t* msg);static void hsms_cnx_state_handler(hsmsd_cnx_state_t state);static void hsmsd_cnx_error_handler(int err);static void* thread_func0(void*);static void* thread_func1(void*);static void* thread_func2(void*);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -