- logger added
git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@95 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
@@ -1,12 +1,16 @@
|
|||||||
package ch.ntb.mcdp.usb;
|
package ch.ntb.mcdp.usb;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import ch.ntb.mcdp.utils.logger.LogUtil;
|
||||||
import ch.ntb.usb.USB;
|
import ch.ntb.usb.USB;
|
||||||
import ch.ntb.usb.USBException;
|
import ch.ntb.usb.USBException;
|
||||||
|
|
||||||
public class Dispatch {
|
public class Dispatch {
|
||||||
|
|
||||||
|
private static Logger logger = LogUtil.ch_ntb_mcdp_usb;
|
||||||
|
|
||||||
// Main Types
|
// Main Types
|
||||||
/**
|
/**
|
||||||
* general errors
|
* general errors
|
||||||
@@ -65,7 +69,7 @@ public class Dispatch {
|
|||||||
}
|
}
|
||||||
mainType = data[index++];
|
mainType = data[index++];
|
||||||
subtype = data[index++];
|
subtype = data[index++];
|
||||||
int dataLen = data[index++] * 0x100 + data[index++];
|
int dataLen = (data[index++] & 0xFF) * 0x100 + (data[index++] & 0xFF);
|
||||||
if (data[index + dataLen] != DataPacket.PACKET_END) {
|
if (data[index + dataLen] != DataPacket.PACKET_END) {
|
||||||
throw new DispatchException("PACKET_END or packetLen ("
|
throw new DispatchException("PACKET_END or packetLen ("
|
||||||
+ dataLen + " bytes) wrong");
|
+ dataLen + " bytes) wrong");
|
||||||
@@ -121,6 +125,7 @@ public class Dispatch {
|
|||||||
|
|
||||||
public static DataPacket readUART() throws USBException, DispatchException {
|
public static DataPacket readUART() throws USBException, DispatchException {
|
||||||
if (!uartData.isEmpty()) {
|
if (!uartData.isEmpty()) {
|
||||||
|
logger.info("buffer not empty");
|
||||||
return uartData.poll();
|
return uartData.poll();
|
||||||
}
|
}
|
||||||
int dataLength = USBDevice.read_UART(usbData, USB.MAX_DATA_SIZE);
|
int dataLength = USBDevice.read_UART(usbData, USB.MAX_DATA_SIZE);
|
||||||
|
|||||||
Reference in New Issue
Block a user