使用SAM E54的打印机示例在USB上写入USB

发布于 2025-01-29 11:25:02 字数 1218 浏览 2 评论 0原文

我试图使用Microchip https://github.com/microchip-mplab-harmony/usb_apps_device/tree/master/master/master/printer_basic#config_9 。我想收到MCU的答案。我想设置一个USB_DEVICE_PRINTER_WRITE。

我决定在app.c中修改代码如下:

case APP_STATE_SCHEDULE_WRITE:

    /* Setup the write */
              
    appData.writeTransferHandle = USB_DEVICE_PRINTER_TRANSFER_HANDLE_INVALID;
    appData.state = APP_STATE_WAIT_FOR_WRITE_COMPLETE;
    /* Reset Switch Pressed status */
    appData.isSwitchPressed = false;
               
    printerResult = USB_DEVICE_PRINTER_Write(USB_DEVICE_PRINTER_INDEX_0,
        &appData.writeTransferHandle, (void*)&appData.prntrReadBuffer[0],
        APP_READ_BUFFER_SIZE,USB_DEVICE_PRINTER_TRANSFER_FLAGS_DATA_COMPLETE);
    
    if(printerResult== USB_DEVICE_PRINTER_RESULT_ERROR_INSTANCE_NOT_CONFIGURED)
    {
        LED_Toggle();
    }      
    break;

我总是将以下结果作为打印机:usb_device_printer_rinter_error_error_error_instance_not_configured,

是否缺少某些东西?

还有其他参考吗?

I was trying to use the SAM E54 Xplained dev board to achieve printer communication using this example from Microchip https://github.com/Microchip-MPLAB-Harmony/usb_apps_device/tree/master/apps/printer_basic#config_9 . I would like to receive an answer from the MCU. I would like to set up a USB_DEVICE_PRINTER_Write.

I decided to modify the code in the app.c as following:

case APP_STATE_SCHEDULE_WRITE:

    /* Setup the write */
              
    appData.writeTransferHandle = USB_DEVICE_PRINTER_TRANSFER_HANDLE_INVALID;
    appData.state = APP_STATE_WAIT_FOR_WRITE_COMPLETE;
    /* Reset Switch Pressed status */
    appData.isSwitchPressed = false;
               
    printerResult = USB_DEVICE_PRINTER_Write(USB_DEVICE_PRINTER_INDEX_0,
        &appData.writeTransferHandle, (void*)&appData.prntrReadBuffer[0],
        APP_READ_BUFFER_SIZE,USB_DEVICE_PRINTER_TRANSFER_FLAGS_DATA_COMPLETE);
    
    if(printerResult== USB_DEVICE_PRINTER_RESULT_ERROR_INSTANCE_NOT_CONFIGURED)
    {
        LED_Toggle();
    }      
    break;

I always got the following result as printerResult: USB_DEVICE_PRINTER_RESULT_ERROR_INSTANCE_NOT_CONFIGURED

Is there something missing?

Are there other references?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文