일부 오류가 발생하는 USB 장치를 나타내는 양식이 있습니다. 아무런 소스가없는 이상한 오류를 디버깅한지 반나절 후, 터미널이 인스턴스화되었지만 표시되지 않을 때 터미널이 작동하지 않는다는 것을 알게되었습니다. 코드를 변경하고 usbTerminal.Show()를 추가하면 제대로 작동합니다..Show()가 호출되지 않으면 양식이 작동하지 않습니다.
USBTerminal usbTouchTerminal;
public MainForm()
{
InitializeComponent();
USBSettings usbTouchSettings = new USBSettings();
usbTouchTerminal = new USBTerminal(usbTouchSettings); //Create Terminal with settings
usbTouchTerminal.StartUSB();
usbTouchTerminal.Show(); //works ONLY when show is here
}
어떻게 가능하며 그 이유는 무엇입니까? 방대한 검색을했는데 내 코드는 내 터미널이나 기본 폼의 .Visible 속성에 따라 다릅니다.
표시되지 않는 경우 일부 양식이 작동하지 않는 이유에 대해 완전히 당황 스럽습니다. MSDN 또는 google도 도움이되지 않았습니다. 인스턴스화 될 때 제대로 작동하지만 표시되지 않을 것이라고 확신했습니다.
추신. 덧붙여서
usbTerminal.Show();
usbTerminal.Hide();
그리고 터미널이 올바르게 기능했습니다.
도움 주셔서 감사합니다.
편집 :
나는이 usbTerminal는 WndProc을 재정의를 사용하는 점에 유의해야한다. 나는 그것에 대해 전문가가 아니지만, 그 일과 관련이 있다고 생각합니다.
나는이 양식에서 onShow 이벤트가 호출 될 때 일부 필수 기능을 호출 할 것이기 때문에 LibUSBdotnet
public class USBSettings
{
/// <summary>
/// This is the Vender ID Number. (0x0B6A)
/// </summary>
public ushort VID { get; set; }
/// <summary>
/// This is the Product ID Number. (0x5346)
/// </summary>
public ushort PID { get; set; }
/// <summary>
/// This is the optional Serial Name. ("")
/// </summary>
public string SerialName { get; set; }
/// <summary>
/// This is the Reader USB Endpoint. (ReadEndpointID.Ep02)
/// </summary>
public ReadEndpointID ReaderEndpoint { get; set; }
/// <summary>
/// This is the Writer USB Endpoint. (WriteEndpointID.Ep01)
/// </summary>
public WriteEndpointID WriterEndpoint { get; set; }
/// <summary>
/// This is the Registry Key for USB settings. ("SOFTWARE\\DEFAULT\\USBPROPERTIES")
/// </summary>
public string SubKey { get; set; }
/// <summary>
/// This is the default read buffer size for the USB Device.
/// </summary>
public int ReadBufferSize { get; set; }
/// <summary>
/// This constructor houses default values for all properties.
/// </summary>
public USBSettings()
{
VID = 0x0B6A;
PID = 0x5346;
SerialName = "";
ReaderEndpoint = ReadEndpointID.Ep02;
WriterEndpoint = WriteEndpointID.Ep01;
SubKey = "SOFTWARE\\DEFAULT\\USBPROPERTIES";
ReadBufferSize = 100;
}
}
무엇입니까? 어떻게 작동하지 않습니까? – SLaks
이 양식입니까? 어떻게해야합니까? usbTouchSettings의 코드는 어떻게 생겼습니까? – Bit
임베디드 시스템에 연결된 USB 터미널입니다. 기본적으로, 그것은해야 할 때 어떤 데이터를받지 못합니다. 터미널에는 기본 응용 프로그램 기능과 함께 제대로 작동하지 않는 수신 및 전송 목록 상자가 있습니다. – bassplayer142