Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use all 4 USB Lines of a SIMCOM A7672E-FASE (IEC-74) (IEC-179) #76

Open
diplfranzhoepfinger opened this issue Dec 13, 2023 · 17 comments
Assignees

Comments

@diplfranzhoepfinger
Copy link
Contributor

diplfranzhoepfinger commented Dec 13, 2023

Hello,

@david-cermak
@igrr
@Others

the Example: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem/examples/pppos_client

we use this Line:
https://github.com/espressif/idf-extra-components/blob/86fab3ed9299d09173a5e98fd216aed14f14b6c7/usb/esp_modem_usb_dte/include/esp_modem_usb_config.h#L75

to access Interface 4 and 5 of the SIMCOM A6772-FASE.

it would be interesting to use also Interface 1 and 3 (guessed Numbers [now proofed, see below], but possible to find out):

  • 1- Diagnostic port for log messages
  • 4-AT port for AT commands communication
  • 5-Modem port for PPP dial up
  • 3-NMEA port for GNSS NMEA message output

1 is for the DIAG Server, if we have Problems to Report to SIMCOM we can take Modem Traces there,

3 is for the NMEA Port.

what to do to access the Other Ports as well ?

https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc/cdc_acm_vcp seems not to help, as it does tooo much Driver stuff and all this, we have already a lot inside the above Example.

Thanks,

Franz

@github-actions github-actions bot changed the title How to use all 4 Lines of a SIMCOM A6772-FASE How to use all 4 Lines of a SIMCOM A6772-FASE (IEC-74) Dec 13, 2023
@diplfranzhoepfinger diplfranzhoepfinger changed the title How to use all 4 Lines of a SIMCOM A6772-FASE (IEC-74) How to use all 4 Lines of a SIMCOM A7672E-FASE (IEC-74) Dec 13, 2023
@tore-espressif
Copy link
Collaborator

Hi @diplfranzhoepfinger thanks for issue.

Here's some information that might help you getting started:

  • The rest of the ports (apart from 5-Modem port for PPP dial up) are not strictly related to 'modem' so I assume that they won't be implemented in esp_modem. cc @david-cermak
  • The interface 5-Modem port for PPP dial up, is a different way to open a network connection. Since not all modems offer this interface and we already have implementation with AT commands, we do not plan to implement this
  • The rest of the ports should act as regular COM ports. You can open them using usb_host_cdc_acm (which is also used for the AT interfaces - 4 and 5 in this case)
  • You can open the interface with this function
esp_err_t cdc_acm_host_open_vendor_specific(uint16_t vid, uint16_t pid, uint8_t interface_num, const cdc_acm_host_device_config_t *dev_config, cdc_acm_dev_hdl_t *cdc_hdl_ret);

relevant example is here https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc/cdc_acm_host

https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc/cdc_acm_vcp seems not to help, as it does tooo much Driver stuff and all this, we have already a lot inside the above Example.

This is not the first time that this example confused someone, I'll try to describe better what is this example for. Thanks for the feedback!

@diplfranzhoepfinger
Copy link
Contributor Author

@tore-espressif 

Thanks, we will have a Look.

@tore-espressif
Copy link
Collaborator

@diplfranzhoepfinger Do you any any other inputs on this or can we close?

@rinstrum-franz
Copy link

@tore-espressif i did try, but it chrashes.

i need to deep into this again.
Sorry for slow feedback so far.

i will reopen this issue once i go back into it.

@diplfranzhoepfinger diplfranzhoepfinger changed the title How to use all 4 Lines of a SIMCOM A7672E-FASE (IEC-74) How to use all 4 USB Lines of a SIMCOM A7672E-FASE (IEC-74) Sep 27, 2024
@diplfranzhoepfinger
Copy link
Contributor Author

diplfranzhoepfinger commented Oct 9, 2024

@diplfranzhoepfinger
Copy link
Contributor Author

diplfranzhoepfinger commented Oct 9, 2024

now, using a modified Version of:

https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/cdc/cdc_acm_host

visible here:

https://github.com/diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/blob/feature/USB_third_port_try1/pppos_client/components/nmea_int/usb_cdc_example_main.c

Ports (interface_num)

https://github.com/espressif/idf-extra-components/blob/86fab3ed9299d09173a5e98fd216aed14f14b6c7/usb/esp_modem_usb_dte/include/esp_modem_usb_config.h#L75

we know that Port 4&5 is used for esp_modem

according to SIMCOM the following Ports should be there:

l /dev/ttyUSB0 Diagnostic port for log messages
l /dev/ttyUSB1 AT port for AT commands communication
l /dev/ttyUSB2 Modem port for PPP dial up
l /dev/ttyUSB3 NMEA port for GNSS NMEA message output

