erpc over USB_CDC
Hello,
Does the latest erpc support USB_CDC now?
I am trying to add erpc to my application. My server-side application runs on STM32 with FreeRTOS. Now it contains USB_CDC middleware and exports a Virtual Port to the PC. I focus on the server-side application now.
According to the Porting Guide, I choose the erpc_port_freertos.* and change the erpc_config.h. Here is the episode from my CMakeList.txt:
file(GLOB_RECURSE SOURCES "startup/*.*" "Middlewares/*.*" "Drivers/*.*" "USB_DEVICE/*.*" "Core/*.*"
"Communication/*.*"
"autogen/*.*"
"erpc/erpc_c/config/*.*"
"erpc/erpc_c/setup/erpc_setup_usb_cdc.*"
"erpc/erpc_c/setup/erpc_server_setup.*"
"erpc/erpc_c/setup/erpc_client_setup.*"
"erpc/erpc_c/transport/erpc_usb_cdc_transport.*"
"erpc/erpc_c/transport/erpc_serial_transport.*"
"erpc/erpc_c/port/erpc_serial.*"
"erpc/erpc_c/port/erpc_port_freertos.cpp"
"erpc/erpc_c/port/erpc_setup_extensions_freertos.cpp"
"erpc/erpc_c/port/erpc_threading_freertos.cpp"
)
I received a compiling error:
In file included from /home/birdman/FOC/erpc/erpc_c/setup/erpc_setup_usb_cdc.cpp:12:
/home/birdman/FOC/erpc/erpc_c/transports/erpc_usb_cdc_transport.hpp:21:10: fatal error: fsl_component_serial_manager.h: No such file or directory
21 | #include "fsl_component_serial_manager.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/FOC.elf.dir/build.make:843: CMakeFiles/FOC.elf.dir/erpc/erpc_c/setup/erpc_setup_usb_cdc.cpp.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/birdman/FOC/erpc/erpc_c/port/erpc_serial.h:50,
from /home/birdman/FOC/erpc/erpc_c/port/erpc_serial.cpp:39:
/usr/include/newlib/termios.h:4:10: fatal error: sys/termios.h: No such file or directory
4 | #include <sys/termios.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/FOC.elf.dir/build.make:778: CMakeFiles/FOC.elf.dir/erpc/erpc_c/port/erpc_serial.cpp.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/FOC.elf.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
What am I missing? Does modification of erpc_erpc_usb_cdc_transport.* required?
I am new to this. Can anyone help?
Thank you.
Steps you didn't forgot to do
- [x] I checked if there is no related issue opened/closed.
- [x] I checked that there doesn't exist opened/closed PR which is solving this issue.
- [x] I looked in documentation if there is related information.
Hi eRPC user. Thank you for your interest and welcome. We hope you will enjoy this framework well.
Based on your output you are missing Linux or NXP SDK dependencies. It means there is no port for STM32 and you should do it on your own if you want it. If you provide PR in that case we will appretiate it.
Depends on which driver you want to use on STM32 (if there is something already existing and can ported here, or you need create also driver by your self.)
fsl_serial is only for Windows, Linux and Apple currently:

Based on your output you are missing Linux or NXP SDK dependencies. It means there is no port for STM32 and you should do it on your own if you want it. If you provide PR in that case we will appretiate it.
Depends on which driver you want to use on STM32 (if there is something already existing and can ported here, or you need create also driver by your self.)
I really love to do this kind of work and create a PR. What I can think of that needs to be modified is to implement SerialManager_* kind functions based on STM32 provided APIs. Or Reimplement UsbCdcTransport::underlyingReceive, UsbCdcTransport::underlyingSend, UsbCdcTransport::init based on STM32 APIs.
Please correct me if I am wrong. And hoping for detail instructions.
@Second222None Looking forward for you PR ;) If you would like to use just simple serial on board with freertos you can take a look to erpc_uart_cmsis_transport.hpp If you want to use this CDC feature you need modify header and source file for CDC erpc_usb_cdc_transport.hpp erpc_usb_cdc_transport.cpp
Likely you need modify API for your case. Maybe the port can be inspired by existing thread ports in port directory. serial files can be removed from your project for STM as you don't need them
Hi @Second222None , you are right. As you wrote transport for C you need add transport for Python. Then they should be able to communicate. Python is less supported as C so there can be some issue in generated shim code. But most of cases should pass without issue.
Thank you! @Hadatko Got it. And sorry for delete my reply as the internet connection is not very well. I have solve the problem on client side. I receive the Resource Busy Error. Maybe there some issue on my server side.
eRPC request is sent to the server
Traceback (most recent call last):
File "matrix_multiply.py", line 167, in <module>
runClient(transport)
File "matrix_multiply.py", line 121, in runClient
client.erpcMatrixMultiply(matrix1, matrix2, resultMatrix)
File "/root/FOC/erpc/examples/matrix_multiply_tcp_python/service/erpc_matrix_multiply/client.py", line 49, in erpcMatrixMultiply
self._clientManager.perform_request(request)
File "/usr/local/lib/python3.8/dist-packages/erpc-1.9.1-py3.8.egg/erpc/client.py", line 64, in perform_request
File "/usr/local/lib/python3.8/dist-packages/erpc-1.9.1-py3.8.egg/erpc/transport.py", line 78, in send
File "/usr/local/lib/python3.8/dist-packages/erpc-1.9.1-py3.8.egg/erpc/transport.py", line 117, in _base_send
File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 986, in write
intf, ep = self._ctx.setup_request(self, endpoint)
File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 113, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 229, in setup_request
self.managed_claim_interface(device, intf)
File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 113, in wrapper
return f(self, *args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/usb/core.py", line 178, in managed_claim_interface
self.backend.claim_interface(self.handle, i)
File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 829, in claim_interface
_check(self.lib.libusb_claim_interface(dev_handle.handle, intf))
File "/usr/local/lib/python3.8/dist-packages/usb/backend/libusb1.py", line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 16] Resource busy
@Second222None i cannot help. Try solution here: https://stackoverflow.com/questions/67453535/i-keep-getting-usb-core-usberror-errno-16-resource-busy-when-trying-to-read