Kaynağa Gözat

Added driver and utils for linux and win

Giulio 4 yıl önce
ebeveyn
işleme
2a89b532e7
41 değiştirilmiş dosya ile 2200 ekleme ve 0 silme
  1. BIN
      pdf/Prolin2.X_User_Guide(V1.0.7).pdf
  2. BIN
      pdf/TermAssist.pdf
  3. 23 0
      utils/linux/Driver/Makefile
  4. 0 0
      utils/linux/Driver/Module.symvers
  5. 1 0
      utils/linux/Driver/modules.order
  6. 1326 0
      utils/linux/Driver/ttyPos.c
  7. 137 0
      utils/linux/Driver/ttyPos.h
  8. BIN
      utils/linux/Driver/ttyPos.ko
  9. 72 0
      utils/linux/Driver/ttyPos.mod.c
  10. BIN
      utils/linux/Driver/ttyPos.mod.o
  11. BIN
      utils/linux/Driver/ttyPos.o
  12. 299 0
      utils/linux/Driver/ttyTest.c
  13. BIN
      utils/linux/XCB/xcb
  14. BIN
      utils/linux/XCB/xcb_user_manual_v1.0.0_.pdf
  15. BIN
      utils/windows/posvcom_2.5.0.0/amd64/PosVcom.sys
  16. BIN
      utils/windows/posvcom_2.5.0.0/i386/PosVcom.sys
  17. BIN
      utils/windows/posvcom_2.5.0.0/posvcom.cat
  18. 98 0
      utils/windows/posvcom_2.5.0.0/posvcom.inf
  19. BIN
      utils/windows/posvcom_2.7.0.0/amd64/PosVcom.sys
  20. BIN
      utils/windows/posvcom_2.7.0.0/i386/PosVcom.sys
  21. BIN
      utils/windows/posvcom_2.7.0.0/posvcom.cat
  22. 150 0
      utils/windows/posvcom_2.7.0.0/posvcom.inf
  23. BIN
      utils/windows/term-assist-2.2/DuiLib.dll
  24. 8 0
      utils/windows/term-assist-2.2/Setting/setting.ini
  25. 3 0
      utils/windows/term-assist-2.2/Setting/sysdwld.ini
  26. BIN
      utils/windows/term-assist-2.2/TermAssist-2.2.exe
  27. BIN
      utils/windows/term-assist-2.2/libusb0.dll
  28. BIN
      utils/windows/term-assist-2.2/skin/TermAssistRes.skin
  29. 67 0
      utils/windows/term-assist-2.2/tools/devinfo.xml
  30. BIN
      utils/windows/term-assist-2.2/tools/xcb.exe
  31. BIN
      utils/windows/term-assist-3.0.7.4742/DuiLib.dll
  32. 10 0
      utils/windows/term-assist-3.0.7.4742/Setting/setting.ini
  33. BIN
      utils/windows/term-assist-3.0.7.4742/TermAssist.exe
  34. 6 0
      utils/windows/term-assist-3.0.7.4742/config.ini
  35. BIN
      utils/windows/term-assist-3.0.7.4742/libusb0.dll
  36. BIN
      utils/windows/term-assist-3.0.7.4742/skin/TermAssistRes2.3.skin
  37. BIN
      utils/windows/term-assist-3.0.7.4742/tools/7za.exe
  38. BIN
      utils/windows/term-assist-3.0.7.4742/tools/USBDriver.exe
  39. BIN
      utils/windows/term-assist-3.0.7.4742/tools/data/7zr.exe
  40. BIN
      utils/windows/term-assist-3.0.7.4742/tools/data/data.7z
  41. BIN
      utils/windows/term-assist-3.0.7.4742/tools/xcb.exe

BIN
pdf/Prolin2.X_User_Guide(V1.0.7).pdf


BIN
pdf/TermAssist.pdf


+ 23 - 0
utils/linux/Driver/Makefile

@@ -0,0 +1,23 @@
+
+KERNEL_VER:=$(shell uname -r)
+KERNEL_DIR:=/lib/modules/$(KERNEL_VER)/build
+INSTALL_DIR:=/lib/modules/$(KERNEL_VER)/ttyPos
+
+obj-m := ttyPos.o
+
+
+all:
+	$(MAKE) modules -C $(KERNEL_DIR) SUBDIRS=$(shell pwd)
+
+clean:
+	$(RM) *.o *.ko *.mod.* .*.cmd *~
+	$(RM) -r .tmp_versions
+
+install: all
+	install -D -m 644 ttyPos.ko $(INSTALL_DIR)/ttyPos.ko
+	/sbin/depmod -a
+uninstall:
+	modprobe -r ttyPos ; echo -n
+	$(RM) $(INSTALL_DIR)/ttyPos.ko
+	/sbin/depmod -a
+

+ 0 - 0
utils/linux/Driver/Module.symvers


+ 1 - 0
utils/linux/Driver/modules.order

@@ -0,0 +1 @@
+kernel//home/gabriel/cloudwalk/files/xcb-PAX/ttyPos_303_20141015/ttyPos.ko

+ 1326 - 0
utils/linux/Driver/ttyPos.c