probe the other ports:

it seems that Port Number 1 2 3 4 5 are the Valid Port Number. 

4 and 5 are for esp_modem, one the PPP and the other the AT Line. 

Port 0

https://gist.github.com/diplfranzhoepfinger/5695190fbecd22cf8302f167560f2b46

invalid.

Port 1

https://gist.github.com/diplfranzhoepfinger/6af2de2f31c87c309ba316f9168591c9

Port 2

this Port seems to be the diagnostic Data Port. To be approved.

Diagnostic port for log messages

https://gist.github.com/diplfranzhoepfinger/e2af955c576abf2d6f18cbff167f3685

https://gist.github.com/diplfranzhoepfinger/f46aefa394a79bccac215a72eec44a5d

Port 3

https://gist.github.com/diplfranzhoepfinger/463efe69da42cabc4774523f4d20dd8b

NMEA Output

https://gist.github.com/diplfranzhoepfinger/c68f51bac18e09e2ba9c9da9ee4c2051

likely:

NMEA port for GNSS NMEA message output

Port 4

USB interface number of primary AT port

https://gist.github.com/diplfranzhoepfinger/a9eb561d2acf4f2b6e1636bb636c192a

Port 5

USB interface number of secondary AT port

https://gist.github.com/diplfranzhoepfinger/45c1dd8bc8e6dc8ca24ffbce9fc53715

Port 6

https://gist.github.com/diplfranzhoepfinger/d8157748f95df4265bb0c10dfed2bc30

invalid.

@diplfranzhoepfinger
Copy link
Contributor Author

diplfranzhoepfinger commented Oct 9, 2024

next Step:

connect the SIMCOM Kit to a Linux, and testing something:

/dev/ttyUSB0

constantly sending stuff. ...

might be the Diagnostic port for log messages

/dev/ttyUSB1

/dev/ttyUSB2

unable to open

/dev/ttyUSB3

seeems to be a AT Port. 

doe the following:

AT+CGNSSPWR=1
AT+CGNSSTST=1

after this, the Port /dev/ttyUSB4 start to output GPS NMEA sentences. 

/dev/ttyUSB4

this Port sends NMEA Data.

@diplfranzhoepfinger
Copy link
Contributor Author

diplfranzhoepfinger commented Oct 9, 2024

@tore-espressif 

now, i found out Port 3 is the NMEA Port, 

and if i enabled the Modem before (with my Linux) to output NMEA Sentences, 

this Code here: https://github.com/diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/tree/nmea_001

does read NMEA sentences and output it to the Console. 

NOW:

if i uncomment this Line:

https://github.com/diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/blob/731bfb68a805f49bf78e7c7ec85d8b5b184723e2/pppos_client/main/main.c#L16

i get an Error.

https://gist.github.com/diplfranzhoepfinger/b10ab400f3d4c0452113af673f3b8b72

for me this is obvious, as the esp_modem component does call usb_host_install again.

so the idea then would be: let esp-modem first do its Things, and then connect to the Port 3.

i remove the usb_host_install call also the `cdc_acm_host_install`, and try again!

i get this Error:

Code:

https://github.com/diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/tree/nmea_002

Error:

I (31334) USB-CDC: Opening CDC ACM device 0x1E0E:0x9011...
E (31334) cdc_acm: cdc_acm_start(255): Could not claim interface
E (31334) cdc_acm: cdc_acm_host_open(835): 
I (31334) USB-CDC: Failed to open device

assert failed: cdc_acm_host_desc_print cdc_acm_host.c:951 (cdc_hdl)


Backtrace: 0x40375b0e:0x3fc9a660 0x4037a251:0x3fc9a680 0x403815ad:0x3fc9a6a0 0x420164ad:0x3fc9a7c0 0x4200b18d:0x3fc9a7f0 0x4200afdf:0x3fc9a840 0x42072ba3:0x3fc9a860 0x4037abe1:0x3fc9a890
--- 0x40375b0e: panic_abort at /home/franz/esp-idf-v5.3.1/components/esp_system/panic.c:463
0x4037a251: esp_system_abort at /home/franz/esp-idf-v5.3.1/components/esp_system/port/esp_system_chip.c:92
0x403815ad: __assert_func at /home/franz/esp-idf-v5.3.1/components/newlib/assert.c:80
0x420164ad: cdc_acm_host_desc_print at /home/franz/git/franz/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/pppos_client/managed_components/espressif__usb_host_cdc_acm/cdc_acm_host.c:951 (discriminator 1)
0x4200b18d: usb_cdc_example_main at /home/franz/git/franz/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/pppos_client/components/nmea_int/usb_cdc_example_main.c:126
0x4200afdf: app_main at /home/franz/git/franz/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II/pppos_client/main/main.c:18
0x42072ba3: main_task at /home/franz/esp-idf-v5.3.1/components/freertos/app_startup.c:208
0x4037abe1: vPortTaskWrapper at /home/franz/esp-idf-v5.3.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134





