GNAT.Serial_Communication和虚拟COM端口

时间:2014-05-06 08:16:59

标签: windows ada

我尝试将GNAT.Serial_Communication连接到COM端口(Windows 8,来自以管理员身份运行的控制台')并收到以下错误消息:

EXCEPTION: GNAT.SERIAL_COMMUNICATIONS.SERIAL_ERROR: set: cannot get comm state ( 6)

这与this question非常相似,但是我的错误并没有通过使用" COM10"," COM10:"," \\。\来解决。 COM10",或" \\\\。\\ COM10"作为COM端口标识符。所有虚拟COM端口都出现错误(使用com0com测试,以及自动创建虚拟COM端口的FTDI RS232RL芯片)。

任何提示都非常感谢!

编辑1:该连接适用于HTERM(Windows中的超级终端替代方案)。

编辑2:代码段:

A)调用GNAT.Serial_Communications:

...

Open (Port => Serial_Port_XBee_Pro_S2B, Name => Port_Name (I_Device));
-- where I_Device is the COM port identifier mentioned in the question.

Set (
    Port      => Serial_Port_XBee_Pro_S2B,
    Rate      => B57600,
    Bits      => CS8,
    Parity    => None,
    Stop_Bits => One,
    Block     => True);

...

B)导致问题的g-sercom.adb的一部分。

  ... 

  if Port.H = null then
     Raise_Error ("set: port not opened", 0);
  end if;

  Success := GetCommState (HANDLE (Port.H.all), Com_Settings'Access);

  if Success = Win32.FALSE then
     Success := CloseHandle (HANDLE (Port.H.all));
     Port.H.all := 0;
     Raise_Error ("set: cannot get comm state");
  end if;

  ... 

0 个答案:

没有答案