@@ -0,0 +1,1326 @@
+#include "ttyPos.h"
+
+#define DRV_VERSION	"303"
+#define VERSION_DATE    "2014.10.13_01"
+#define MAX_RETRY_S	5
+#define DRV_NAME	"ttyPos"
+
+static struct tty_pos *pdx_table[POS_TTY_MINORS];
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+static struct tty_port	pos_port[POS_TTY_MINORS];
+#endif
+#endif
+
+static unsigned char ResetPipePort(struct tty_pos *dev)
+{
+	struct tty_pos *pdx = dev;
+	int retval;
+
+	retval = usb_clear_halt(pdx->udev, usb_sndbulkpipe(pdx->udev,
+	    pdx->bulk_out_epAddr));
+	if (retval) {
+		ERR("%s - ERROR CLEAR %X HALT = %d",
+		    __func__, pdx->bulk_out_epAddr, retval);
+		goto reset_port;
+	}
+
+	retval = usb_clear_halt(pdx->udev, usb_rcvbulkpipe(pdx->udev,
+	    pdx->bulk_in_epAddr));
+	if (retval) {
+		ERR("%s - ERROR CLEAR %X HALT = %d",
+		    __func__, pdx->bulk_in_epAddr, retval);
+		goto reset_port;
+	}
+
+	return 0;
+
+ reset_port:
+	retval = usb_reset_device(pdx->udev);
+	if (retval) {
+		ERR("%s - ERROR RESETTING DEVICE: %d", __func__, retval);
+	}
+
+	return retval;
+}
+
+static int VerifyChecksum(ST_BULK_IO *p_bio)
+{
+	unsigned char a, b;
+	int i, dn;
+
+	dn = p_bio->Len + 4;
+	a = 0;
+
+	for (i = 2; i < dn; i++) {
+		a ^= ((unsigned char *)p_bio)[i];
+	}
+
+	a ^= p_bio->SeqNo & 0x0f;
+	a ^= p_bio->ReqType & 0x0f;
+	b = (p_bio->SeqNo & 0xf0) + (p_bio->ReqType >> 4);
+	if (a != b)
+		return 1;
+
+	/* clear checksum field */
+	p_bio->SeqNo &= 0x0f;
+	p_bio->ReqType &= 0x0f;
+	return 0;
+}
+
+static void SetChecksum(ST_BULK_IO *p_bio)
+{
+	unsigned char a;
+	int i, dn;
+
+	dn = p_bio->Len + 4;
+	a = 0;
+
+	for (i = 2; i < dn; i++) {
+		a ^= ((unsigned char *)p_bio)[i];
+	}
+
+	a ^= p_bio->SeqNo & 0x0f;
+	a ^= p_bio->ReqType & 0x0f;
+
+	/* fill high 4 bits of checksum into high 4 bits of ID field */
+	p_bio->SeqNo = (p_bio->SeqNo & 0x0f) | (a & 0xf0);
+
+	/* fill low 4 bits of checksum into high 4 bits of REQ_TYPE field */
+	p_bio->ReqType |= (a << 4);
+}
+
+static void UrbCallBack(struct urb *urb)
+{
+	struct tty_pos *pdx;
+
+	pdx = (struct tty_pos *)urb->context;
+
+	atomic_set(&pdx->urb_done, 1);
+	wake_up(&pdx->urb_wait);
+}
+
+static int SendAndWaitUrb(struct tty_pos *dev)
+{
+	struct tty_pos *pdx = dev;
+	int retval;
+
+	atomic_set(&pdx->urb_done, 0);
+
+	/* send the data out the bulk port */
+	retval = usb_submit_urb(pdx->urb, /* GFP_KERNEL */ GFP_ATOMIC);
+	if (retval) {
+		ERR("%s - FAILED SUBMITTING WRITE URB: %d", __func__, retval);
+		retval = 1;
+		goto exit;
+	}
+	retval = wait_event_timeout(pdx->urb_wait,
+	    (atomic_read(&pdx->urb_done) == 1), pdx->timeout_jiffies);
+	if (retval == 0) {
+		/* INFO("URB TIMEOUT\n"); */
+
+		if (atomic_read(&pdx->urb_done) == 0) {	/* urb is not done */
+#if 0
+			usb_unlink_urb(pdx->urb);
+			printk(KERN_ALERT "usb_done: %d; %d\n",
+			    (atomic_read(&pdx->urb_done) == 1),
+			    /* pdx->urb_done, */ usb_unlink_urb(pdx->urb));
+#endif
+			usb_kill_urb(pdx->urb);
+#if 0
+			wait_event(pdx->urb_wait,
+			    (atomic_read(&pdx->urb_done) == 1));
+#endif
+		}
+#if 0
+		INFO("urb->status: %d, %d\n", pdx->urb->status,
+		    pdx->urb->actual_length);
+#endif
+		retval = 2;
+		goto exit;
+	}
+	else if (retval < 0) {
+		ERR("%s - WAIT FAILED: %d", __func__, retval);
+		retval = 3;
+		goto exit;
+	}
+	else {
+		retval = 0;
+#if 0
+		printk(KERN_INFO "Use jiffies: %d", pdx->timeout_jiffies -
+		    retval);
+#endif
+	}
+
+	if (pdx->urb->status) {
+		/* if (pdx->urb->status != -EREMOTEIO) */
+		{
+			ERR("%s - nonzero status received: %d", __func__,
+			    pdx->urb->status);
+            ERR("urb status:%d\n",pdx->urb->status);    
+			retval = 4;
+			goto exit;
+		}
+	}
+ exit:
+	return retval;
+}
+
+/* error codes: 11~29 */
+static int ProcessCommand(struct tty_pos *dev)
+{
+	struct tty_pos *pdx = dev;
+	int retval;
+
+	/* stage 1: send command pack */
+
+	SetChecksum((ST_BULK_IO *)pdx->BioPack);
+
+	if (pdx->urb == NULL)
+		return 18;
+
+	if (pdx->urb->status == -EINPROGRESS) {
+#if 0
+		ERR("URB IN PROGRESS\n");
+#endif
+		return 19;
+	}
+
+	usb_fill_bulk_urb(pdx->urb, pdx->udev,
+	    usb_sndbulkpipe(pdx->udev, pdx->bulk_out_epAddr),
+	    pdx->BioPack, pdx->BioPack->Len + 4, UrbCallBack, pdx);
+
+	retval = SendAndWaitUrb((struct tty_pos *)pdx);
+
+	if (retval != 0)
+		return retval + 10;
+
+	/* stage 2: receive answer pack */
+
+	/* clear pack flags */
+	pdx->BioPack->SeqNo = 0;
+	pdx->BioPack->ReqType = 0;
+	pdx->BioPack->Len = 0;
+	if (pdx->urb == NULL)
+		return 28;
+
+	usb_fill_bulk_urb(pdx->urb, pdx->udev,
+	    usb_rcvbulkpipe(pdx->udev, pdx->bulk_in_epAddr),
+	    pdx->BioPack, sizeof(*pdx->BioPack), UrbCallBack, pdx);
+
+	retval = SendAndWaitUrb((struct tty_pos *)pdx);
+	if (retval != 0)
+		return retval + 20;
+
+	if (VerifyChecksum((ST_BULK_IO *)pdx->BioPack)) {
+		unsigned int i;
+		/* unsigned char x; */
+
+		ERR("VERIFY CHECKSUM FAILED: %d\n", retval);
+		ERR("%X; %X; %X\n", pdx->BioPack->SeqNo,
+		    pdx->BioPack->ReqType, pdx->BioPack->Len);
+
+		for (i = 0; i < 508; i++) {
+			INFO("%X\n", pdx->BioPack->Data[i]);
+		}
+#if 0
+		for (i = 0, x = pdx->BioPack.Data[0];
+		    i < pdx->BioPack.Len; i++, x++) {
+			if (pdx->BioPack.Data[i] != x) {
+				printk(KERN_ALERT "%d: %X; %X\n", i - 1,
+				    pdx->BioPack.Data[i - 1], x - 1);
+				printk(KERN_ALERT "%d: %X; %X\n", i,
+				    pdx->BioPack.Data[i], x);
+				printk(KERN_ALERT "%d: %X; %X\n", i + 1,
+				    pdx->BioPack.Data[i + 1], x + 1);
+				printk(KERN_ALERT "%d: %X; %X\n", i + 2,
+				    pdx->BioPack.Data[i + 2], x + 2);
+				printk(KERN_ALERT "%d: %X; %X\n", i + 3,
+				    pdx->BioPack.Data[i + 3], x + 3);
+				break;
+			}
+		}
+#endif
+		return 29;
+	}
+
+	return 0;
+}
+
+static void SleepMs(unsigned int nMs, struct tty_pos *dev)
+{
+#if 0
+	set_current_state(TASK_UNINTERRUPTIBLE);
+	schedule_timeout(nMs * HZ / 1000);
+#endif
+	struct tty_pos *pdx = dev;
+
+	unsigned int timeout = (nMs * HZ / 1000);
+	if (timeout < 1) {
+		timeout = 1;
+	}
+
+	wait_event_timeout(pdx->write_wait,
+	    (atomic_read(&pdx->write_flag) == 1), timeout);
+}
+
+static int ThreadCallBack(void *data)
+{
+	struct tty_pos *pdx = data;
+	unsigned char loops;
+	int retval;
+	unsigned int i, rlen, wlen;
+	struct tty_struct *tty;
+
+	retval = ResetPipePort(pdx);
+	if (retval != 0) {
+		retval = 1;
+		goto exit;
+	}
+
+	tty = pdx->tty;
+
+	while (pdx->ThreadState == THREAD_CREATED) {
+
+		/* get device buffer status */
+		for (loops = 0; (loops < MAX_RETRY_S) &&
+		    (pdx->ThreadState == THREAD_CREATED); loops++) {
+			/* building command pack */
+			pdx->SeqCount = (pdx->SeqCount + 1) & 0x0f;
+			pdx->BioPack->SeqNo = pdx->SeqCount;
+			pdx->BioPack->ReqType = STATUS_COMMAND;
+			pdx->BioPack->Len = 0;
+
+			retval = ProcessCommand((struct tty_pos *)pdx);
+			if (retval != 0) {
+				retval += 100;
+				goto loop_s_tail;
+			}
+
+			if (pdx->urb->actual_length != 20) {
+				retval = 130;
+				goto loop_s_tail;
+			}
+
+			if (pdx->BioPack->SeqNo != pdx->SeqCount) {
+				retval = 131;
+				goto loop_s_tail;
+			}
+
+			if (pdx->BioPack->ReqType != STATUS_COMMAND) {
+				retval = 132;
+				goto loop_s_tail;
+			}
+
+			memcpy(&pdx->BioDevState, pdx->BioPack->Data,
+			    sizeof(pdx->BioDevState));
+
+			if ((!pdx->BioDevState.TxLeft) &&
+			    IS_POOL_EMPTY(pdx->TxPool)) {
+				SleepMs(10, (struct tty_pos *)pdx);
+			}
+
+ loop_s_tail:
+			if (retval == 0)
+				break;
+			ERR("STATUS RETRY, loop: %d, err: %d, seq: %02X\n",
+			    loops, retval, pdx->SeqCount);
+			ResetPipePort(pdx);
+		}
+
+		if (retval != 0)
+			goto exit;
+
+ r_process:	/* read from usb device */
+
+		for (loops = 0; (loops < MAX_RETRY_S) &&
+		    (pdx->ThreadState == THREAD_CREATED); loops++) {
+			if (!pdx->BioDevState.TxLeft)
+				goto w_process;
+
+			rlen = pdx->BioDevState.TxLeft;
+
+			if (rlen > sizeof(pdx->BioPack->Data)) {
+				rlen = sizeof(pdx->BioPack->Data);
+			}
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+            rlen = tty_buffer_request_room(&pos_port[pdx->devIndex],rlen);
+#else
+			rlen = tty_buffer_request_room(tty, rlen);
+#endif
+#endif
+			if (!loops) {
+				pdx->SeqCount = (pdx->SeqCount + 1) & 0x0f;
+			}
+
+			pdx->BioPack->SeqNo = pdx->SeqCount;
+			pdx->BioPack->ReqType = READ_COMMAND;
+			pdx->BioPack->Len = 2;
+			/* in dlen required */
+			pdx->BioPack->Data[0] = (unsigned short)rlen & 0xff;
+			pdx->BioPack->Data[1] = (unsigned short)rlen >> 8;
+
+			retval = ProcessCommand((struct tty_pos *)pdx);
+			if (retval != 0) {
+				retval += 200;
+				goto loop_r_tail;
+			}
+
+			if (pdx->BioPack->SeqNo != pdx->SeqCount) {
+				retval = 231;
+				goto loop_r_tail;
+			}
+
+			if (pdx->BioPack->ReqType != READ_COMMAND) {
+				if ((pdx->BioPack->ReqType == STATUS_COMMAND) &&
+				    (pdx->BioPack->Len >=
+				    sizeof(pdx->BioDevState))) {
+					memcpy(&pdx->BioDevState,
+					    pdx->BioPack->Data,
+					    sizeof(pdx->BioDevState));
+					goto w_process;	/* no data to fetch */
+				}
+
+				retval = 232;
+				ERR("  %02X, ERROR req_type: %02X.\n",
+				    pdx->SeqCount, pdx->BioPack->ReqType);
+
+				goto loop_r_tail;
+			}
+
+			if (pdx->urb->actual_length <
+			    (int)pdx->BioPack->Len + 4) {
+				retval = 233;
+				goto loop_r_tail;
+			}
+
+			if (pdx->BioPack->Len > rlen) {
+				ERR("MORE DATA FETCHED THAN DECLARED, NEED: "
+				    "%d, RN: %d\n", rlen, pdx->BioPack->Len);
+				retval = 234;
+				goto exit;
+			}
+
+			rlen = pdx->BioPack->Len;
+#if 0
+			for (j = 0; j < rlen - 1; j++) {
+				if ((pdx->BioPack.Data[j] + 1 !=
+				    pdx->BioPack.Data[j + 1])
+				    && (pdx->BioPack.Data[j + 1] != 0)) {
+					inerr = 235;
+					goto exit;
+				}
+			}
+#endif
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+            tty_insert_flip_string(&pos_port[pdx->devIndex], pdx->BioPack->Data, rlen);
+			tty_flip_buffer_push(&pos_port[pdx->devIndex]);
+#else            
+			tty_insert_flip_string(tty, pdx->BioPack->Data, rlen);
+			tty_flip_buffer_push(tty);
+#endif
+#endif
+			pdx->BioDevState.TxLeft -= rlen;
+#if 0
+			printk(KERN_ALERT "%02X, RN: %d\n", pdx->SeqCount,
+			    rlen);
+#endif
+
+			if (pdx->BioDevState.TxLeft)
+				goto r_process;
+ loop_r_tail:
+			if (retval == 0)
+				break;
+
+			ERR("RX RETRY, loop: %d, err: %d, SEQ: %02X\n",
+			    loops, retval, pdx->SeqCount);
+
+			ResetPipePort(pdx);
+		}
+
+		if (retval)
+			goto exit;
+
+ w_process:	/* write to usb device */
+
+		wlen = GET_USING_POOL(pdx->TxPool);
+
+		if (wlen > sizeof(pdx->BioPack->Data)) {
+			wlen = sizeof(pdx->BioPack->Data);
+		}
+
+		if (wlen > pdx->BioDevState.RxLeft) {
+			wlen = pdx->BioDevState.RxLeft;
+		}
+
+		for (loops = 0; (loops < MAX_RETRY_S) &&
+		    (pdx->ThreadState == THREAD_CREATED); loops++) {
+			if (wlen == 0)
+				break;
+
+			if (!loops) {
+				pdx->SeqCount = (pdx->SeqCount + 1) & 0x0f;
+			}
+
+			pdx->BioPack->SeqNo = pdx->SeqCount;
+			pdx->BioPack->ReqType = WRITE_COMMAND;
+			pdx->BioPack->Len = (unsigned short)wlen;
+
+			for (i = 0; i < wlen; i++) {
+				pdx->BioPack->Data[i] =
+				    pdx->TxPool.Buffer[(pdx->TxPool.ReadPos +
+				    i) % POOL_SIZE];
+			}
+
+			retval = ProcessCommand((struct tty_pos *)pdx);
+			if (retval != 0) {
+				retval += 300;
+				goto loop_w_tail;
+			}
+
+			if (pdx->urb->actual_length != 20) {
+				retval = 330;
+				goto loop_w_tail;
+			}
+
+			if (pdx->BioPack->SeqNo != pdx->SeqCount) {
+				retval = 331;
+
+				ERR("***** Mismatched with SEQ: %02X, "
+				    "wlen: %d, loop: %d\n", pdx->SeqCount,
+				    wlen, loops);
+
+				ERR(" SEQ: %02X, type: %02X, dn: %d\n",
+				    pdx->BioPack->SeqNo, pdx->BioPack->ReqType,
+				    pdx->BioPack->Len);
+
+				for (i = 0; i < pdx->BioPack->Len; i++) {
+					INFO("%02X ", pdx->BioPack->Data[i]);
+				}
+
+				if (((pdx->BioPack->SeqNo + 1) % 16) ==
+				    pdx->SeqCount)
+					goto loop_w_tail;
+
+				goto exit;
+			}	/* mismatched seq_no */
+
+			if (pdx->BioPack->ReqType != STATUS_COMMAND) {
+				retval = 332;
+
+				ERR(" SEQ: %02X, type: %02X, dn: %d\n",
+				    pdx->BioPack->SeqNo, pdx->BioPack->ReqType,
+				    pdx->BioPack->Len);
+
+				for (i = 0; i < sizeof(pdx->BioPack->Data);
+				    i++) {
+					INFO("%02X ", pdx->BioPack->Data[i]);
+				}
+
+				INFO("\n");
+
+				goto exit;
+			}	/* mismatched req_type */
+#if 0
+			printk(KERN_ALERT "%02X, WN: %d\n", pdx->SeqCount,
+			    wlen);
+#endif
+			pdx->TxPool.ReadPos = (pdx->TxPool.ReadPos + wlen) %
+			    POOL_SIZE;
+
+			memcpy(&pdx->BioDevState, pdx->BioPack->Data,
+			    sizeof(pdx->BioDevState));
+
+			if (!IS_POOL_EMPTY(pdx->TxPool))
+				goto w_process;
+
+			atomic_set(&pdx->write_flag, 0);
+ loop_w_tail:
+			if (retval == 0)
+				break;
+
+			ERR("TX RETRY, loop: %d, err: %d, SEQ: %02X\n",
+			    loops, retval, pdx->SeqCount);
+
+			ResetPipePort(pdx);
+		}
+
+		if (retval)
+			goto exit;
+	}
+
+ exit:
+#if 0    
+	INFO("ThreadCallBack Exit\n");
+#endif
+	if (retval != 0) {
+		ERR("%02X, ERR: %d\n", pdx->SeqCount, retval);
+
+		ResetPipePort(pdx);
+	}
+
+	pdx->ThreadState = THREAD_STOPPED;
+	complete(&pdx->ThreadExit_completion);
+	do_exit(0);
+}
+
+static void pos_delete(struct kref *kref)
+{
+	struct tty_pos *pdx = to_pos_dev(kref);
+
+	if (pdx == NULL)
+		return;
+
+    if(pdx->devIndex >= POS_TTY_MINORS)
+		return;
+
+	if (pdx->tty) {
+		pdx->tty->driver_data = NULL;
+	}
+
+	pdx_table[pdx->devIndex] = NULL;
+	usb_free_urb(pdx->urb);
+	usb_put_dev(pdx->udev);
+	kfree(pdx->BioPack);
+	kfree(pdx);
+}
+
+static int pos_open(struct tty_struct *tty, struct file *filp)
+{
+	struct tty_pos *pdx;
+	
+    if(tty==NULL)return USB_ERR_MEM_SYSTEM;
+    if(tty->index >= POS_TTY_MINORS || tty->index<0)return USB_ERR_MEM_SYSTEM;
+    
+//    INFO("%s index:%d\n",__func__,tty->index);
+	pdx = pdx_table[tty->index];
+	if (pdx == NULL)
+		return USB_ERR_DEV_ABSENT;
+
+	if (THREAD_IS_RUNNING(pdx->ThreadState)) {
+		return USB_ERR_BUSY;
+	}
+
+	tty->driver_data = pdx;
+	pdx->tty = tty;
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    tty_port_tty_set(&pos_port[pdx->devIndex], tty);
+#endif
+#endif
+
+	kref_get(&pdx->kref);
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    reinit_completion(&pdx->ThreadExit_completion);
+#else
+	INIT_COMPLETION(pdx->ThreadExit_completion);
+#endif
+#endif
+	pdx->ThreadState = THREAD_CREATED;
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+{
+    struct task_struct *thread;
+    thread = kthread_run(ThreadCallBack,(struct tty_pos *)pdx,"ThreadCallBack");
+    if (IS_ERR(thread))
+    {
+		ERR("FAILED TO CREATE KERNEL THREAD!\n");
+		pdx->ThreadState = THREAD_INIT;
+		kref_put(&pdx->kref, pos_delete);
+		return USB_ERR_RC_SYSTEM;
+	}
+}
+#else
+{
+    pid_t pid;
+	pid = kernel_thread(ThreadCallBack, (struct tty_pos *)pdx,
+	    CLONE_FS | CLONE_FILES);
+	if (pid < 0) {
+		ERR("FAILED TO CREATE KERNEL THREAD!\n");
+		pdx->ThreadState = THREAD_INIT;
+		kref_put(&pdx->kref, pos_delete);
+		return USB_ERR_RC_SYSTEM;
+	}
+}
+#endif
+#endif
+
+	pdx->filp = filp;
+	return 0;
+}
+
+static void pos_close(struct tty_struct *tty, struct file *filp)
+{
+	struct tty_pos *pdx = tty->driver_data;
+
+	if (pdx == NULL)
+		return;
+    if(pdx_table[pdx->devIndex]==NULL)
+        return;
+
+	if (pdx->ThreadState == THREAD_CREATED) {
+		pdx->ThreadState = THREAD_CLOSE;
+		wait_for_completion(&pdx->ThreadExit_completion);
+	}
+
+	pdx->ThreadState = THREAD_INIT;
+
+	kref_put(&pdx->kref, pos_delete);
+    //tty_ldisc_flush(tty);
+}
+
+static int pos_write(struct tty_struct *tty, const unsigned char *buf,
+    int count)
+{
+	struct tty_pos *pdx = tty->driver_data;
+	unsigned int wn, i;
+	int retval;
+
+	if (!pdx)
+		return USB_ERR_NOT_OPEN;
+
+	if (!THREAD_IS_RUNNING(pdx->ThreadState)) {
+		retval = USB_ERR_INVALID;
+		goto exit;
+	}
+
+	if (count == 0) {
+		retval = 0;
+		goto exit;
+	}
+
+	wn = GET_SPACE_POOL(pdx->TxPool);
+	if (wn >= count) {
+		wn = count;
+	}
+	else
+		return USB_ERR_BUF;
+
+	for (i = 0; i < wn; i++) {
+		pdx->TxPool.Buffer[(pdx->TxPool.WritePos + i) % POOL_SIZE] =
+		    buf[i];
+	}
+
+	pdx->TxPool.WritePos = (pdx->TxPool.WritePos + wn) % POOL_SIZE;
+	retval = wn;
+
+	atomic_set(&pdx->write_flag, 1);
+	wake_up(&pdx->write_wait);
+ exit:
+	return retval;
+}
+
+static int pos_write_room(struct tty_struct *tty)
+{
+	struct tty_pos *pdx = tty->driver_data;
+	int room = -EINVAL;
+
+	if (!pdx)
+		return -ENODEV;
+
+	room = GET_SPACE_POOL(pdx->TxPool);
+	return room;
+}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+static int pos_ioctl(struct tty_struct *tty, struct file *filp,
+    unsigned int cmd, unsigned long arg)
+#else
+static int pos_ioctl(struct tty_struct *tty, unsigned int cmd,
+    unsigned long arg)
+#endif    
+{
+	struct tty_pos *pdx = tty->driver_data;
+
+#if 0
+	INFO("pos_ioctl\n");
+#endif
+	if (!pdx)
+		return -ENODEV;
+
+	switch (cmd) {
+	case TIOCGSERIAL:
+	case TIOCMIWAIT:
+	case TIOCGICOUNT:
+	default:
+		break;
+	}
+    #if 0
+    INFO("%s-cmd: 0x%X\n", __func__, cmd);
+    #endif
+	return -ENOIOCTLCMD;
+}
+
+#define RELEVANT_IFLAG(iflag) \
+	((iflag) & (IGNBRK | BRKINT | IGNPAR | PARMRK | INPCK))
+
+static void pos_set_termios(struct tty_struct *tty,
+    struct ktermios *old_termios)
+{
+	unsigned int cflag;
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    cflag = tty->termios.c_cflag;
+#else
+	cflag = tty->termios->c_cflag;
+#endif
+#endif
+	/* check that they really want us to change something */
+	if (old_termios) {
+		if ((cflag == old_termios->c_cflag) &&
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+            (RELEVANT_IFLAG(tty->termios.c_iflag) ==
+#else            
+		    (RELEVANT_IFLAG(tty->termios->c_iflag) ==
+#endif
+#endif
+		    RELEVANT_IFLAG(old_termios->c_iflag))) {
+#if 0
+			INFO(" - nothing to change...\n");
+#endif
+			return;
+		}
+	}
+#if 0
+	/* get the byte size */
+	switch (cflag & CSIZE) {
+	case CS5:
+		INFO(" - data bits = 5\n");
+		break;
+	case CS6:
+		INFO(" - data bits = 6\n");
+		break;
+	case CS7:
+		INFO(" - data bits = 7\n");
+		break;
+	default:
+	case CS8:
+		INFO(" - data bits = 8\n");
+		break;
+	}
+
+	/* determine the parity */
+	if (cflag & PARENB) {
+		if (cflag & PARODD) {
+			INFO(" - parity = odd\n");
+		}
+		else {
+			INFO(" - parity = even\n");
+		}
+	}
+	else {
+		INFO(" - parity = none\n");
+	}
+
+	/* figure out the stop bits requested */
+	if (cflag & CSTOPB) {
+		INFO(" - stop bits = 2\n");
+	}
+	else {
+		INFO(" - stop bits = 1\n");
+	}
+
+	/* figure out the hardware flow control settings */
+	if (cflag & CRTSCTS) {
+		INFO(" - RTS/CTS is enabled\n");
+	}
+	else {
+		INFO(" - RTS/CTS is disabled\n");
+	}
+
+	/* determine software flow control.
+	 * if we are implementing XON/XOFF, set the start and
+	 * stop character in the device */
+	if (I_IXOFF(tty) || I_IXON(tty)) {
+		unsigned char stop_char = STOP_CHAR(tty);
+		unsigned char start_char = START_CHAR(tty);
+
+		/* if we are implementing INBOUND XON/XOFF */
+		if (I_IXOFF(tty)) {
+			INFO(" - INBOUND XON/XOFF is enabled, "
+			    "XON = %2x, XOFF = %2x", start_char, stop_char);
+		}
+		else {
+			INFO(" - INBOUND XON/XOFF is disabled");
+		}
+
+		/* if we are implementing OUTBOUND XON/XOFF */
+		if (I_IXON(tty)) {
+			INFO(" - OUTBOUND XON/XOFF is enabled, "
+			    "XON = %2x, XOFF = %2x", start_char, stop_char);
+		}
+		else {
+			INFO(" - OUTBOUND XON/XOFF is disabled");
+		}
+	}
+
+	/* get the baud rate wanted */
+	INFO(" - baud rate = %d\n", tty_get_baud_rate(tty));
+#endif
+}
+
+static void pos_throttle(struct tty_struct *tty)
+{
+	/* INFO("pos_throttle\n"); */
+}
+
+static void pos_unthrottle(struct tty_struct *tty)
+{
+	/* INFO("pos_unthrottle\n"); */
+}
+
+static void pos_flush_buffer(struct tty_struct *tty)
+{
+	struct tty_pos *pdx = tty->driver_data;
+
+#if 0
+	INFO("pos_flush_buffer\n");
+#endif
+
+	if (!pdx)
+		return;
+
+	INIT_POOL_BUFFER(pdx->TxPool);
+}
+
+static int pos_chars_in_buffer(struct tty_struct *tty)
+{
+	int in_buf_len;
+	struct tty_pos *pdx = tty->driver_data;
+
+	if (!pdx)
+		return -ENODEV;
+
+	in_buf_len = GET_USING_POOL(pdx->TxPool);
+#if 0
+	printk(KERN_ALERT "pos_chars_in_buffer: %d\n", in_buf_len);
+#endif
+
+	return in_buf_len;
+}
+
+/* Our fake UART values */
+#define MCR_DTR		0x01
+#define MCR_RTS		0x02
+#define MCR_LOOP	0x04
+#define MSR_CTS		0x08
+#define MSR_CD		0x10
+#define MSR_RI		0x20
+#define MSR_DSR		0x40
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+static int pos_tiocmget(struct tty_struct *tty, struct file *filp)
+#else
+static int pos_tiocmget(struct tty_struct *tty)
+#endif
+{
+	struct tty_pos *pdx = tty->driver_data;
+	unsigned int msr, mcr, result;
+
+#if 0
+	INFO("pos_tiocmget\n");
+#endif
+	if (!pdx)
+		return -ENODEV;
+
+	msr = pdx->msr;
+	mcr = pdx->mcr;
+
+	result = ((mcr & MCR_DTR) ? TIOCM_DTR : 0) |	/* DTR is set */
+	    ((mcr & MCR_RTS) ? TIOCM_RTS : 0) |		/* RTS is set */
+	    ((mcr & MCR_LOOP) ? TIOCM_LOOP : 0) |	/* LOOP is set */
+	    ((msr & MSR_CTS) ? TIOCM_CTS : 0) |		/* CTS is set */
+	    ((msr & MSR_CD) ? TIOCM_CAR : 0) |	/* Carrier detect is set */
+	    ((msr & MSR_RI) ? TIOCM_RI : 0) |	/* Ring Indicator is set */
+	    ((msr & MSR_DSR) ? TIOCM_DSR : 0);		/* DSR is set */
+
+	return result;
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
+static int pos_tiocmset(struct tty_struct *tty, struct file *filp,
+    unsigned int set, unsigned int clear)
+#else
+static int pos_tiocmset(struct tty_struct *tty, unsigned int set, 
+    unsigned int clear)
+#endif    
+{
+	struct tty_pos *pdx = tty->driver_data;
+	unsigned int mcr;
+
+	if (!pdx)
+		return -ENODEV;
+
+	mcr = pdx->mcr;
+
+	if (set & TIOCM_RTS) {
+		mcr |= MCR_RTS;
+	}
+	if (set & TIOCM_DTR) {
+		mcr |= MCR_DTR;		/* mcr |= MCR_RTS; */
+	}
+
+	if (clear & TIOCM_RTS) {
+		mcr &= ~MCR_RTS;
+	}
+	if (clear & TIOCM_DTR) {
+		mcr &= ~MCR_DTR;	/* mcr &= ~MCR_RTS; */
+	}
+
+	/* set the new MCR value in the device */
+	pdx->mcr = mcr;
+	return 0;
+}
+
+static const struct tty_operations pos_ops = {
+	.open = pos_open,
+	.close = pos_close,
+	.write = pos_write,
+	.write_room = pos_write_room,
+	.ioctl = pos_ioctl,
+	.set_termios = pos_set_termios,
+	.throttle = pos_throttle,
+	.unthrottle = pos_unthrottle,
+	.flush_buffer = pos_flush_buffer,
+	.chars_in_buffer = pos_chars_in_buffer,
+	.tiocmget = pos_tiocmget,
+	.tiocmset = pos_tiocmset,
+};
+
+struct tty_driver *pos_tty_driver;
+
+static int pos_usb_probe(struct usb_interface *interface,
+    const struct usb_device_id *id)
+{
+	struct tty_pos *pdx;
+	struct usb_host_interface *iface_desc;
+	struct usb_endpoint_descriptor *endpoint;
+
+	int i, retval = -ENOMEM;
+
+    for(i=0;i<POS_TTY_MINORS;i++)
+    {
+		if (pdx_table[i] == NULL)
+			break;
+	}
+
+    if(i==POS_TTY_MINORS)
+		return -ENOMEM;
+
+	pdx = kzalloc(sizeof(*pdx), /* GFP_KERNEL */ GFP_ATOMIC);
+	if (!pdx) {
+		ERR("OUT OF MEMORY pdx\n");
+		return -ENOMEM;
+	}
+
+	pdx->BioPack = kzalloc(sizeof(*pdx->BioPack), GFP_ATOMIC);
+	if (!pdx) {
+		ERR("OUT OF MEMORY BioPack\n");
+		return -ENOMEM;
+	}
+
+	printk(KERN_ALERT "ttyPos probe:%s %s,index:%d\n",DRV_VERSION,VERSION_DATE,i);
+
+	pdx->devIndex = i;
+	pdx_table[pdx->devIndex] = pdx;
+
+	INIT_POOL_BUFFER(pdx->TxPool);
+
+	pdx->timeout_jiffies = 400 * HZ / 1000;		/* 400ms */
+	kref_init(&pdx->kref);
+	init_waitqueue_head(&pdx->urb_wait);
+	atomic_set(&pdx->urb_done, 0);
+
+	init_waitqueue_head(&pdx->write_wait);
+	atomic_set(&pdx->write_flag, 0);
+
+	init_completion(&pdx->ThreadExit_completion);
+
+	pdx->udev = usb_get_dev(interface_to_usbdev(interface));
+	pdx->interface = interface;
+
+	pdx->urb = usb_alloc_urb(0, /* GFP_KERNEL */ GFP_ATOMIC);
+	if (!pdx->urb) {
+		retval = -ENOMEM;
+		ERR("FAILED ALLOC URB!\n");
+		goto error;
+	}
+
+	iface_desc = interface->cur_altsetting;
+
+	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+		endpoint = &iface_desc->endpoint[i].desc;
+
+		if (endpoint->bEndpointAddress & 0x80) {
+			pdx->bulk_in_epAddr = endpoint->bEndpointAddress;
+		}
+		else {
+			pdx->bulk_out_epAddr = endpoint->bEndpointAddress;
+		}
+	}
+
+	if (!(pdx->bulk_in_epAddr && pdx->bulk_out_epAddr)) {
+		ERR("COULD NOT FIND BOTH BULK-IN AND BULK-OUT ENDPOINT\n");
+	}
+
+	usb_set_intfdata(interface, pdx);
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    tty_port_register_device(&pos_port[pdx->devIndex], pos_tty_driver,
+			pdx->devIndex, NULL);
+#else
+    tty_register_device(pos_tty_driver, pdx->devIndex, NULL);
+#endif
+#endif
+
+    dev_info(&interface->dev,
+                "USB POS device now attached to PosUsb-%d",
+                interface->minor);
+	return 0;
+
+ error:
+	if (pdx) {
+		kref_put(&pdx->kref, pos_delete);
+	}
+
+	ERR("--pos_probe error\n");
+	return retval;
+}
+
+static void pos_usb_disconnect(struct usb_interface *interface)
+{
+	struct tty_pos *pdx;
+
+#if 0
+	INFO("++pos_disconnect\n");
+#endif
+	pdx = usb_get_intfdata(interface);
+	if (pdx == NULL)
+		return;
+
+	tty_unregister_device(pos_tty_driver, pdx->devIndex);
+
+	if (pdx->ThreadState == THREAD_CREATED) {
+		pdx->ThreadState = THREAD_CLOSE;
+#if 0        
+		INFO("Wait thread exit\n");
+#endif        
+		wait_for_completion(&pdx->ThreadExit_completion);
+#if 0        
+		INFO("Wait thread exit success!\n");
+#endif    
+	}
+	pdx->ThreadState = THREAD_INIT;
+
+	usb_set_intfdata(interface, NULL);
+
+#if 0
+	usb_deregister_dev(interface, &pos_class);
+#endif
+
+	pdx->interface = NULL;
+
+	kref_put(&pdx->kref, pos_delete);
+#if 0
+	INFO("--pos_disconnect\n");
+#endif
+}
+
+#if 1
+static int pos_usb_suspend(struct usb_interface *intf, pm_message_t message)
+{
+//	printk(KERN_ALERT "pos_suspend\n");
+
+	return 0;
+}
+
+static int pos_usb_resume(struct usb_interface *intf)
+{
+//	printk(KERN_ALERT "pos_resume\n");
+
+	return 0;
+}
+#endif
+
+#ifdef OLD_USB_DRIVER
+static void pos_usb_pre_reset(struct usb_interface *intf)
+{
+	/* struct tty_pos *pdx = usb_get_intfdata(intf); */
+#if 0
+	INFO("pos_pre_reset\n");
+#endif
+}
+#else
+static int pos_usb_pre_reset(struct usb_interface *intf)
+{
+	/* struct tty_pos *pdx = usb_get_intfdata(intf); */
+#if 0
+	INFO("pos_pre_reset\n");
+#endif
+	return 0;
+}
+#endif
+
+#ifdef OLD_USB_DRIVER
+static void pos_usb_post_reset(struct usb_interface *intf)
+{
+#if 0
+	INFO("pos_post_reset\n");
+#endif
+}
+#else
+static int pos_usb_post_reset(struct usb_interface *intf)
+{
+#if 0
+	INFO("pos_post_reset\n");
+#endif
+	return 0;
+}
+#endif
+
+static struct usb_driver pos_usb_driver = {
+    .name   =       "PosUsb",
+	.probe = pos_usb_probe,
+	.disconnect = pos_usb_disconnect,
+#if 1
+	.suspend = pos_usb_suspend,
+	.resume = pos_usb_resume,
+	.supports_autosuspend = 1,
+#endif
+	.pre_reset = pos_usb_pre_reset,
+	.post_reset = pos_usb_post_reset,
+	.id_table = pos_usb_table,
+};
+
+/* Compatible with TTY_DRIVER_DYNAMIC_DEV and TTY_DRIVER_NO_DEVFS */
+#define TTY_USB_DEV     0x0008 
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+
+static int pos_port_activate(struct tty_port *port, struct tty_struct *tty)
+{
+	return 0;
+}
+
+static void pos_port_shutdown(struct tty_port *port)
+{
+
+}
+
+static int pos_carrier_raised(struct tty_port *port)
+{
+	return 0;
+}
+
+static void pos_dtr_rts(struct tty_port *port, int onoff)
+{
+}
+
+static const struct tty_port_operations pos_port_ops = {
+	.activate	= pos_port_activate,
+	.shutdown	= pos_port_shutdown,
+	.carrier_raised = pos_carrier_raised,
+	.dtr_rts	= pos_dtr_rts,
+};
+#endif
+#endif
+
+static int __init pos_tty_init(void)
+{
+	int result,i;
+
+	printk(KERN_ALERT "ttyPos:%s %s\n",DRV_VERSION,VERSION_DATE);
+
+    for(i=0;i<POS_TTY_MINORS;i++)
+		pdx_table[i] = NULL;
+
+	pos_tty_driver = alloc_tty_driver(POS_TTY_MINORS);
+	if (!pos_tty_driver)
+		return -ENOMEM;
+
+	pos_tty_driver->owner = THIS_MODULE;
+	pos_tty_driver->driver_name = "usbpos";
+	pos_tty_driver->name = 	"ttyPos";
+	pos_tty_driver->major = 0;//POS_TTY_MAJOR;//The major number will be chosen dynamically
+	pos_tty_driver->minor_start = 0;
+	pos_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
+	pos_tty_driver->subtype = SERIAL_TYPE_NORMAL;
+	pos_tty_driver->flags = TTY_DRIVER_REAL_RAW | TTY_USB_DEV;
+	pos_tty_driver->init_termios = tty_std_termios;
+	pos_tty_driver->init_termios.c_cflag = B9600 | CS8 | CREAD
+	    | HUPCL | CLOCAL;
+
+	tty_set_operations(pos_tty_driver, &pos_ops);
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+	for (i = 0; i < POS_TTY_MINORS; i++) 
+    {
+		tty_port_init(&pos_port[i]);
+		pos_port[i].ops = &pos_port_ops;
+		pos_port[i].close_delay     = HZ / 2;	/* .5 seconds */
+		pos_port[i].closing_wait    = 30 * HZ;/* 30 seconds */
+	}
+#endif
+#endif
+
+	result = tty_register_driver(pos_tty_driver);
+	if (result) {
+		ERR("%s - tty_register_driver failed\n", __func__);
+		goto byebye1;
+	}
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    for (i = 0; i < POS_TTY_MINORS; i++)
+		tty_port_destroy(&pos_port[i]);
+#endif
+#endif
+
+	result = usb_register(&pos_usb_driver);
+	if (result) {
+		ERR("%s - usb_register failed; err: %d\n",__func__, result);
+        goto byebye2;
+	}
+
+    
+	return 0;
+byebye2:
+	tty_unregister_driver(pos_tty_driver);
+byebye1:
+    put_tty_driver(pos_tty_driver);
+
+	return result;
+}
+
+static void __exit pos_tty_exit(void)
+{
+    unsigned int i;
+    
+	usb_deregister(&pos_usb_driver);
+	tty_unregister_driver(pos_tty_driver);
+    put_tty_driver(pos_tty_driver);
+
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+    for (i = 0; i < POS_TTY_MINORS; i++)
+		tty_port_destroy(&pos_port[i]);
+#endif
+#endif
+
+    INFO("pos_tty_exit\n");
+}
+
+module_init(pos_tty_init);
+module_exit(pos_tty_exit);
+
+MODULE_LICENSE("GPL");
+MODULE_ALIAS_LDISC(N_SLIP);

+ 137 - 0
utils/linux/Driver/ttyPos.h

@@ -0,0 +1,137 @@
+#ifndef _TTY_POS_H_
+#define _TTY_POS_H_
+
+#include <linux/module.h>
+#include <linux/version.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/slab.h>
+#include <linux/tty.h>
+#include <linux/tty_driver.h>
+#include <linux/tty_flip.h>
+#include <linux/kref.h>
+#include <linux/uaccess.h>
+#include <linux/usb.h>
+#include <linux/mutex.h>
+#include <linux/time.h>
+#include <linux/sched.h>
+#ifdef LINUX_VERSION_CODE
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0))
+#include <linux/err.h>
+#include <linux/kthread.h>
+#endif
+#endif
+#define USB_VENDOR_ID		0x1234
+#define USB_PRODUCT_ID		0x0101
+
+static struct usb_device_id pos_usb_table[] = {
+	{ USB_DEVICE(USB_VENDOR_ID, USB_PRODUCT_ID) },
+	{},
+};
+
+MODULE_DEVICE_TABLE(usb,pos_usb_table);
+
+//#define POS_TTY_MAJOR		192	/* experimental range */
+#define POS_TTY_MINORS		20	/* only have 20 devices */
+
+#define THREAD_INIT		0x00
+#define THREAD_STOPPED		0x01
+#define THREAD_CREATED		0x82
+#define THREAD_CLOSE		0x83
+
+#define THREAD_IS_RUNNING(ThreadState)	(ThreadState & 0x80)
+
+#define WRITE_COMMAND		0	/* write to usb device command */
+#define READ_COMMAND		1	/* read from to usb device command */
+#define STATUS_COMMAND		2	/* get device buffer status command */
+
+#define POOL_SIZE		10241
+
+typedef struct _POOL {
+	unsigned int ReadPos;
+	unsigned int WritePos;
+	unsigned char Buffer[POOL_SIZE];
+} __attribute__((packed)) POOL, *PPOOL;
+
+typedef struct {
+	unsigned char SeqNo;
+	unsigned char ReqType;		/* 0:OUT, 1:IN, 2:STAT, 3:RESET */
+	unsigned short Len;
+	unsigned char Data[508];
+} __attribute__((packed)) ST_BULK_IO;
+
+typedef struct {
+	unsigned int TxBufSize;
+	unsigned int RxBufSize;
+	unsigned int TxLeft;
+	unsigned int RxLeft;
+} __attribute__((packed)) ST_BIO_STATE;
+
+struct tty_pos {
+	struct tty_struct *tty;
+	unsigned char devIndex;
+
+	/* for tiocmget and tiocmset functions */
+	int msr;		/* MSR shadow */
+	int mcr;		/* MCR shadow */
+
+	struct file *filp;
+
+	struct usb_device *udev;
+	struct usb_interface *interface;
+	struct urb *urb;
+	wait_queue_head_t urb_wait;
+	atomic_t urb_done;
+	int timeout_jiffies;
+	atomic_t urb_busy;
+
+	wait_queue_head_t write_wait;
+	atomic_t write_flag;
+
+	__u8 bulk_in_epAddr;
+	__u8 bulk_out_epAddr;
+
+	struct kref kref;
+	struct mutex io_mutex;		/* synchronize I/O with disconnect */
+	volatile u8 ThreadState;
+	struct completion ThreadExit_completion;
+
+	unsigned char SeqCount;
+	ST_BULK_IO *BioPack;		/* for IO access */
+	ST_BIO_STATE BioDevState;
+
+	POOL TxPool;
+};
+
+#define to_pos_dev(d)		container_of(d, struct tty_pos, kref)
+
+#define INIT_POOL_BUFFER(pool)	pool.ReadPos = pool.WritePos = 0
+
+#define IS_POOL_EMPTY(pool)	(pool.ReadPos == pool.WritePos)
+
+#define GET_USING_POOL(pool) \
+	((pool.WritePos + POOL_SIZE - pool.ReadPos) % POOL_SIZE)
+
+#define GET_SPACE_POOL(pool)	(POOL_SIZE - 1 - GET_USING_POOL(pool))
+
+#if 0
+#define ERR(stuff...)
+#define INFO(stuff...)
+#else
+#define ERR(stuff...)		printk(KERN_ERR "ttyPos: " stuff)
+#define INFO(stuff...)		printk(KERN_INFO "ttyPos: " stuff)
+#endif
+
+//--error code define of API call
+#define USB_ERR_NOT_OPEN        (-3403)//通道未打开
+#define USB_ERR_BUF             (-3404)//发送缓冲区错误
+#define USB_ERR_NOT_FREE        (-3405)//无可用的端口
+#define USB_ERR_NO_CONF         (-3411)//设备未完成枚举和配置过程
+#define USB_ERR_DISCONN         (-3412)//设备已经与主机断开
+#define USB_ERR_MEM_SYSTEM      (-3413)//系统内存出现异常
+#define USB_ERR_BUSY            (-3414)//USB系统忙碌
+#define USB_ERR_RC_SYSTEM       (-3415)//系统资源申请失败
+#define USB_ERR_DEV_ABSENT      (-3416)//USB主机上设备不在位
+#define USB_ERR_INVALID         (-3417)//USB通讯状态无效
+#endif

