Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

上位机反复请求设备状态 #1

Open
imuncle opened this issue Nov 28, 2019 · 1 comment
Open

上位机反复请求设备状态 #1

imuncle opened this issue Nov 28, 2019 · 1 comment

Comments

@imuncle
Copy link

imuncle commented Nov 28, 2019

你好,我参照你的代码实现CH341的模拟,目前已经成功枚举,串口调试软件也能成功打开串口,但打开串口之后电脑不断请求设备状态,也就是下面:

int ch341_get_status(struct usb_device *dev) 
{ 
  char *buffer; 
  int r = -ENOMEM; 
  const unsigned size = 8; 
  
   dbg("ch341_get_status()"); 
   
   buffer = kmalloc(size, GFP_KERNEL); 
  if (!buffer) 
    goto out; 
   
   r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size); 
  /* return value ignored */ 
   r = 0; 
  
  out: kfree(buffer); 
  return r; 
 } 

我猜测是上位机让设备复位后在查询设备的复位情况。你的代码里面的处理方式是:

/*******************************************************************************
* Function Name  : Virtual_Com_Port_Data_Setup
* Description    : handle the data class specific requests
* Input          : Request Nb.
* Output         : None.
* Return         : USB_UNSUPPORT or USB_SUCCESS.
*******************************************************************************/
static u8 vender_request;

u8 *Vender_Handle_CH341(u16 Length)
{
    u16 wValue = pInformation->USBwValues.w;
    u16 wIndex = pInformation->USBwIndexs.w;
    static u8 buf1[2]={0x30,0};
    static u8 buf2[2]={0xc3,0};
    change_byte(wValue);
    change_byte(wIndex);
   
    // 省略其他代码...

    case 0x95:
            if(wValue==0x2518)
                return buf2;
            else if(wValue==0x0706)
                return (u8 *)&ch341_state;     
    }
    return 0;
}

我按照你的代码返回值为0xee9fch341_state返回,但并没有解决问题。

希望能从你这获得帮助,谢谢!

@blackmiaool
Copy link
Owner

改行啦 不玩硬件啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants