C# Demo,调用二维码模块的tx_windows_hidpos.dll扫码库,支持QR-M20 、QR-M10、QR-M30等二维码型号。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text;
using System.IO;
using System.IO.Ports;
using System.Threading;
using System.Management;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;
using AssemblyInfo;
namespace demo
{
class Program
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
/**解码数据回调函数**/
public delegate int tx_scanner_decode_data_cb_fun(byte ucCodeType, [MarshalAs(UnmanagedType.LPArray, SizeConst = 8192)]byte[] pBuf, int uiBufLen);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
/**通信接口连接状态0:断开,1:连接**/
public delegate void tx_scanner_comm_state_cb_fun(byte ucState);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_init();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_deinit();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_version(byte[] pVer, byte ucVerLen);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_decode_data_fun_register(tx_scanner_decode_data_cb_fun fDataFun);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_comm_state_fun_register(tx_scanner_comm_state_cb_fun fStateFun);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_version_info(byte[] pVerInfo, int iVerInfoLen);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_all_product_info(byte[] pProInfo, int iProInfoLen);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_decode_start();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_decode_stop();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_no_time_decode_start();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_trigger_mode(DB_TRIGGER_MODE_E eMode, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_trigger_mode();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_light_state(DB_LED_STATE_E eLedState, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_light_state();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_en_prefix(byte ucEnable, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_en_prefix();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_prefix(byte[] pData, byte ucDataLen, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_prefix(byte[] pData, byte ucDataLen);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_en_suffix(byte ucEnable, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_en_suffix();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_suffix(byte[] pData, byte ucDataLen, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_suffix(byte[] pData, byte ucDataLen);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_focus_state(DB_LED_STATE_E eLedState, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_focus_state();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_once_scan_time(int usTimeMs, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_once_scan_time();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_beep_volume(byte ucVol, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_beep_volume();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_heartbeat_type(DB_HEARTBEAT_TYPE_E eType, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_heartbeat_type();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_reset();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_scan_sw(byte ucEnable);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_cmd_setcode_sw(byte ucEnable, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_heartbeat_gap_time(uint uiTimeMs, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_heartbeat_gap_time();
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_set_heartbeat_wait_ack_time(uint uiTimeMs, byte isSaveParam);
[DllImport("..\\..\\..\\..\\..\\lib\\tx_windows_hidpos.dll", CallingConvention = CallingConvention.Cdecl)]
private extern static int tx_scanner_get_heartbeat_wait_ack_time();
static tx_scanner_decode_data_cb_fun s_fDecodeDataCb;
static tx_scanner_comm_state_cb_fun s_fCommStateCb;
static int s_uiDecodeCnt = 0;
static int tx_scanner_sdk_decode_data_cb(byte ucCodeType, byte[] pBuf, int uiBufLen)
{
byte[] ucData = new byte[uiBufLen];
string strData;
int i;
for(i=0; i<uiBufLen; i++)
{
ucData[i] = pBuf[i];
}
strData = System.Text.Encoding.Default.GetString(ucData, 0, uiBufLen);
Console.WriteLine("[{0}[{1}]len:{2},data:{3}", ++s_uiDecodeCnt, ucCodeType, uiBufLen, strData);
return 0;
}
static void tx_scanner_sdk_comm_state_cb_fun(byte ucState)
{
/**0:断开连接,1:连接**/
Console.WriteLine("scanner usb hidpos state:{0}", ucState);
}
static void tx_scanner_sdk_show_menu()
{
Console.Write("***************************MENU***************************\r\n");
Console.Write("a:start decode\r\n");
Console.Write("b:stop decode\r\n");
Console.Write("c:no time decode start\r\n");
Console.Write("d:get version info\r\n");
Console.Write("e:get product info\r\n");
Console.Write("f:set trigger mode; 0:LEVEL,1:PULSE,2:CONTINUOUS,3:AUTOSENS; save:0:no,1:yes.(eg:f01)\r\n");
Console.Write("g:get trigger mode\r\n");
Console.Write("h:set light LED; 0:working light,1:always off,2:always on; save:0:no,1:yes.(eg:h01)\r\n");
Console.Write("i:get light LED\r\n");
Console.Write("j:set focus state; 0:working light,1:always off,2:always on; save:0:no,1:yes.(eg:j01)\r\n");
Console.Write("k:get fucus state\r\n");
Console.Write("l:set en prefix; 0:OFF,1:ON; save:0:no,1:yes.(eg:l01)\r\n");
Console.Write("n:get en prefix\r\n");
Console.Write("o:set prefix; save:0:no,1:yes.(eg:o0)\r\n");
Console.Write("p:get prefix length\r\n");
Console.Write("r:set en suffix; 0:OFF,1:ON; save:0:no,1:yes.(eg:r01)\r\n");
Console.Write("s:get en suffix\r\n");
Console.Write("t:set suffix; save:0:no,1:yes.(eg:t0)\r\n");
Console.Write("u:get suffix length\r\n");
Console.Write("v:set once scan time(0-65536); save:0:no,1:yes.(eg:v01)\r\n");
Console.Write("w:get once scan time\r\n");
Console.Write("x:set beep volume(0-100); save:0:no,1:yes.(eg:x01)\r\n");
Console.Write("y:get beep volume\r\n");
Console.Write("z:set heartbeat type; 0:BAN,1:NO ACK,2:ACK; save:0:no,1:yes.(eg:z01)\r\n");
Console.Write("0:get heartbeat type\r\n");
Console.Write("1:set heartbeat gap time(0-2147483648); save:0:no,1:yes.(eg:101)\r\n");
Console.Write("2:get heartbeat gap time\r\n");
Console.Write("3:set heartbeat wait ack time(0-2147483648); save:0:no,1:yes.(eg:301)\r\n");
Console.Write("4:get heartbeat wait ack time\r\n");
Console.Write("5:reset\r\n");
Console.Write("6:set scan sw; 0:unable,1:able\r\n");
Console.Write("7:set setcode sw; 0:unable,1:able; save:0:no,1:yes.(eg:71)\r\n");
Console.Write("?/m:more menu\r\n");
Console.Write("q:quit\r\n");
Console.Write("******************************************************\r\n");
}
static void Main(string[] args)
{
int iRet;
byte[] ucVer = new byte[128];
byte[] ucVerInfo = new byte[128];
byte[] ucProInfo = new byte[512];
byte[] cTemp = new byte[128];
string strTemp = null;
byte ucTemp1;
byte ucTemp2;
uint uiTemp3;
char cFristChar;
char cSecondChar;
string cInput;
byte uiLen = 0;
iRet = tx_scanner_get_version(ucVer, (byte)ucVer.Length);
if(iRet > 0)
strTemp = System.Text.Encoding.Default.GetString(ucVer, 0, iRet);
Console.WriteLine("windows c# usb hidpos demo ver:{0}", strTemp);
/**注册解码数据回调函数**/
s_fDecodeDataCb = tx_scanner_sdk_decode_data_cb;
tx_scanner_decode_data_fun_register(s_fDecodeDataCb);
/**注册设备连接状态回调函数**/
s_fCommStateCb = tx_scanner_sdk_comm_state_cb_fun;
tx_scanner_comm_state_fun_register(s_fCommStateCb);
/**初始化**/
tx_scanner_init();
Console.Write("******************************************************\r\n");
Console.Write("a:start decode\r\n");
Console.Write("b:stop decode\r\n");
Console.Write("c:no time decode start\r\n");
Console.Write("d:get version info\r\n");
Console.Write("e:get product info\r\n");
Console.Write("f:set trigger mode; 0:LEVEL,1:PULSE,2:CONTINUOUS,3:AUTOSENS; save:0:no,1:yes.(eg:f01)\r\n");
Console.Write("g:get trigger mode\r\n");
Console.Write("h:set light LED; 0:working light,1:always off,2:always on; save:0:no,1:yes.(eg:h01)\r\n");
Console.Write("i:get light LED\r\n");
Console.Write("?/m:more menu\r\n");
Console.Write("q:quit\r\n");
Console.Write("******************************************************\r\n");
while(true)
{
/**switch(Console.ReadLine())这种方式需要点击回车,有的功能操作方式和C++的不一样,如C++下h01+回车,C#下h+回车+01**/
switch(Console.ReadKey().KeyChar)
{
case 'A':
case 'a':
Console.ReadLine();/**吸收回车符**/
iRet = tx_scanner_decode_start();
if (iRet < 0)
Console.Write("tx_scanner_decode_start fail!!!\r\n");
else
Console.Write("start\r\n");
break;
case 'B':
case 'b':
Console.ReadLine();
iRet = tx_scanner_decode_stop();
if (iRet < 0)
Console.Write("tx_scanner_decode_stop fail!!!\r\n");
else
Console.Write("stop\r\n");
break;
case 'C':
case 'c':
Console.ReadLine();
iRet = tx_scanner_no_time_decode_start();
if (iRet < 0)
Console.Write("tx_scanner_no_time_decode_start fail!!!\r\n");
else
Console.Write("no time start\r\n");
break;
case 'D':
case 'd':
Console.ReadLine();
iRet = tx_scanner_get_version_info(ucVerInfo, ucVerInfo.Length);
if (iRet < 0)
{
Console.Write("tx_scanner_get_version_info fail!!!\r\n");
}
else
{
strTemp = System.Text.Encoding.Default.GetString(ucVerInfo, 0, iRet);
Console.Write("{0}\r\n", strTemp);
}
break;
case 'E':
case 'e':
Console.ReadLine();
iRet = tx_scanner_get_all_product_info(ucProInfo, ucProInfo.Length);
if (iRet < 0)
{
Console.Write("tx_scanner_get_all_product_info fail!!!\r\n");
}
else
{
strTemp = System.Text.Encoding.Default.GetString(ucProInfo, 0, iRet);
Console.Write("{0}\r\n", strTemp);
}
break;
case 'f':
case 'F':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_trigger_mode((DB_TRIGGER_MODE_E)ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_trigger_mode fail!!!\r\n");
}
break;
case 'g':
case 'G':
Console.ReadLine();
iRet = tx_scanner_get_trigger_mode();
Console.Write("tx_scanner_get_trigger_mode:{0}\r\n", iRet);
break;
case 'h':
case 'H':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_light_state((DB_LED_STATE_E)ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("ts_scanner_set_light_state fail!!!\r\n");
}
break;
case 'i':
case 'I':
Console.ReadLine();
iRet = tx_scanner_get_light_state();
Console.Write("ts_scanner_get_light_state:{0}\r\n", iRet);
break;
case 'j':
case 'J':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_focus_state((DB_LED_STATE_E)ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_focus_state fail!!!\r\n");
}
break;
case 'k':
case 'K':
cInput = Console.ReadLine();
iRet = tx_scanner_get_focus_state();
Console.Write("tx_scanner_set_focus_state:{0}\r\n", iRet);
break;
case 'l':
case 'L':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_en_prefix(ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_prefix_state fail!!!\r\n");
}
break;
case 'n':
case 'N':
Console.ReadLine();
iRet = tx_scanner_get_en_prefix();
Console.Write("tx_scanner_get_en_prefix:{0}\r\n", iRet);
break;
case 'o':
case 'O':
{
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
Console.Write("{0}\r\n", ucTemp1);
string str = "ABC";
byte[] ucArr = Encoding.ASCII.GetBytes(str);
uiLen = (byte)str.Length;
iRet = tx_scanner_set_prefix(ucArr, uiLen, ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_set_prefix fail!!!\r\n");
}
break;
}
case 'p':
case 'P':
Console.ReadLine();
Array.Clear(cTemp, 0, cTemp.Length);
iRet = tx_scanner_get_prefix(cTemp, uiLen);
Console.Write("tx_scanner_get_prefix:{0}\r\n", iRet);
break;
case 'r':
case 'R':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_en_suffix(ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_en_suffix fail!!!\r\n");
}
break;
case 's':
case 'S':
Console.ReadLine();
iRet = tx_scanner_get_en_suffix();
Console.Write("tx_scanner_get_en_suffix:{0}\r\n", iRet);
break;
case 't':
case 'T':
{
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
Console.Write("{0}\r\n", ucTemp1);
string str = "CBA";
byte[] ucArr = Encoding.ASCII.GetBytes(str);
uiLen = (byte)str.Length;
iRet = tx_scanner_set_suffix(ucArr, uiLen, ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_set_suffix fail!!!\r\n");
}
break;
}
case 'u':
case 'U':
Console.ReadLine();
Array.Clear(cTemp, 0, cTemp.Length);
iRet = tx_scanner_get_suffix(cTemp, uiLen);
Console.Write("tx_scanner_get_suffix:{0}\r\n", iRet);
break;
case 'v':
case 'V':
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
uiTemp3 = uint.Parse(cInput);
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
Console.Write("{0},{1}\r\n", uiTemp3, ucTemp1);
iRet = tx_scanner_set_once_scan_time((ushort)uiTemp3, ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_set_suffix_state fail!!!\r\n");
}
}
break;
case 'w':
case 'W':
Console.ReadLine();
iRet = tx_scanner_get_once_scan_time();
Console.Write("tx_scanner_get_once_scan_time:{0}\r\n", iRet);
break;
case 'x':
case 'X':
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
ucTemp1 = byte.Parse(cInput);
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp2 = byte.Parse(cFristChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_beep_volume(ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_beep_volume fail!!!\r\n");
}
}
break;
case 'y':
case 'Y':
Console.ReadLine();
iRet = tx_scanner_get_beep_volume();
Console.Write("tx_scanner_get_beep_volume:{0}\r\n", iRet);
break;
case 'z':
case 'Z':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_set_heartbeat_type((DB_HEARTBEAT_TYPE_E)ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_set_heartbeat_type fail!!!\r\n");
}
break;
case '0':
Console.ReadLine();
iRet = tx_scanner_get_heartbeat_type();
Console.Write("tx_scanner_get_heartbeat_type:{0}\r\n", iRet);
break;
case '1':
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
uiTemp3 = uint.Parse(cInput);
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
iRet = tx_scanner_set_heartbeat_gap_time(uiTemp3, ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_set_heartbeat_gap_time fail!!!\r\n");
}
}
break;
case '2':
Console.ReadLine();
iRet = tx_scanner_get_heartbeat_gap_time();
Console.Write("tx_scanner_get_heartbeat_gap_time:{0}\r\n", iRet);
break;
case '3':
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
uiTemp3 = uint.Parse(cInput);
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
iRet = tx_scanner_set_heartbeat_wait_ack_time(uiTemp3, ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_set_heartbeat_wait_ack_time fail!!!\r\n");
}
}
break;
case '4':
Console.ReadLine();
iRet = tx_scanner_get_heartbeat_wait_ack_time();
Console.Write("tx_scanner_get_heartbeat_wait_ack_time:{0}\r\n", iRet);
break;
case '5':
Console.ReadLine();
iRet = tx_scanner_reset();
if(iRet < 0)
Console.Write("tx_scanner_reset fail!!!\r\n");
else
Console.Write("reset\r\n");
break;
case '6':
cInput = Console.ReadLine();
if (cInput.Length < 1)
{
Console.WriteLine("Invalid input! Input length must be at least 1 characters.");
}
else
{
cFristChar = cInput[0];
ucTemp1 = byte.Parse(cFristChar.ToString());
Console.Write("{0}\r\n", ucTemp1);
iRet = tx_scanner_scan_sw(ucTemp1);
if (iRet < 0)
Console.Write("tx_scanner_scan_sw fail!!!\r\n");
}
break;
case '7':
cInput = Console.ReadLine();
if (cInput.Length < 2)
{
Console.WriteLine("Invalid input! Input length must be at least 2 characters.");
}
else
{
cFristChar = cInput[0];
cSecondChar = cInput[1];
ucTemp1 = byte.Parse(cFristChar.ToString());
ucTemp2 = byte.Parse(cSecondChar.ToString());
Console.Write("{0},{1}\r\n", ucTemp1, ucTemp2);
iRet = tx_scanner_cmd_setcode_sw(ucTemp1, ucTemp2);
if (iRet < 0)
Console.Write("tx_scanner_cmd_setcode_sw fail!!!\r\n");
}
break;
case 'm':
case 'M':
case '?':
cInput = Console.ReadLine();
tx_scanner_sdk_show_menu();
break;
case 'q':
case 'Q':
cInput = Console.ReadLine();
Console.Write("quit\r\n");
return;
default:
break;
}
}
}
}
}