This library wraps the following open source project: https://github.com/felHR85/UsbSerial (MIT license).
It is an alternative to the UsbSerial2 library.
The following devices are supported: CP210x, CDC, FTDI, PL2303 and CH34x.
Usage is simple. You find the UsbDevice with USB library and then initialize felUsbSerial, configure it and start reading.
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
SetFlowControl is only implemented for CP2102, FTDI and CH34x chips.
Updates
V1.12 - BUFFER_READ_SIZE / BUFFER_WRITE_SIZE fields. Default value is 16 * 1024. You can change these values before initializing the object to change the internal buffers sizes.
			
			It is an alternative to the UsbSerial2 library.
The following devices are supported: CP210x, CDC, FTDI, PL2303 and CH34x.
Usage is simple. You find the UsbDevice with USB library and then initialize felUsbSerial, configure it and start reading.
			
				B4X:
			
		
		
		Sub Process_Globals
   Private usbserial As felUsbSerial
   Private manager As UsbManager
   Private bc As ByteConverter
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
     manager.Initialize
   End If
   Dim btnConnect As Button
   btnConnect.Initialize("btnConnect")
   btnConnect.Text = "Connect"
   Activity.AddView(btnConnect, 10dip, 10dip, 100dip, 100dip)
End Sub
Sub btnConnect_Click
   If manager.GetDevices.Length = 0 Then
     Log("No connected usb devices.")
   Else
     Dim device As UsbDevice = manager.GetDevices(0) 'assuming that there is exactly one device
     If manager.HasPermission(device) = False Then
       ToastMessageShow("Please allow connection and click again.", True)
       manager.RequestPermission(device)
     Else
       usbserial.Initialize("serial", device, -1)
       usbserial.BaudRate = 115200
       usbserial.DataBits = usbserial.DATA_BITS_8
       usbserial.StartReading
     End If
   End If
End Sub
Private Sub serial_DataAvailable (Buffer() As Byte)
   Log("New data: " & bc.HexFromBytes(Buffer))
End SubSetFlowControl is only implemented for CP2102, FTDI and CH34x chips.
Updates
V1.12 - BUFFER_READ_SIZE / BUFFER_WRITE_SIZE fields. Default value is 16 * 1024. You can change these values before initializing the object to change the internal buffers sizes.
Attachments
			
				Last edited: 
			
		
	
							 
				 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		