BIN
utils/linux/Driver/ttyPos.ko


+ 72 - 0
utils/linux/Driver/ttyPos.mod.c

@@ -0,0 +1,72 @@
+#include <linux/module.h>
+#include <linux/vermagic.h>
+#include <linux/compiler.h>
+
+MODULE_INFO(vermagic, VERMAGIC_STRING);
+
+__visible struct module __this_module
+__attribute__((section(".gnu.linkonce.this_module"))) = {
+	.name = KBUILD_MODNAME,
+	.init = init_module,
+#ifdef CONFIG_MODULE_UNLOAD
+	.exit = cleanup_module,
+#endif
+	.arch = MODULE_ARCH_INIT,
+};
+
+static const struct modversion_info ____versions[]
+__used
+__attribute__((section("__versions"))) = {
+	{ 0xce67f0de, __VMLINUX_SYMBOL_STR(module_layout) },
+	{ 0x7986ac06, __VMLINUX_SYMBOL_STR(usb_deregister) },
+	{ 0x9e548906, __VMLINUX_SYMBOL_STR(put_tty_driver) },
+	{ 0xcfa87a29, __VMLINUX_SYMBOL_STR(tty_unregister_driver) },
+	{ 0x4b83a80f, __VMLINUX_SYMBOL_STR(usb_register_driver) },
+	{ 0x7546448f, __VMLINUX_SYMBOL_STR(tty_port_destroy) },
+	{ 0x173c7d63, __VMLINUX_SYMBOL_STR(tty_register_driver) },
+	{ 0xd9948b65, __VMLINUX_SYMBOL_STR(tty_port_init) },
+	{ 0x3f151bed, __VMLINUX_SYMBOL_STR(tty_set_operations) },
+	{ 0x67b27ec1, __VMLINUX_SYMBOL_STR(tty_std_termios) },
+	{ 0xb674fb3f, __VMLINUX_SYMBOL_STR(__tty_alloc_driver) },
+	{ 0xbc25ddba, __VMLINUX_SYMBOL_STR(tty_unregister_device) },
+	{ 0x6d0aba34, __VMLINUX_SYMBOL_STR(wait_for_completion) },
+	{ 0x73f84837, __VMLINUX_SYMBOL_STR(_dev_info) },
+	{ 0xf16ea7d2, __VMLINUX_SYMBOL_STR(tty_port_register_device) },
+	{ 0x95562a7b, __VMLINUX_SYMBOL_STR(usb_alloc_urb) },
+	{ 0x9a2f439c, __VMLINUX_SYMBOL_STR(usb_get_dev) },
+	{ 0xf432dd3d, __VMLINUX_SYMBOL_STR(__init_waitqueue_head) },
+	{ 0x48b65efa, __VMLINUX_SYMBOL_STR(kmem_cache_alloc_trace) },
+	{ 0xf08b545, __VMLINUX_SYMBOL_STR(kmalloc_caches) },
+	{ 0xa202a8e5, __VMLINUX_SYMBOL_STR(kmalloc_order_trace) },
+	{ 0x16305289, __VMLINUX_SYMBOL_STR(warn_slowpath_null) },
+	{ 0x46d5b1a7, __VMLINUX_SYMBOL_STR(wake_up_process) },
+	{ 0x8af08e8a, __VMLINUX_SYMBOL_STR(kthread_create_on_node) },
+	{ 0x76d65595, __VMLINUX_SYMBOL_STR(tty_port_tty_set) },
+	{ 0xdfb78c98, __VMLINUX_SYMBOL_STR(tty_flip_buffer_push) },
+	{ 0x50e4f32d, __VMLINUX_SYMBOL_STR(tty_insert_flip_string_fixed_flag) },
+	{ 0x952664c5, __VMLINUX_SYMBOL_STR(do_exit) },
+	{ 0x4b06d2e7, __VMLINUX_SYMBOL_STR(complete) },
+	{ 0x7d3cb6bb, __VMLINUX_SYMBOL_STR(tty_buffer_request_room) },
+	{ 0xe3d45d73, __VMLINUX_SYMBOL_STR(usb_reset_device) },
+	{ 0xd85105f, __VMLINUX_SYMBOL_STR(usb_clear_halt) },
+	{ 0xb6c04be8, __VMLINUX_SYMBOL_STR(usb_kill_urb) },
+	{ 0x27e1a049, __VMLINUX_SYMBOL_STR(printk) },
+	{ 0xd62c833f, __VMLINUX_SYMBOL_STR(schedule_timeout) },
+	{ 0xfa66f77c, __VMLINUX_SYMBOL_STR(finish_wait) },
+	{ 0x34f22f94, __VMLINUX_SYMBOL_STR(prepare_to_wait_event) },
+	{ 0x9589c982, __VMLINUX_SYMBOL_STR(usb_submit_urb) },
+	{ 0xcf21d241, __VMLINUX_SYMBOL_STR(__wake_up) },
+	{ 0x37a0cba, __VMLINUX_SYMBOL_STR(kfree) },
+	{ 0x20903b29, __VMLINUX_SYMBOL_STR(usb_put_dev) },
+	{ 0x786fa262, __VMLINUX_SYMBOL_STR(usb_free_urb) },
+	{ 0xbdfb6dbb, __VMLINUX_SYMBOL_STR(__fentry__) },
+};
+
+static const char __module_depends[]
+__used
+__attribute__((section(".modinfo"))) =
+"depends=";
+
+MODULE_ALIAS("usb:v1234p0101d*dc*dsc*dp*ic*isc*ip*in*");
+
+MODULE_INFO(srcversion, "5AB993BD6815A26E338AACA");

