- Permission to use, copy, modify, distribute, and sell this
+ Permission to use, copy, modify, distribute, and sell this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
+ permission notice and warranty disclaimer appear in supporting
+ documentation, and that the name of the author not be used in
+ advertising or publicity pertaining to distribution of the
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
uint8_t Printer_GetDeviceID(char* DeviceIDString,
const uint16_t BufferSize)
{
uint8_t Printer_GetDeviceID(char* DeviceIDString,
const uint16_t BufferSize)
{
uint16_t DeviceIDStringLength = 0;
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
uint16_t DeviceIDStringLength = 0;
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.wValue = 0,
.wIndex = PrinterInterfaceNumber,
.wLength = sizeof(DeviceIDStringLength),
};
.wValue = 0,
.wIndex = PrinterInterfaceNumber,
.wLength = sizeof(DeviceIDStringLength),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)
return ErrorCode;
if (!(DeviceIDStringLength))
{
DeviceIDString[0] = 0x00;
return HOST_SENDCONTROL_Successful;
}
if (!(DeviceIDStringLength))
{
DeviceIDString[0] = 0x00;
return HOST_SENDCONTROL_Successful;
}
DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength);
if (DeviceIDStringLength > BufferSize)
DeviceIDStringLength = BufferSize;
USB_ControlRequest.wLength = DeviceIDStringLength;
DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength);
if (DeviceIDStringLength > BufferSize)
DeviceIDStringLength = BufferSize;
USB_ControlRequest.wLength = DeviceIDStringLength;
/* Move string back two characters to remove the string length value from the start of the array */
memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);
DeviceIDString[DeviceIDStringLength - 2] = 0x00;
/* Move string back two characters to remove the string length value from the start of the array */
memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);
DeviceIDString[DeviceIDStringLength - 2] = 0x00;
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
.wValue = 0,
.wIndex = PrinterInterfaceNumber,
.wLength = sizeof(uint8_t),
.wValue = 0,
.wIndex = PrinterInterfaceNumber,
.wLength = sizeof(uint8_t),
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
USB_ControlRequest = (USB_Request_Header_t)
{
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),