void CA01ControllerDlg::OnBnClickedButton43()
{
// TODO: 在此添加控件通知处理程序代码
if(g_udevIndex > 0)
{
int ret;
CString serialNumber;
char Out_Data[64];
// float f;
union
{
char data[4];
float f;
}exchange;
//SET_MAGXX_EDIT
GetDlgItemText(SET_MAGXX_EDIT, serialNumber); 字符串转化为float 类型 最关键的实现
exchange.f = (float)(atof(serialNumber));
//exchange.f = atof(serialNumber);
//exchange.f = strtod(serialNumber,NULL);
memcpy(&Out_Data[0], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGYX_EDIT
GetDlgItemText(SET_MAGYX_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[4], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGZX_EDIT
GetDlgItemText(SET_MAGZX_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[8], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGXOFF_EDIT
GetDlgItemText(SET_MAGXOFF_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[12], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGXY_EDIT
GetDlgItemText(SET_MAGXY_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
//exchange.f = atof(serialNumber);
memcpy(&Out_Data[16], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGYY_EDIT
GetDlgItemText(SET_MAGYY_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[20], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGZY_EDIT
GetDlgItemText(SET_MAGZY_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[24], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGYOFF_EDIT
GetDlgItemText(SET_MAGYOFF_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[28], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGXZ_EDIT
GetDlgItemText(SET_MAGXZ_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[32], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGYZ_EDIT
GetDlgItemText(SET_MAGYZ_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[36], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGZZ_EDIT
GetDlgItemText(SET_MAGZZ_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[40], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
//SET_MAGZOFF_EDIT
GetDlgItemText(SET_MAGZOFF_EDIT, serialNumber);
exchange.f = (float)(atof(serialNumber));
// exchange.f = atof(serialNumber);
memcpy(&Out_Data[44], exchange.data, 4);
printf("%f\r\n", exchange.f);
printf("%x %x %x %x\r\n",exchange.data[0], exchange.data[1], exchange.data[2], exchange.data[3]);
// if (serialNumber.GetLength()!=6)
// {
// printf("Length Error.\r\n");
// return;
// }
// memcpy(Out_Data,serialNumber,6);
// printf("%s\r\n",serialNumber);
ret = usb_control_msg(g_udev[0],0x21,0x09,0x0308,0x0000,Out_Data,63,1000);
}
else
{
// AfxMessageBox("请链接OTG设备");
}
}