BIN
utils/linux/Driver/ttyPos.mod.o


BIN
utils/linux/Driver/ttyPos.o


+ 299 - 0
utils/linux/Driver/ttyTest.c

@@ -0,0 +1,299 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+//#include <sys/file.h>
+#include <signal.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+
+static volatile sig_atomic_t doneflag = 0;
+
+static void setdoneflag(int signo)
+{
+	doneflag = 1;
+}
+
+static int initSig(void)
+{
+	struct sigaction act;
+	act.sa_handler = setdoneflag;
+	act.sa_flags = 0;
+	if((sigemptyset(&act.sa_mask) == -1)||
+		(sigaction(SIGINT,&act,NULL) == -1))
+	{
+		perror("Failed to set SIGINT handler");
+		return 1;
+	}
+
+	return 0;
+}
+
+int setSerial(int fd,int nSpeed,int nBits,char nEvent,int nStop)
+{
+	struct termios newtio,oldtio;
+
+	if(tcgetattr(fd,&oldtio) != 0)
+	{
+		perror("SetupSerial 1");
+		return 1;
+	}
+
+	bzero(&newtio,sizeof(newtio));
+	
+	//1:Setting char size
+	newtio.c_cflag |= CLOCAL | CREAD;
+	newtio.c_cflag &= ~CSIZE;
+
+	//2:Setting bits
+	switch(nBits)
+	{
+	case 7:
+		newtio.c_cflag |= CS7;
+		break;
+
+	case 8:
+		newtio.c_cflag |= CS8;
+		break;
+	}
+	
+	//3:Setting parity
+	switch(nEvent)
+	{
+	case 'O':
+		newtio.c_cflag |= PARENB;
+		newtio.c_cflag |= PARODD;
+		newtio.c_cflag |= (INPCK | ISTRIP);
+		break;
+	
+	case 'E':
+		newtio.c_cflag |= (INPCK | ISTRIP);
+		newtio.c_cflag |= PARENB;
+		newtio.c_cflag &= ~PARODD;
+		break;
+
+	case 'N':
+		newtio.c_cflag &= ~PARENB;
+		break;
+	}
+
+	//4:Setting speed
+	switch(nSpeed)
+	{
+	case 2400:
+		cfsetispeed(&newtio,B2400);
+		cfsetospeed(&newtio,B2400);
+		break;
+	
+	case 4800:
+		cfsetispeed(&newtio,B4800);
+		cfsetospeed(&newtio,B4800);
+		break;
+
+	case 9600:
+		cfsetispeed(&newtio,B9600);
+		cfsetospeed(&newtio,B9600);
+		break;
+
+	case 115200:
+		cfsetispeed(&newtio,B115200);
+		cfsetospeed(&newtio,B115200);
+		break;
+
+	case 460800:
+		cfsetispeed(&newtio,B460800);
+		cfsetospeed(&newtio,B460800);
+		break;
+
+	default:
+		cfsetispeed(&newtio,B115200);
+		cfsetospeed(&newtio,B115200);
+		break;
+	}
+
+	//5:Setting stop bits
+	switch(nStop)
+	{
+	case 1:
+		newtio.c_cflag &= ~CSTOPB;
+		break;
+
+	case 2:
+		newtio.c_cflag |= CSTOPB;	
+		break;
+	}
+
+	//6:Setting recvice timeout and mini bytes  size of recvice
+	newtio.c_cc[VTIME] = 0;
+	newtio.c_cc[VMIN] = 0;
+
+	//7:flush input and output buffer
+	tcflush(fd,TCIOFLUSH);
+	
+	if(tcsetattr(fd,TCSANOW,&newtio) != 0)
+	{
+		perror("serial set error");
+		return 2;
+	}
+	
+	printf("serial setting done\n");
+	
+	return 0;
+}
+
+int openSerial(int fd,unsigned char *SerialName)
+{
+	fd = open(SerialName,O_RDWR|O_NOCTTY|O_NDELAY);
+	if(fd <0)
+	{
+		perror("open");
+		return fd;
+	}
+#if 1
+	if(fcntl(fd,F_SETFL,0) < 0)
+		printf("fcntl failed!\n");
+	else
+		printf("fcntl=%d\n",fcntl(fd,F_SETFL,0));	
+#endif
+	return fd;
+}
+
+int rwTest(int fd)
+{
+	int rLen=0,wLen=0,ret=0;
+	unsigned char buf[3000];
+    unsigned int i=0,j=0;
+	unsigned int r_count=0;
+#if 1	
+	fd_set rd;	
+
+	FD_ZERO(&rd);
+	FD_SET(fd,&rd);
+#endif
+	while(doneflag ==0)
+    {
+#if 1
+		while(!FD_ISSET(fd,&rd));
+		if(select(fd+1,&rd,NULL,NULL,NULL) <0)
+		continue;
+#endif
+        rLen= read(fd,buf,sizeof(buf));
+        if(rLen < 0)
+        {
+            perror("read");
+            return 1;
+        }
+
+        if(rLen == 0)
+        {
+            //sleep(1);
+//            printf("sleep\n");
+            continue;
+        }
+
+		//r_count++;
+		//if(r_count%100 == 0)
+       	//	 printf("rLen:%d\n",rLen);
+        
+        wLen = 0;
+        for(j=0;j<5;j++)
+        {
+            ret = write(fd, buf + wLen, rLen - wLen);
+            if(ret < 0)
+            {
+                perror("write");
+                return 2;
+            }
+            wLen += ret;
+
+            if(wLen == rLen)
+                break;
+        }
+
+        if(wLen == rLen)
+		{ 
+			//if(r_count%100 ==0)
+	   		//	printf("wLen:%d\n",wLen);
+		}
+		else
+        {
+            printf("write err 1\n");
+            return 3;
+        }
+    }
+	
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	int fd;
+    int flags;
+	int ret;
+    unsigned char SerialName[30]={0};
+
+	printf("Version:%s\n","2010.12.30_00");
+
+	if(argc == 1)
+	{
+		strcpy(SerialName,"/dev/ttyPos0");
+	}
+	else if(argc == 2)
+	{
+		strcpy(SerialName,argv[1]);
+	}
+	else
+	{
+		printf("ARG ERROR\n");
+		return 1;
+	}
+
+	printf("SerialName:%s\n",SerialName);
+
+	ret = initSig();
+	if(ret)
+		return ret;	        
+
+    
+	fd = openSerial(fd,SerialName);//open(SerialName,O_RDWR);
+
+	if(fd <0)
+	{
+		exit(1);
+	}
+	
+	ret = setSerial(fd,115200,8,'N',1);
+	if(ret != 0)
+	{
+		printf("setSerial:%d\n");
+		goto byebye;
+	}
+
+    if(ioctl(fd,TIOCMGET,&flags)<0)
+    {
+        perror("ioctl failed");
+        goto byebye;
+    }
+
+    printf("flags:%X\n",flags);
+
+	ret = rwTest(fd);
+	printf("rwTest:%d\n",ret);
+
+byebye:
+	printf("doneflag:%d\n",doneflag);
+	ret = close(fd);
+	if(ret <0)
+	{
+		perror("close");
+	}
+	else
+	{
+		printf("close success!\n");
+	}
+	exit(0);
+}