ELF file SHA256: 267e6c011

CPU halted.

diplfranzhoepfinger referenced this issue in diplfranzhoepfinger/esp-protocols-tree-master-components-esp_modem-examples-pppos_client-II Oct 9, 2024
@tore-espressif
Copy link
Collaborator

tore-espressif commented Oct 9, 2024

I assume you are using IDF version >5.0 and latest usb_host_cdc_acm driver v2.0.4 https://components.espressif.com/components/espressif/usb_host_cdc_acm/versions/2.0.4

EDIT: CDC-ACM driver v2.0.5 release just now. It fixes some edge cases in device opening, although it should not affect your device and example

The CDC driver opens the CDC interfaces based on the bInterfaceNumber in Configuration descriptor, for your device this can be 0-5.

Interface 0&1:

These 2 interfaces are bound together with Interface Association Descriptor (so they belong to the same USB Function) with USB Class = 0xE0: USB_CLASS_WIRELESS_CONTROLLER. So:

  • Interface 0 is not opened, as it does not contain 2 Bulk endpoints
  • Interface 1 is opened and you can try to use it, but you must know what format the data endpoint have. We do not have and do not plan support for Wireless Controller class

Interfaces 2-5

Seem to be working OK

Interface 6

Does not exist in this device

for me this is obvious, as the esp_modem component does call usb_host_install again.

For usecases when USB host is used for other purposes the communication with esp_modem, you can set this parameter to false

bool install_usb_host; /*!< Flag whether USB Host driver should be installed */

This way you can install USB Host library in you application main and it can be shared with multiple threads

@tore-espressif tore-espressif transferred this issue from espressif/idf-extra-components Oct 9, 2024
@github-actions github-actions bot changed the title How to use all 4 USB Lines of a SIMCOM A7672E-FASE (IEC-74) How to use all 4 USB Lines of a SIMCOM A7672E-FASE (IEC-74) (IEC-179) Oct 9, 2024
@tore-espressif
Copy link
Collaborator

That's really weird... So if you run the example without opening the NMEA port, it works OK?

I'll have to test on HW, meanwhile, if you could find where this call fails, it would help o lot
https://github.com/espressif/esp-usb/blob/master/host/class/cdc/usb_host_cdc_acm/cdc_acm_host.c#L253

@diplfranzhoepfinger
Copy link
Contributor Author

That's really weird... So if you run the example without opening the NMEA port, it works OK?
yes !

I'll have to test on HW, meanwhile, if you could find where this call fails, it would help o lot https://github.com/espressif/esp-usb/blob/master/host/class/cdc/usb_host_cdc_acm/cdc_acm_host.c#L253

what and how should i test ?

the Backtrace is included in the Gist.

@diplfranzhoepfinger
Copy link
Contributor Author

@tore-espressif here you see which parts i used:
#76 (comment)

@tore-espressif
Copy link
Collaborator

tore-espressif commented Oct 11, 2024

@diplfranzhoepfinger OK, I think I got.

ESP32-S3 has 8 USB channels (implemented in HW). The USB Host Library allocates 1 channel per endpoint. 1 endpoint is reserved for EP0, the rest is allocated to endpoints you open. Your device implements 3 endpoints in each interface 3, 4 and 5. So you require (1 + 3x3) = 10 channels. That is why the last interface fails to open.

When we tested multiple CDC interfaces, we only tested with 2, so we never got the problem!

The only feasible way is not to ignore the Interrupt Endpoint of each interface. This endpoint is used for CDC notifications but it is not used in Modem Terminal

ESP_LOGD(TAG, "Ignored USB event %d", event->type);

This will require change in the CDC-ACM driver or even USB Host lib, so it will take some time.

Meanwhile, if you want to hack it yourself, you will have to modify this section so it does not allocate the INTR endpoint (always the first one in your device)
https://github.com/espressif/esp-idf/blob/master/components/usb/usb_host.c#L1297 and then of course do not use that endpoint. However this is not an easy thing to do... just a tip, in case you cannot afford to wait for the fix

EDIT: Easier workaround is to use just one CDC port for modem

ESP_MODEM_DEFAULT_USB_CONFIG(0x1E0E, 0x9011, 4)

This way, the modem would use the same port for data and commands, leaving enough USB channels for the NMEA port

Thank you for all your testing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants