Sub btnConnect_Click
USBConnect(1,19200)
End Sub
Sub btnPrint_Click
USBPrint
End Sub
Sub USBConnect(USBDevice As Int, USBBaudRate As Int )
If UsbSerial1.UsbPresent(USBDevice) = UsbSerial1.USB_NONE Then ' Ver_2.4
xui.MsgboxAsync("No se encuentra puerto USB", "Aviso")
Return
End If
If (UsbSerial1.HasPermission(USBDevice)) Then ' Ver_2.4
xui.MsgboxAsync(UsbSerial1.DeviceInfo(USBDevice),"DeviceInfo")
' UsbSerial1.SetCustomDevice(UsbSerial1.DRIVER_SILABS, 0xFE6, 0x811E)
' UsbSerial1.SetCustomDevice(UsbSerial1.DRIVER_SILABS, 4070, 33054)
If Not (UsbSerial1.Open(USBBaudRate, USBDevice) = UsbSerial1.USB_NONE) Then
AStreams1.Initialize(UsbSerial1.GetInputStream, UsbSerial1.GetOutputStream, "astreams1")
UsbSerial1.SetParameters(USBBaudRate, UsbSerial1.DATABITS_8, UsbSerial1.STOPBITS_1, UsbSerial1.PARITY_NONE)
Else
xui.MsgboxAsync("Error opening USB port","Error")
End If
Else
UsbSerial1.RequestPermission(USBDevice) ' Ver_2.4
End If
End Sub
Sub USBPrint
Dim PrintWrite As String
' Resetear la impresora
PrintWrite = Chr(27) & Chr(64)
' Fecha y Hora
PrintWrite = PrintWrite & "TODAY: " & DateTime.Date(DateTime.Now) & CRLF
' Imprimir
AStreams1.Write(PrintWrite.GetBytes("ISO-8859-9")) 'o UTF-8
AStreams1.Close
End Sub