Przeglądaj źródła

fix(serial): add default handler for gsm

Signed-off-by: sakumisu <1203593632@qq.com>
sakumisu 3 tygodni temu
rodzic
commit
3f23af5ad7
2 zmienionych plików z 14 dodań i 4 usunięć
  1. 12 2
      class/serial/usbh_gsm.c
  2. 2 2
      class/serial/usbh_serial.c

+ 12 - 2
class/serial/usbh_gsm.c

@@ -63,6 +63,16 @@ static void usbh_gsm_detach(struct usbh_serial *serial)
     usb_osal_free(gsm_class);
 }
 
+static int usbh_gsm_set_line_coding(struct usbh_serial *serial, struct cdc_line_coding *line_coding)
+{
+    return 0;
+}
+
+static int usbh_gsm_set_line_state(struct usbh_serial *serial, bool dtr, bool rts)
+{
+    return 0;
+}
+
 static const struct usbh_serial_driver gsm_driver = {
     .driver_name = "gsm",
 
@@ -72,9 +82,9 @@ static const struct usbh_serial_driver gsm_driver = {
     .attach = usbh_gsm_attach,
     .detach = usbh_gsm_detach,
     .set_flow_control = NULL,
-    .set_line_coding = NULL,
+    .set_line_coding = usbh_gsm_set_line_coding,
     .get_line_coding = NULL,
-    .set_line_state = NULL,
+    .set_line_state = usbh_gsm_set_line_state,
     .get_modem_status = NULL,
 };
 

+ 2 - 2
class/serial/usbh_serial.c

@@ -584,7 +584,7 @@ int usbh_serial_cdc_write_async(struct usbh_serial *serial, uint8_t *buffer, uin
         return -USB_ERR_INVAL;
     }
 
-    if (serial->ref_count > 0) {
+    if (serial->ref_count == 0) {
         return -USB_ERR_NODEV;
     }
 
@@ -603,7 +603,7 @@ int usbh_serial_cdc_read_async(struct usbh_serial *serial, uint8_t *buffer, uint
         return -USB_ERR_INVAL;
     }
 
-    if (serial->ref_count > 0) {
+    if (serial->ref_count == 0) {
         return -USB_ERR_NODEV;
     }