BIN
utils/linux/XCB/xcb


BIN
utils/linux/XCB/xcb_user_manual_v1.0.0_.pdf


BIN
utils/windows/posvcom_2.5.0.0/amd64/PosVcom.sys


BIN
utils/windows/posvcom_2.5.0.0/i386/PosVcom.sys


BIN
utils/windows/posvcom_2.5.0.0/posvcom.cat


+ 98 - 0
utils/windows/posvcom_2.5.0.0/posvcom.inf

@@ -0,0 +1,98 @@
+; POSVCOM.INF
+; 
+; Copyright ?2000-2013 Future Technology Devices International Limited
+;
+; USB serial port driver installation file for Windows 2000, XP, Server 2003, Vista, Server 2008,
+; Windows 7 and Server 2008 R2 (x86 and x64).
+; 
+[Version]
+Signature="$Windows NT$"
+DriverPackageType=PlugAndPlay
+DriverPackageDisplayName=%DeviceName%
+Class=Ports
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
+Provider=%ProviderName%
+DriverVer=06/21/2013,2.5.0.0
+Catalogfile=posvcom.cat
+
+[SourceDisksNames]
+1=%DriversDisk%,,,
+
+[SourceDisksFiles]
+posvcom.sys=1,i386
+
+[SourceDisksFiles.amd64]
+posvcom.sys=1,amd64
+
+[DestinationDirs]
+Wdm.Files.Driver=10,System32\Drivers
+
+[ControlFlags]
+ExcludeFromSelect=*
+
+[Manufacturer]
+%ProviderName% = PAXHW,NTamd64
+
+[PAXHW]
+%VID_1234&PID_0101.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0101
+
+[PAXHW.NTamd64]
+%VID_1234&PID_0101.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0101
+
+[PAXPort.NT.AddService]
+DisplayName    = %ServiceName%
+ServiceType    = %SERVICE_KERNEL_DRIVER%
+StartType      = %SERVICE_DEMAND_START%
+ErrorControl   = %SERVICE_ERROR_NORMAL%
+ServiceBinary  = %10%\System32\Drivers\posvcom.sys
+LoadOrderGroup = Base
+
+[Serenum_AddService]
+DisplayName    = %SereServiceName%
+ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
+StartType      = 3               ; SERVICE_DEMAND_START
+ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
+ServiceBinary  = %12%\serenum.sys
+LoadOrderGroup = PNP Filter
+
+[PAXPort.NT.AddReg]
+HKR,,,,%PortsClassName%
+HKR,,Icon,,"-23"
+HKR,,DevLoader,,*ntkern
+HKR,,NTMPDriver,,posvcom.sys
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
+
+[Wdm.Files.Driver]
+posvcom.sys,,,%COPYFLG_NOSKIP%
+
+[PAXPort.NT]
+CopyFiles=Wdm.Files.Driver
+AddReg=PAXPort.NT.AddReg
+
+[PAXPort.NTamd64]
+CopyFiles=Wdm.Files.Driver
+AddReg=PAXPort.NT.AddReg
+
+[PAXPort.NT.Services]
+AddService = vcom_service, %SPSVCINST_ASSOCSERVICE%, PAXPort.NT.AddService
+AddService = Serenum,,Serenum_AddService
+
+[PAXPort.NTamd64.Services]
+AddService = vcom_service, %SPSVCINST_ASSOCSERVICE%, PAXPort.NT.AddService
+AddService = Serenum,,Serenum_AddService
+
+[Strings]
+ProviderName="PAX Technology Co. Ltd"
+PortsClassName="PosPorts(VCOM)"
+DeviceName="Pos Vcom Device"
+ServiceName="Pos Vcom Driver"
+SereServiceName="Serenum Filter Driver"
+VID_1234&PID_0101.DeviceDesc="USB Serial Port(PAX)"
+DriversDisk="SYS file directory"
+
+SPSVCINST_ASSOCSERVICE=0x00000002	; Driver service is associated with device being installed
+COPYFLG_NOSKIP=2	; Do not allow user to skip file
+SERVICE_KERNEL_DRIVER=1
+SERVICE_AUTO_START=2
+SERVICE_DEMAND_START=3
+SERVICE_ERROR_NORMAL=1

