如需转载请标明出处:http://blog.csdn.net/itas109
技术交流:129518033
环境:
系统:Ubuntu 20.04
linux内核版本:5.15.0
CH340版本:CH340G
CH340 linux驱动版本:1.5 (2018-03-18)
CH340系列USB转串口芯片是南京沁恒微电子股份有限公司的一款国产芯片,其价格和稳定性都非常不错。其驱动也支持windows、linux、macos和android等系统。
https://www.wch.cn/download/CH341SER_LINUX_ZIP.html
CH340系列USB转串口LINUX驱动程序,支持CH340G,CH340T,CH340C,CH340N, CH340K, CH340E,CH340B,CH341A,CH341F, CH341T,CH341B,CH341C,CH341U等。
#include
// wait_queue_t wait;
---
ch34x.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ch34x.c b/ch34x.c
index 2fcf7f0..95d8acf 100644
--- a/ch34x.c
+++ b/ch34x.c
@@ -30,7 +30,7 @@
//#include
#include
#include
-
+#include
#define DRIVER_DESC "WCH CH34x USB to serial adaptor driver"
#define DRIVER_AUTHOR ""
@@ -588,7 +588,7 @@ static void ch34x_close( struct usb_serial_port *port,
unsigned int c_cflag;
int bps;
long timeout;
- wait_queue_t wait;
+ // wait_queue_t wait;
#if(LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0))
dbg_ch34x("%s - port:%d", __func__, port->number);
@@ -935,7 +935,7 @@ static int ch34x_write( struct usb_serial_port *port,
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
-static int ch34x_write_room( struct tty_struct *tty )
+static unsigned int ch34x_write_room( struct tty_struct *tty )
{
struct usb_serial_port *port = tty->driver_data;
#else
@@ -961,7 +961,7 @@ static int ch34x_write_room( struct usb_serial_port *port )
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
-static int ch34x_chars_in_buffer( struct tty_struct *tty )
+static unsigned int ch34x_chars_in_buffer( struct tty_struct *tty )
{
struct usb_serial_port *port = tty->driver_data;
#else
--
$ make
make -C /lib/modules/5.15.0-52-generic/build M=/home/dev/CH341SER_LINUX
make[1]: 进入目录“/usr/src/linux-headers-5.15.0-52-generic”
CC [M] /home/dev/CH341SER_LINUX/ch34x.o
MODPOST /home/dev/CH341SER_LINUX/Module.symvers
CC [M] /home/dev/CH341SER_LINUX/ch34x.mod.o
LD [M] /home/dev/CH341SER_LINUX/ch34x.ko
BTF [M] /home/dev/CH341SER_LINUX/ch34x.ko
Skipping BTF generation for /home/dev/CH341SER_LINUX/ch34x.ko due to unavailability of vmlinux
make[1]: 离开目录“/usr/src/linux-headers-5.15.0-52-generic”
$ ls
ch34x.c ch34x.mod ch34x.mod.o Makefile Module.symvers
ch34x.ko ch34x.mod.c ch34x.o modules.order readme.txt
sudo make load
sudo cp ch34x.ko /lib/modules/`uname -r`/kernel/drivers/usb/serial
sudo depmod
$ lsusb
Bus 002 Device 008: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter
...
$ ./CSerialPortDemoNoGui
Version: https://github.com/itas109/CSerialPort - V4.2.1.221107
availableFriendlyPorts:
1 - /dev/ttyUSB0
2 - /dev/ttyS0
Please Input The Index Of Port(1 - 2)
1
Port Name: /dev/ttyUSB0
Open /dev/ttyUSB0 Success
/dev/ttyUSB0 - Count: 1, Length: 12, Str: 12345itas109, Hex: 0x31 0x32 0x33 0x34 0x35 0x69 0x74 0x61 0x73 0x31 0x30 0x39
/dev/ttyUSB0 - Count: 2, Length: 12, Str: 12345itas109, Hex: 0x31 0x32 0x33 0x34 0x35 0x69 0x74 0x61 0x73 0x31 0x30 0x39
/dev/ttyUSB0 - Count: 3, Length: 12, Str: 12345itas109, Hex: 0x31 0x32 0x33 0x34 0x35 0x69 0x74 0x61 0x73 0x31 0x30 0x39
...
License
License under CC BY-NC-ND 4.0: 署名-非商业使用-禁止演绎
如需转载请标明出处:http://blog.csdn.net/itas109
技术交流:129518033
Reference:
1.https://www.wch.cn/product/CH340.html