2024-03-31 11:09 AM
Hi ST Support Team,
I am reaching out regarding an issue I have encountered while attempting to utilize USB CCID functionality on the STM32WB55 MCU. Recently, I integrated the CCID driver from the following link into my project.
https://github.com/STMicroelectronics/stm32_mw_usb_device/tree/master/Class/CCID
Following the integration, I successfully configured the USB device, and my system(windows PC) can now detect the STM32WB MCU as a smart card reader.
However, upon further testing, I encountered an unexpected behavior: when attempting to communicate with the smart card reader using a Python script, the STM32WB USB port is detected as a Virtual COM port rather than a smart card reader. As a result, I am unable to establish communication with the MCU via script.
I am reaching out to kindly request your assistance in resolving this issue. Could you please provide guidance or solutions to ensure that the STM32WB MCU is correctly detected as a smart card reader and able to communicate with application?
Any support or insights you can provide on this matter would be immensely appreciated.
Thank you for your attention to this matter.
Best regards,
sjain
Solved! Go to Solution.
2024-04-03 04:10 AM
Hello @Sjain
"Cannot Unpack Non-iterable NoneType Object" error in Python is not directly related to STM32 USB functionality. The error is specific to Python. Your question was about USB port detected as VCP when using Python script!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-03-31 04:27 PM
Hi @Sjain , you can try with USBX middleware (AzureRTOS) it support CCID Class in baremetal and RTOS (Threadx)
you can flow the example delivred with STM32H723
BR
2024-04-02 05:34 AM
Hello @Sjain
Sharing you python script would be helpful to investigate. I guess this issue depends on pyusb library. Maybe these examples STMicroelectronics/stm32ai-datalogger at 0ba92ced44248e606a5cc68139fdfdc84489fa17 (github.com) could be helpful.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2024-04-02 12:31 PM
Thanks @Mohamed_AYED and @FBL for the reply.
I just wanted to give you and update that on python script my device able to detect as smart card reader but after that no communication happen. I'm sharing the python script here which I used for my testing.
from smartcard.System import readers
from smartcard.scard import SCARD_PROTOCOL_T0
from smartcard.CardConnection import CardConnection
from smartcard.Exceptions import CardConnectionException
def test_apdu_command(apdu_command):
try:
# Get a list of available smartcard readers
reader_list = readers()
if reader_list:
print("Smartcard reader(s) detected:")
for reader in reader_list:
print(reader)
# Create a connection to the reader
card_connection = CardConnection(reader)
# Connect to the card
try:
card_connection.connect()
print("Connected to smart card successfully.")
# Send the APDU command to the card
response, sw1, sw2 = card_connection.transmit(apdu_command)
# Print the response
print("Response:", response)
print("Status words:", sw1, sw2)
except CardConnectionException as e:
print("Error connecting to smartcard:", e)
finally:
# Disconnect from the card
card_connection.disconnect()
print("Disconnected from smart card.")
else:
print("No smartcard readers detected.")
except Exception as e:
print("Error:", e)
if __name__ == "__main__":
# Example APDU command (SELECT command)
# You can replace this with any other APDU command you want to test
apdu_command = [0x00, 0xA4, 0x04, 0x00, 0x00] # SELECT command for the master file
test_apdu_command(apdu_command)
After run the script I received the response of connected to smart card and name is also correct. But after that no data received on STM32WB55 MCU configured as smart card reader.
"Error: cannot unpack non-iterable NoneType object" is occurred because no response received from device.
I'm confused because on connection request and transmit data no event generated on MCU.
Can you please suggest where I'm doing wrong ? CCID is new for me so not having much information about it.
Any support you provide will really helpful to me.
Thanks,
SJain
2024-04-03 04:10 AM
Hello @Sjain
"Cannot Unpack Non-iterable NoneType Object" error in Python is not directly related to STM32 USB functionality. The error is specific to Python. Your question was about USB port detected as VCP when using Python script!
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.