BIN
utils/windows/posvcom_2.7.0.0/amd64/PosVcom.sys


BIN
utils/windows/posvcom_2.7.0.0/i386/PosVcom.sys


BIN
utils/windows/posvcom_2.7.0.0/posvcom.cat


+ 150 - 0
utils/windows/posvcom_2.7.0.0/posvcom.inf

@@ -0,0 +1,150 @@
+; POSVCOM.INF
+; 
+; Copyright ?2000-2013 Future Technology Devices International Limited
+;
+; USB serial port driver installation file for Windows 2000, XP, Server 2003, Vista, Server 2008,
+; Windows 7 and Server 2008 R2 (x86 and x64).
+; 
+[Version]
+Signature="$Windows NT$"
+DriverPackageType=PlugAndPlay
+DriverPackageDisplayName=%DeviceName%
+Class=Ports
+ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
+Provider=%ProviderName%
+DriverVer=10/16/2015,2.7.0.0
+Catalogfile=posvcom.cat
+
+[SourceDisksNames]
+1=%DriversDisk%,,,
+
+[SourceDisksFiles]
+posvcom.sys=1,i386
+
+[SourceDisksFiles.amd64]
+posvcom.sys=1,amd64
+
+[DestinationDirs]
+Wdm.Files.Driver=10,System32\Drivers
+
+[ControlFlags]
+ExcludeFromSelect=*
+
+[Manufacturer]
+%ProviderName% = PAXHW,NTamd64
+
+[PAXHW]
+%VID_1234&PID_0101.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0101
+%VID_1234&PID_0102.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0102
+%VID_1234&PID_0103.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0103
+%VID_1234&PID_0104.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0104
+%VID_1234&PID_0105.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0105
+%VID_1234&PID_0106.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0106
+%VID_1234&PID_0107.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0107
+%VID_1234&PID_0108.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0108
+%VID_1234&PID_0109.DeviceDesc%=PAXPort.NT, USB\VID_1234&PID_0109
+
+%VID_0866&PID_0201.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0201
+%VID_0866&PID_0202.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0202
+%VID_0866&PID_0203.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0203
+%VID_0866&PID_0204.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0204
+%VID_0866&PID_0205.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0205
+%VID_0866&PID_0206.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0206
+%VID_0866&PID_0207.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0207
+%VID_0866&PID_0208.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0208
+%VID_0866&PID_0209.DeviceDesc%=PAXPort.NT, USB\VID_0866&PID_0209
+[PAXHW.NTamd64]
+%VID_1234&PID_0101.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0101
+%VID_1234&PID_0102.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0102
+%VID_1234&PID_0103.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0103
+%VID_1234&PID_0104.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0104
+%VID_1234&PID_0105.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0105
+%VID_1234&PID_0106.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0106
+%VID_1234&PID_0107.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0107
+%VID_1234&PID_0108.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0108
+%VID_1234&PID_0109.DeviceDesc%=PAXPort.NTamd64, USB\VID_1234&PID_0109
+
+%VID_0866&PID_0201.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0201
+%VID_0866&PID_0202.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0202
+%VID_0866&PID_0203.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0203
+%VID_0866&PID_0204.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0204
+%VID_0866&PID_0205.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0205
+%VID_0866&PID_0206.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0206
+%VID_0866&PID_0207.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0207
+%VID_0866&PID_0208.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0208
+%VID_0866&PID_0209.DeviceDesc%=PAXPort.NTamd64, USB\VID_0866&PID_0209
+[PAXPort.NT.AddService]
+DisplayName    = %ServiceName%
+ServiceType    = %SERVICE_KERNEL_DRIVER%
+StartType      = %SERVICE_DEMAND_START%
+ErrorControl   = %SERVICE_ERROR_NORMAL%
+ServiceBinary  = %10%\System32\Drivers\posvcom.sys
+LoadOrderGroup = Base
+
+[Serenum_AddService]
+DisplayName    = %SereServiceName%
+ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
+StartType      = 3               ; SERVICE_DEMAND_START
+ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
+ServiceBinary  = %12%\serenum.sys
+LoadOrderGroup = PNP Filter
+
+[PAXPort.NT.AddReg]
+HKR,,,,%PortsClassName%
+HKR,,Icon,,"-23"
+HKR,,DevLoader,,*ntkern
+HKR,,NTMPDriver,,posvcom.sys
+HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"
+
+[Wdm.Files.Driver]
+posvcom.sys,,,%COPYFLG_NOSKIP%
+
+[PAXPort.NT]
+CopyFiles=Wdm.Files.Driver
+AddReg=PAXPort.NT.AddReg
+
+[PAXPort.NTamd64]
+CopyFiles=Wdm.Files.Driver
+AddReg=PAXPort.NT.AddReg
+
+[PAXPort.NT.Services]
+AddService = vcom_service, %SPSVCINST_ASSOCSERVICE%, PAXPort.NT.AddService
+AddService = Serenum,,Serenum_AddService
+
+[PAXPort.NTamd64.Services]
+AddService = vcom_service, %SPSVCINST_ASSOCSERVICE%, PAXPort.NT.AddService
+AddService = Serenum,,Serenum_AddService
+
+[Strings]
+ProviderName="PAX Technology Co. Ltd"
+PortsClassName="PosPorts(VCOM)"
+DeviceName="Pos Vcom Device"
+ServiceName="Pos Vcom Driver"
+SereServiceName="Serenum Filter Driver"
+VID_1234&PID_0101.DeviceDesc="USB Serial Port"
+VID_1234&PID_0102.DeviceDesc="USB Serial Port"
+VID_1234&PID_0103.DeviceDesc="USB Serial Port"
+VID_1234&PID_0104.DeviceDesc="USB Serial Port"
+VID_1234&PID_0105.DeviceDesc="USB Serial Port"
+VID_1234&PID_0106.DeviceDesc="USB Serial Port"
+VID_1234&PID_0107.DeviceDesc="USB Serial Port"
+VID_1234&PID_0108.DeviceDesc="USB Serial Port"
+VID_1234&PID_0109.DeviceDesc="USB Serial Port"
+
+VID_0866&PID_0201.DeviceDesc="USB Serial Port"
+VID_0866&PID_0202.DeviceDesc="USB Serial Port"
+VID_0866&PID_0203.DeviceDesc="USB Serial Port"
+VID_0866&PID_0204.DeviceDesc="USB Serial Port"
+VID_0866&PID_0205.DeviceDesc="USB Serial Port"
+VID_0866&PID_0206.DeviceDesc="USB Serial Port"
+VID_0866&PID_0207.DeviceDesc="USB Serial Port"
+VID_0866&PID_0208.DeviceDesc="USB Serial Port"
+VID_0866&PID_0209.DeviceDesc="USB Serial Port"
+DriversDisk="SYS file directory"
+
+SPSVCINST_ASSOCSERVICE=0x00000002	; Driver service is associated with device being installed
+COPYFLG_NOSKIP=2	; Do not allow user to skip file
+SERVICE_KERNEL_DRIVER=1
+SERVICE_AUTO_START=2
+SERVICE_DEMAND_START=3
+SERVICE_ERROR_NORMAL=1

