Skip to main content
Associate II
April 30, 2025
Question

Help with host USB Printer Class

  • April 30, 2025
  • 2 replies
  • 938 views

Hi,
I know this question have been asked many times but i still can find a solid answer that can really help.
I will try to ask again depends on the progress i have made and i hope if someone made this class that he could help.
My objective is to be able to print 1 label using stm32f407 and a label printer from brother just to check the feasibility of this usb host and printer setup, so i just wanted to create usb host CDC project and adopt it to work with printer, ST community recommended this approach or use MSC.
what did few changes on the usbh_cdc source and header files like this:

/*Communication Class codes*/
#define USB_CDC_CLASS 0x07U
#define COMMUNICATION_INTERFACE_CLASS_CODE 0x07U

/*Data Interface Class Codes*/
#define DATA_INTERFACE_CLASS_CODE 0x07U

/*Communication sub class codes*/
#define RESERVED 0xFFU
#define DIRECT_LINE_CONTROL_MODEL 0x01U
#define ABSTRACT_CONTROL_MODEL 0xFFU
#define TELEPHONE_CONTROL_MODEL 0x03U
#define MULTICHANNEL_CONTROL_MODEL 0x04U
#define CAPI_CONTROL_MODEL 0x05U
#define ETHERNET_NETWORKING_CONTROL_MODEL 0x06U
#define ATM_NETWORKING_CONTROL_MODEL 0x07U

/*Communication Interface Class Control Protocol Codes*/
#define NO_CLASS_SPECIFIC_PROTOCOL_CODE 0xFFU
#define COMMON_AT_COMMAND 0xFFU
#define VENDOR_SPECIFIC 0xFFU

Printer class is 0x07 and also changed many values to 0xFF because i don't know the exact value and i wanted to let the library to check all possibilities.
In the source file (usbh_cdc.c) i had to remove a lot of condition to make it work since in printer i don t have the same check or requirement like in normal CDC condition or device.
doing this i was able to display all informations about the printer, like the model, serial number, class id, subclass id, protocol and since i set the debug level to 3 i can see that class is started and device is activated.

in main i check if the Application is read, if yes, i use cdc transmit function to send messages.
but in the printer side nothing is happening.
i used the same command lines with a PC (c code) and it works.

maybe I'm missing setps or other configurations, maybe i did something wrong with configuration or the changes on the cdc class,

I will appreciate any advice or help.


Best regards

2 replies

Pavel A.
Super User
April 30, 2025

Host printer class is available in USBX: https://github.com/STMicroelectronics/stm32-mw-usbx/blob/main/common/usbx_host_classes/inc/ux_host_class_printer.h

USBX can be used together with ThreadX or "bare metal".  Good luck!

 

H_DrxAuthor
Associate II
April 30, 2025

Hi @Pavel A. 
Thank you for you replay, i will give it a try and i will back to leave a feedback.

Technical Moderator
May 2, 2025

Hi @H_Drx 

The following post maybe helpful as well.

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.Best regards,FBL