We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello Sir,
I am making a receipt printer for point of sale application using LPC2368 controller. I want to use USB interface for receiving data from computer to printer.I am using bulk transfer for data receiving and sending data. I started using Keil USB HID source code example and converted this source code for bulk transfer using following changes in configuration descriptor and few other changes
const UWORD8 USB_ConfigDescriptor[] = { /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ 1*USB_CONFIGUARTION_DESC_SIZE + 1*USB_INTERFACE_DESC_SIZE + 2*USB_ENDPOINT_DESC_SIZE ), 0x01, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */ /*USB_CONFIG_REMOTE_WAKEUP*/, USB_CONFIG_POWER_MA(100), /* bMaxPower */ /* Interface 0, Alternate Setting 0, MSC Class */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x02, /* bNumEndpoints */ USB_DEVICE_CLASS_PRINTER, /* bInterfaceClass */ 0x01, /* bInterfaceSubClass */ 0x02, /* bInterfaceProtocol */ 0x62, /* iInterface */ /* Bulk In Endpoint */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_IN(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(0x0040), /* wMaxPacketSize */ 0, /* bInterval */ /* Bulk Out Endpoint */ USB_ENDPOINT_DESC_SIZE, /* bLength */ USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ USB_ENDPOINT_OUT(2), /* bEndpointAddress */ USB_ENDPOINT_TYPE_BULK, /* bmAttributes */ WBVAL(0x0040), /* wMaxPacketSize */ 0, /* bInterval */ /* Terminator */ 0 /* bLength */ };
Computer recognize my board usb device as a USB printing support successfully. I just want to know that is there is any class descriptor like HID class descriptor for printer or not?
And also I want to know that Is there is any host application to check bulk out transfer .
Thanks & Regards Rohit
Your printer descriptors seem fine.
> I just want to know that is there is any class descriptor like HID class descriptor for printer or not?
Printer class doesn't have any extra descriptor, unlike HID report descriptor. Instead, GET_DEVICE_ID request returns Printer "Device ID" string, which describes printer's property.
Windows has a default INF file for "Generic" printers. To install your printer silently (ie. without any INF file), apply this Device ID for "Generic Text Only".
typedef struct __attribute__ ((packed)) { BYTE size_h, size_l; BYTE str[]; } T_prn_Device_ID; static const T_prn_Device_ID prn_Device_ID = { 0x00, 12 + 24 + 11 + 12 + 30, // size of string, two-bytes, MSB first { // these strings are concatenated by compiler "MFG:Generic;" // manufacturer (case sensitive) "MDL:Generic_/_Text_Only;" // model (case sensitive) "CMD:1284.4;" // PDL command set "CLS:PRINTER;" // class "DES:Generic text only printer;" // description } };
I posted this tip of USB printer on these forum threads,
USB Printer Class(Client, not Host) - Microchip USB forum " href= "e2e.ti.com/.../217001.aspx"> e2e.ti.com/.../217001.aspx
[USB printer spec] "Printer Device Class Document 1.1" www.usb.org/.../usbprint11.pdf > And also I want to know that Is there is any host application to check bulk out transfer .
Printer port is accessed over WinAPI. - How to send raw data to a printer by using Visual C# .NET support.microsoft.com/.../en-us - HOWTO: Send Raw Data to a Printer by Using the Win32 API support.microsoft.com/.../en-us - How to send raw data to a printer by using Visual Basic .NET support.microsoft.com/.../en-us
Tsuneo
Thanks Sir for your kind support
I need your support i made some changes in software as shown below
void USB_EndPoint0 (UWORD32 event) { //only portion that I changed case REQUEST_CLASS: #if USB_CLASS switch (SetupPacket.bmRequestType.BM.Recipient) { case REQUEST_TO_INTERFACE: #if USB_PRINTER if (SetupPacket.wIndex.WB.L == 0x00){ switch(SetupPacket.bRequest) { case PRNT_GET_DEVICE_ID: EP0Data.pData = (UWORD8 *)&prn_Device_ID; EP0Data.Count = prn_Device_ID.size_l + 2; USB_DataInStage(); break; case PRNT_GET_PORT_STATUS: port_status.b = 0; // initialize status port_status.PRNT_FLAG.prn_not_error = 1; // 1 = No Error, 0 port_status.PRNT_FLAG.prn_select = 1; port_status.PRNT_FLAG.prn_paper_empty = 0; // 1 = Paper Empty, 0 EP0Data.pData = (UWORD8 *)&port_status; EP0Data.Count = 1; USB_DataInStage(); break; case PRNT_SOFT_RESET: USB_ClrStallEP(0x02); USB_ClrStallEP(0x82); break; } } #endif }
When I debug through software I am getting device ID request from PC but not other two request. Second thing i notice that I sent Device ID to PC but when i monitors it on device monitor studio software it is not visible on this software.
What,s the reason for that?
> I am getting device ID request from PC but not other two request.
Windows put just GET_DEVICE_ID on enumeration. Try GetPrinter(PRINTER_INFO_2) and ResetPrinter() on Windows app.
> I sent Device ID to PC but when i monitors it on device monitor studio software it is not visible on this software.
Did you start on this example? C:\Keil\ARM\Boards\Keil\MCB2300\USBHID
case PRNT_GET_DEVICE_ID: EP0Data.pData = (UWORD8 *)&prn_Device_ID; EP0Data.Count = prn_Device_ID.size_l + 2; USB_DataInStage(); goto setup_class_ok; // <----- break; case PRNT_GET_PORT_STATUS: port_status.b = 0; // initialize status port_status.PRNT_FLAG.prn_not_error = 1; // 1 = No Error, 0 port_status.PRNT_FLAG.prn_select = 1; port_status.PRNT_FLAG.prn_paper_empty = 0; // 1 = Paper Empty, 0 EP0Data.pData = (UWORD8 *)&port_status; EP0Data.Count = 1; USB_DataInStage(); goto setup_class_ok; // <----- break; case PRNT_SOFT_RESET: USB_ClrStallEP(0x02); USB_ClrStallEP(0x82); USB_StatusInStage(); // <----- goto setup_class_ok; // <----- break;
Thanks Sir for your reply,
Yes I am using C:\Keil\ARM\Boards\Keil\MCB2300\USBHID .
Rohit
> And also I want to know that Is there is any host application to check bulk out transfer .
USB Trace is a great tool for investigating your USB IN/OUT packets. http://www.sysnucleus.com/
Actually Sir currently I am using USB Device monitor studio For checking IN/OUT packets. Now i will try USB trace.
hi, sir i am using LPC2929 (ARM9), i need LIN protocol sample code on this