java - Trigger Prolific Barcode Scanner device from Android -


Sorry for my bad english I am using a great tool for which I have to give commands and read the data. I want to read and write data to com port. I specify the code given in the PL 303 Drivers Library, which I got with the SDK provided here

.

If I scan something from the bar code scanner, then I can read that data from com port. If I write to write some data then it writes that the number of bytes in writing is quite large. There is no problem with that but I want to send the command to the device which will shine the bar code scanner and will scan the bar code. I use the USB Serial Terminal Light Application. If I run the command # 55 # 30 # 41 # AA, USB Serial Terminal Lite to Bar Code Scanner, then in the same way I want it in my application. I tried with the commands given in # 55 # 30 # 41 # aa, 0x55, 0x30, 0x41, 0xAA documents. But they do not work. I think I'm missing a special order that will trigger the bar code scanner. I am posting some code here.

  PL2303 driver marsial; Private static final string ACTION_USB_PERMISSION = "com.prolific.pl2303hxdsimpletest.USB_PERMISSION"; MSerial = new PL2303 driver ((UsbManager) getSystemService (event .USB_SERVICE), this, ACTION_USB_PERMISSION);  

Read the code for the method:

  Private Zero ReadDataForcereal () {int len; Byte [] rbf = new byte [4096]; Stringbuffer sbHex = new stringbuffer (); Log D. (Tag, "enter readDataFromSerial"); If return (empty == mSerial); If (! MSerial.isConnected ()) return; Len = mSerial.read (rbuf); If (lane and lieutenant; 0) {log d. (Tag, "Bulk transfers (read data) fail"); Return; } If (lane> 0) {if (SHOW_DEBUG) {log d. (Tag, "lane written:" + lane); } For (int j = 0; j and lt; lan; j ++) {sbHex.append (four) (rbf [ja] and 0x000000 ff); } EtRead.setText (sbHex.toString ()); Toast. Make text (this, "LAN =" + Lane, Toast. LNNGHORART) Show (); } And {if (SHOW_DEBUG) {log d. (Tag, read "Lane: 0"); } EtRead.setText ("blank"); Return; } Try {Thread.sleep (50); } Grip (Interrupted e) e.printStackTrace (); } Log D. (Tag, "Skip Reading Data Fractional"); }  

Type the code method:

  Private Zero WriteDatatocryial () {log D. (Tag, "Write Tattacirial"); If return (empty == mSerial); If (! MSerial.isConnected ()) return; String strWrite = etWrite.getText () ToString (); // if (SHOW_DEBUG) {log d. (TAG, "Type the PL2303 driver (" + strWrite.length (+ + + "):" + Stratitude); } Int res = mSerial.write (strWrite.getBytes (), strWrite.length ()); If (RSS & lt; 0) {Log D. (Tag, "Setup: Failed to control transfer:" + res); Return; } Toast. Make text (this, "Written Length:" + strWrite.length () + "Bytes", Toast .LENGTH_SHORT). Show (); If (SHOW_DEBUG) {log d. (Tag, "PL 2303 Drivers Write 2 (" + strWrite.length (+ + "):" + Stratitude); } Log D. (Tag, "leave writing tattoosreal"); }  

Please help.

OK. The question of myself.I was remembering the command that the LED of the scanner is flashing.I have been able to achieve this. In addition, the following things need to be done:

BOD Rate: 9600 Data bits:

Parity: None

Turn off Bit: 1

pl2303driver.jar is really useful here.


Comments

Popular posts from this blog

eclipse plugin - Run java code error: Workspace is closed -

ios - How do I use CFArrayRef in Swift? -

scala - Play Framework - how to bind form to a session field -