BIN
utils/windows/term-assist-2.2/DuiLib.dll


+ 8 - 0
utils/windows/term-assist-2.2/Setting/setting.ini

@@ -0,0 +1,8 @@
+[setting]
+ConnType=1
+com=COM11
+com_index=1
+Dest_IP=
+Dest_port=5555
+CloseType=0
+Language=0

+ 3 - 0
utils/windows/term-assist-2.2/Setting/sysdwld.ini

@@ -0,0 +1,3 @@
+[list]
+OS_TYPE=0
+File_Type=0

BIN
utils/windows/term-assist-2.2/TermAssist-2.2.exe


BIN
utils/windows/term-assist-2.2/libusb0.dll


BIN
utils/windows/term-assist-2.2/skin/TermAssistRes.skin


+ 67 - 0
utils/windows/term-assist-2.2/tools/devinfo.xml

@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?><devinfo>
+	<terminal>
+		<os>Prolin2.4.51[D1]</os>
+		<build-time>2016-03-09</build-time>
+		<sn>55152475</sn>
+		<exsn>G3TN05041AJCWX000000000000000000</exsn>
+		<mach>s900</mach>
+		<flash>128MB</flash>
+		<freeflash>61.27M</freeflash>
+		<boot>2.0.05.3256</boot>
+		<ram>59.14MB</ram>
+		<freeram>32.15M</freeram>
+		<pn>S900-0GW-363-02LU</pn>
+		<pukmode>2</pukmode>
+		<msr>MEGAHUNT SecureHead Reader V4.32</msr>
+	</terminal>
+	<application>
+		<app id="MAINAPP" >
+			<appname>MerchantDeviceApp</appname>
+			<bin>bin/MablApp</bin>
+			<version>1.2.1.2</version>
+			<vender>Optomany</vender>
+			<description>AxeptMerchantDevice</description>
+			<mtime>2016-09-29 12:40:06</mtime>
+		</app>
+	</application>
+	<package>
+	</package>
+	<uspuk>
+		<puk0 crc="0xA40EB99B" owner="" />
+	</uspuk>
+	<property>
+		<fac key="ro.fac.ubootver" value="2.0.05.3256" />
+		<fac key="ro.fac.exsn" value="G3TN05041AJCWX000000000000000000" />
+		<fac key="ro.fac.sn" value="55152475" />
+		<fac key="ro.fac.prolin_debug_level" value="1" />
+		<fac key="ro.fac.lcd.rotate" value="90" />
+		<fac key="ro.fac.pcd.param3" value="00000000000000000000" />
+		<fac key="ro.fac.pcd.param2" value="6F3C0B03020300000000" />
+		<fac key="ro.fac.pcd.param1" value="00000FFF0404116F1100" />
+		<fac key="ro.fac.sdhc" value="4-32GB,Class4" />
+		<fac key="ro.fac.touchscreen" value="resistive,ads7846" />
+		<fac key="ro.fac.audiocard" value="CS4344-CZZR" />
+		<fac key="ro.fac.videocard" value="08" />
+		<fac key="ro.fac.msr" value="E-MAG_MH1601" />
+		<fac key="ro.fac.sci" value="05" />
+		<fac key="ro.fac.pcd" value="03" />
+		<fac key="ro.fac.printer" value="PRT-48F" />
+		<fac key="ro.fac.radio" value="02" />
+		<fac key="ro.fac.wifi" value="01" />
+		<fac key="ro.fac.battery" value="1" />
+		<fac key="ro.fac.simsocket" value="1" />
+		<fac key="ro.fac.buzzer" value="1" />
+		<fac key="ro.fac.keybroad" value="1" />
+		<fac key="ro.fac.leddt" value="0" />
+		<fac key="ro.fac.usb.otg" value="1" />
+		<fac key="ro.fac.usb.device" value="1" />
+		<fac key="ro.fac.usb.host" value="1" />
+		<fac key="ro.fac.eth" value="0" />
+		<fac key="ro.fac.boardver" value="ANT04" />
+		<fac key="ro.fac.pn" value="S900-0GW-363-02LU" />
+		<fac key="ro.fac.conf.ver" value="08AL02_V2.0" />
+		<fac key="ro.fac.mach" value="s900" />
+		<fac key="ro.fac.hwver" value="08-05" />
+		<fac key="ro.fac.boardid" value="S900_M08_P05_GPRS_MG323" />
+	</property>
+</devinfo>

