Bulk transfer of Data via USB (Host side)

Hi everyone,

I am using a LM3S5951 controllers for one of my projects in which I need to implement a host side driver for Dot Matrix printer .

I am done with enumeration of the printer, but now I would like to know how can I send data to printers using bulk transfers. I am using the Stellaries USB Library for the same where I found some host side codes for keyboard and pendrive. I would like to know, how to go about this.

Regards

Dhanush

Parents Reply
  • GET_PORT_STATUS class-specific request retrieves printer status, including Paper Empty.

    USB Printing Device Class spec
    www.usb.org/.../usbprint11a021811.pdf
    4.2.2 GET_PORT_STATUS (bRequest = 1) (page 7)
    This class-specific request returns the printer's current status, in a format which is compatible with the status register of a standard PC parallel port.

    Bit(s) Field Description
    7..6  Reserved;      Reserved for future use; device shall return these bits reset to zero.
     5    Paper Empty;   1 = Paper Empty, 0 = Paper Not Empty
     4    Select;        1 = Selected,    0 = Not Selected
     3    Not Error;     1 = No Error,    0 = Error
    2..0  Reserved;      Reserved for future use; device shall return these bits reset to zero.
    

    This request is carried over Control Transfer. The implementation is,

    unsigned long
    GetPortStatus(unsigned long ulInstance, unsigned long ulInterface)
    {
    
    #define PRN_GET_PORT_STATUS   0x01
    
        unsigned long        ulStatus   = 0;
        tUSBHostPRNInstance *pPRNDevice = (tUSBHostPRNInstance *)ulInstance;
        tUSBRequest          SetupPacket;
    
        SetupPacket.bmRequestType = USB_RTYPE_DIR_IN | USB_RTYPE_CLASS | USB_RTYPE_INTERFACE;
        SetupPacket.bRequest      = PRN_GET_PORT_STATUS;
        SetupPacket.wValue        = 0x0000;
        SetupPacket.wIndex        = (unsigned short)ulInterface;    // interface number
        SetupPacket.wLength       = 0x01;                           // one-byte status returns
    
        USBHCDControlTransfer(0, &SetupPacket, pPRNDevice->pDevice,
                              (unsigned char *)&ulStatus, sizeof(ulStatus),
                              pPRNDevice->pDevice->DeviceDescriptor.bMaxPacketSize0);
        return(ulStatus);
    }
    

    To poll the printer status, your firmware regularly calls GetPortStatus() in every 100ms or so.

    unsigned long ulStatus = GetPortStatus( g_USBHPRNDevice.pDevice, g_USBHPRNDevice.pDevice->ulInterface );
    

    Tsuneo

Children
More questions in this forum