本文章介绍了在linux系统下,如何修改usb驱动支持合宙 Air720模块,以及使用Air720进行ppp拨号上网流程
Air720正常启动后,通过USB连接到linux设备上,驱动正常加载后会产生如下设备:
static const struct usb_device_id option_ids[] = {
//+add by airm2m for Air72x
{ USB_DEVICE(0x1286, 0x4e3d) },
//-add by airm2m for Air72x
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_COLT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_LIGHT) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD) },
{ USB_DEVICE(OPTION_VENDOR_ID, OPTION_PRODUCT_RICOLA_QUAD_LIGHT) },
static struct urb *usb_wwan_setup_urb(struct usb_serial_port *port,
int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback) (struct urb *))
{
struct usb_serial *serial = port->serial;
struct urb *urb;
urb = usb_alloc_urb(0, GFP_KERNEL); /* No ISO */
if (!urb)
return NULL;
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
//+add by airm2m for Air72x
if(dir == USB_DIR_OUT){
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if(desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))
{
urb->transfer_flags |= URB_ZERO_PACKET;
}
}
//-add by airm2m for Air72x
return urb;
}
static struct urb *option_setup_urb(struct usb_serial *serial, int endpoint,
int dir, void *ctx, char *buf, int len,
void (*callback)(struct urb *))
{
......
/* Fill URB using supplied data. */
usb_fill_bulk_urb(urb, serial->dev,
usb_sndbulkpipe(serial->dev, endpoint) | dir,
buf, len, callback, ctx);
//+add by airm2m for Air72x
if(dir == USB_DIR_OUT)
{
struct usb_device_descriptor *desc = &serial->dev->descriptor;
if(desc->idVendor == cpu_to_le16(0x1286) && desc->idProduct == cpu_to_le16(0x4e3d))
{
urb->transfer_flags |= URB_ZERO_PACKET;
}
}
//-add by airm2m for Air72x
return urb;
}
static struct usb_serial_driver option_1port_device = {
.driver = {
.owner = THIS_MODULE,
.name = "option1",
},
....
#ifdef CONFIG_PM
.suspend = usb_wwan_suspend,
.resume = usb_wwan_resume,//+add by airm2m for Air720#endif
.reset_resume = usb_wwan_resume,
//-add by airm2m for Air720
};
/* Driver structure we register with the USB core */
static struct usb_driver usb_serial_driver = {
.name ="usbserial",
.probe =usb_serial_probe,
.disconnect =usb_serial_disconnect,
.suspend =usb_serial_suspend,
.resume =usb_serial_resume,
//+add by airm2m for Air72x
.reset_resume = usb_serial_resume,
//-add by airm2m for Air72x
.no_dynamic_id = 1,
};
cd <your kernel directory>
make menuconfig
[*] Device Drivers →
[*] USB Support →
[*] USB Serial Converter support →
[*] USB driver for GSM and CDMA modems
[*] Device Drivers →
[*] Network device support →
[*] PPP (point-to-point protocol) support
make
二、模块测试
debug nodetach dump /dev/ttyUSB1 115200 nolock nocrtscts modem hide-password novj novjccomp ipcp-accept-local ipcp-accept-remote noipdefault usepeerdns noccp connect 'chat -s -v -f /etc/ppp/peers/air-chat-connect' disconnect 'chat -s -v -f /etc/ppp/peers/air-chat-disconnect'
ABORT "NO CARRIER" ABORT "NO DIALTONE" ABORT "NO ANSWER" ABORT "BUSY" ABORT "Username/Password Incorrect" "" AT OK-+++-OK ATH0 OK AT+CREG? OK AT+CPIN? OK AT+CESQ OK ATD*99# CONNECT ""
ABORT "ERROR" ABORT "NO DIALTONE" SAY "\nSending break to the modem\n" "" "\K" "" "+++ATH0" SAY "\nGood bay\n"
# pppd call air-ppp &
此时通过ifconfig命令查看网卡就有一个ppp0网卡出现,这时可以禁用其他网卡,就可以用Air720模块连接到互联网了。
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!