BIN
utils/windows/term-assist-2.2/tools/xcb.exe


BIN
utils/windows/term-assist-3.0.7.4742/DuiLib.dll


+ 10 - 0
utils/windows/term-assist-3.0.7.4742/Setting/setting.ini

@@ -0,0 +1,10 @@
+[setting]
+ConnType=1
+com=
+com_index=-1
+Dest_IP=
+Dest_port=5555
+CloseType=0
+download_mode=1
+Language=0
+sync_time=1

BIN
utils/windows/term-assist-3.0.7.4742/TermAssist.exe


+ 6 - 0
utils/windows/term-assist-3.0.7.4742/config.ini

@@ -0,0 +1,6 @@
+[machinfo]
+;格式:Prolin版本=对应机型(英文字母隔开)
+2.4=S300,S800,S900,S920,D200,K800,D820PRT,S900_ECR
+2.5=PX5,PX7,S920
+2.6=Q80,Q80S,Q90,Q90S,Q30,Q30S,D220,QR55,Q50
+2.7=SP200

BIN
utils/windows/term-assist-3.0.7.4742/libusb0.dll


BIN
utils/windows/term-assist-3.0.7.4742/skin/TermAssistRes2.3.skin


BIN
utils/windows/term-assist-3.0.7.4742/tools/7za.exe


BIN
utils/windows/term-assist-3.0.7.4742/tools/USBDriver.exe


BIN
utils/windows/term-assist-3.0.7.4742/tools/data/7zr.exe


BIN
utils/windows/term-assist-3.0.7.4742/tools/data/data.7z


BIN
utils/windows/term-assist-3.0.7.4742/tools/xcb.exe