Home > database >  Send instruction to the USB port
Send instruction to the USB port

Time:09-20

In the case of not install driver, how to transmit POS/ESC instruction to USB port?

The premise is not to drive, write USB port directly, hope ace directions

CodePudding user response:

Used createfile to open the serial port for data reading and writing, usb should also can

Please refer to the following link
http://www.docin.com/p-63912601.html

CodePudding user response:

Please refer to open a serial port example with createfile

//open port
Iu_file=CreateFileA (ls_com, 3221225472, 0, 0, 3, 128, 0)
If (iu_file & lt; 0) then
Gnv_app. Of_message (" unable to open "+ ls_com +" # "+ string (getlasterror ()), StopSign!)
If PortOpen then closehandle (iu_file)
PortOpen=false
Return PortOpen
End the if

//initialize the DCB
If (Not BuildCommDcbA (ls_commset lst_dcb)) then
Gnv_app. Of_message (" unable to create DCB "+" # "+ string (getlasterror ()), StopSign!)
If PortOpen then closehandle (iu_file)
PortOpen=false
Return PortOpen
End the if

//set port
If (Not setcommstate (iu_file lst_dcb)) then
Gnv_app. Of_message (" unable to set port "+ ls_com +" # "+ string (getlasterror ()), StopSign!)
If PortOpen then closehandle (iu_file)
PortOpen=false
Return PortOpen
End the if

//set the timeout
Commtimeouts lst_to
Lst_to. Readintervaltimeout=4294967295//MAXDWORD
//lst_to readtotaltimeoutconstant=60000
//lst_to readtotaltimeoutmultiplier=10
SetCommTimeouts (iu_file lst_to)
CommError=0

Return PortOpen

CodePudding user response:

I just want to use FileWrite write port, no problem, wrote before the COM now need to write just don't know how to make the USB port

Preliminary understanding as PB make uncertain, may need to use VC or other language?

CodePudding user response:

Call the API should be able to solve

CodePudding user response:

Is there any which old assembly?

It seems the problem have higher difficulty (or remote), to solve the set to open 200 points, is not enough to say grateful of a drop in the bucket

CodePudding user response:

No, if you install a usb com driver, then use your com directly before, speaking, reading and writing

CodePudding user response:

Thank LZP reply, but substitute driving for instruction, just returned to the problem: (

Recently put this problem aside, ready to say
after Spring FestivalSeems to need to use VC to handle? Use VC for a long time, be flexible enumeration to a USB device, as the use of VC in also very troublesome
Still want an experienced player can provide examples

CodePudding user response:

I don't drive, is the purpose of reducing the operation of the terminal customers, more can't depend on a particular manufacturer of driver

CodePudding user response:

I may want to know how to deal with

CodePudding user response:

FileOpen (" PRN "/* USB port, such as \ \ server \ HP also go */, linemode! The write! , lockwrite! The replace!
FileWrite (li_filename ls_PrtStr)
FileClose (li_filename)
Li_filename is directive

CodePudding user response:

After another wall bumps bumps

CodePudding user response:

Upstairs someone said, usb com port driver, usb is a serial port, so use drive to it for a com name should be ok

CodePudding user response:

Are posted, forget this didn't solve
Thank you for your participation, see have points!

CodePudding user response:

Put up for a long time, although not solve, thank you for your participation, see have points!

CodePudding user response:

references to the tenth floor gmb_1984 response:
FileOpen (PRN/* USB port, such as \ \ server \ HP also go */, linemode! The write! , lockwrite! The replace!
FileWrite (li_filename ls_PrtStr)
FileClose (li_filename)
Li_filename is directive

Use the output directly to the port to try,

CodePudding user response:

Li_FileNum=FileOpen (ls_port LineMode! The Write! , LockWrite! , Append!)
FileWrite (li_FileNum, 'instructions')
FileClose (li_FileNum)
Ls_port is a serial port LPT port can be, but not USB port, to solve

CodePudding user response:

Someone and you ask the same question, seems U must install driver, you can put the driver installed in your installation file to start automatically, in addition, each manufacturer's instruction set for U mouth POS printer may not be as well, so do not rely on a certain manufacturer driver is what doesn't make sense, MARK, does anyone know if good came back to see, hey hey,

CodePudding user response:

Top, please upload information
  • Related