|
|
|
@ -40,8 +40,8 @@ public class USBSerialPortHelper implements SerialInputOutputManager.Listener { |
|
|
|
private int deviceId = 60000; |
|
|
|
private int deviceId_test = 60000; |
|
|
|
private int portNum; |
|
|
|
private final int WRITE_WAIT_MILLIS = 500; |
|
|
|
private final int READ_WAIT_MILLIS = 100; |
|
|
|
private final int WRITE_WAIT_MILLIS = 50; |
|
|
|
private final int READ_WAIT_MILLIS = 50; |
|
|
|
private String PortNameContians = "SILICON";/**/ |
|
|
|
// private static String PortNameContians="FTD";
|
|
|
|
//private int baudRate = 115200;
|
|
|
|
@ -92,8 +92,8 @@ public class USBSerialPortHelper implements SerialInputOutputManager.Listener { |
|
|
|
UsbManager usbManager = (UsbManager) MainActivity.getSystemService(Context.USB_SERVICE); |
|
|
|
for (UsbDevice v : usbManager.getDeviceList().values()) { |
|
|
|
// status(v.getManufacturerName().toUpperCase());
|
|
|
|
|
|
|
|
if (v.getVendorId() == 6790) { |
|
|
|
// if (v.getVendorId() == 6790)
|
|
|
|
if (v.getVendorId() == 1027||v.getVendorId() == 6790) { |
|
|
|
device = v; |
|
|
|
break; |
|
|
|
} |
|
|
|
@ -236,20 +236,17 @@ public class USBSerialPortHelper implements SerialInputOutputManager.Listener { |
|
|
|
// MainActivity.mainBinding.message.setText(str);
|
|
|
|
} |
|
|
|
|
|
|
|
int Index = 0; |
|
|
|
|
|
|
|
|
|
|
|
private void decodeRceive(byte[] data) { |
|
|
|
try { |
|
|
|
|
|
|
|
MainActivity.USBSerialPortReceivedTimeCounter=0;//计算时间 归零
|
|
|
|
|
|
|
|
if (ModbusRtuSlaveService.processModbusRequest(data, data.length) == 0x03) { |
|
|
|
Index++; |
|
|
|
//Index=128;
|
|
|
|
//由于 System.currentTimeMillis() 会随着时间累加,所以不存在
|
|
|
|
|
|
|
|
|
|
|
|
MainActivity._toSendPV = MainActivity._toSendPV.toBuilder() |
|
|
|
.setTimeStamp(System.currentTimeMillis()) |
|
|
|
.build(); |
|
|
|
DataExchangeHelper.setModbusPVValues( MainActivity._toSendPV); |
|
|
|
} else if (ModbusRtuSlaveService.processModbusRequest(data, data.length) == 0x10) { |
|
|
|
BspIV.IV_struct_define iv = DataExchangeHelper.getIVByModbus(); |
|
|
|
|