|
|
@ -1,4 +1,5 @@
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using FJ500Comm;
|
|
|
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
@ -37,13 +38,17 @@ namespace SlnMesnac.Common
|
|
|
|
public delegate void PushCode(string code);
|
|
|
|
public delegate void PushCode(string code);
|
|
|
|
public static event PushCode PushCodeEvent;
|
|
|
|
public static event PushCode PushCodeEvent;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private FJ500SP fj500sF = new FJ500SP();
|
|
|
|
|
|
|
|
|
|
|
|
//初始化串口并启动接收数据
|
|
|
|
//初始化串口并启动接收数据
|
|
|
|
public void InstanceSerialPort()
|
|
|
|
public void InstanceSerialPort()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
string[] data1 = new string[] { "123" };
|
|
|
|
|
|
|
|
// string[] data = new string[] { "202408101111" };
|
|
|
|
|
|
|
|
string aaa = fj500sF.SendData(data1, 1);
|
|
|
|
|
|
|
|
|
|
|
|
//端口名 注:因为使用的是USB转RS232 所以去设备管理器中查看一下虚拟com口的名字
|
|
|
|
//端口名 注:因为使用的是USB转RS232 所以去设备管理器中查看一下虚拟com口的名字
|
|
|
|
serialPort.PortName = "COM1";// portName;
|
|
|
|
serialPort.PortName = "COM1";// portName;
|
|
|
|
//波特率 霍尼威尔扫码枪115200,普通9600
|
|
|
|
//波特率 霍尼威尔扫码枪115200,普通9600
|
|
|
@ -102,6 +107,12 @@ namespace SlnMesnac.Common
|
|
|
|
/// <param name="data"></param>
|
|
|
|
/// <param name="data"></param>
|
|
|
|
public void SendData(string data)
|
|
|
|
public void SendData(string data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
string[] data1 = new string[] { "123" };
|
|
|
|
|
|
|
|
// string[] data = new string[] { "202408101111" };
|
|
|
|
|
|
|
|
fj500sF.SendData( data1, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
byte[] buffer = GetBytesByCommand(data);
|
|
|
|
byte[] buffer = GetBytesByCommand(data);
|
|
|
|
serialPort.Write(buffer, 0, buffer.Length);
|
|
|
|
serialPort.Write(buffer, 0, buffer.Length);
|
|
|
|
|
|
|
|
|
|
|
|