2

我正在使用一个内部软件工具来显示和记录从我为其开发嵌入式软件的产品的串行调试端口收集的格式化诊断数据。它是 C 语言并且非常古老。它是使用 Borland Turbo-C v1.01(版权所有 1990!)构建的。如果可能的话,我更愿意为现代环境修改而不是重写该工具。

我想一次从多个设备收集调试数据。我设想通过 USB-> 串行适配器连接到集线器的几个设备,连接到 PC(运行 Windows XP)。每个设备运行一个诊断工具实例(同样在 Windows 中),指向相应的 COM 端口。容易,对吧?

不完全的。观察我正在使用的串口初始化函数:

void serinit(int baudrate, char paristat, char adaptnum) {
  int hibcon, lobcon, paricon;
  if(adaptnum == '3') {
    sioreg = lowbaud = 0x3E8;     // SIO (Serial I/O Reg.)
    intenreg = highbaud = 0x3E9;  // IER (Interrupt Enable Reg.)
    intidreg = 0x3EA;             // IIR (Interrupt Ident. Reg.)
    linecon = 0x3EB;              // LCR (Line Control Reg.)
    modemcon = 0x3EC;             // MCR (Modem Control Reg.)
    linestat = 0x3ED;             // LSR (Line Status Reg.)
    modemstat = 0x3EE;            // MSR (Modem Status Reg.)
    sintvect = 0x0C;
    sintmask = 0x10;
  } else if(adaptnum == '2') {
    //omitted for brevity, similar to above w/ different magic numbers
  } else {
    //ditto
  }

  outportb(linecon, 0x80);        // LCR - set up to set baud rate

  switch(baudrate) {
    case 9600:  hibcon = 0x00;  lobcon = 0x0C; break;
    //more magic numbers for other baud rates
  }

  outportb(lowbaud, lobcon);            // Baud Rate Divisor LSB
  outportb(highbaud, hibcon);           // Baud Rate Divisor MSB

  switch(paristat) {
    case 'o': //odd parity, 2 stop, 7 data
    case 'O': paricon = 0x0E; break;
    //more magic numbers for other parity settings
  }

  outportb(linecon, paricon);  //Line Control Register
  outportb(intenreg, 0x01);    //IER - receive enabled
  outportb(modemcon, 0x09);    //x x x x +out2 x -rts +dtr

  imodemcon = 0x09;     //update image
  inportb(sioreg);      //Just in case there's anything lurking in the register
  intvsave = getvect(sintvect);
  setvect(sintvect, serint);   //Set up interrupt vector.
  outportb(0x21, inportb(0x21) & !sintmask); //OCW 1 - enable serial interrupts
}

当 USB-> 串行适配器将显示为时,我有什么选择可以为 COM 端口 5+ 调整这种配置?我可以使用 DOS 命令按预期看到它们mode(并且在 Windows 设备管理器中像普通人一样),但我不确定如何从诊断程序中访问它们。

4

3 回答 3

7

直接寻址 I/O 寄存器需要模拟传统 COM 端口行为的设备驱动程序。标准的 Microsoft 设备驱动程序执行此操作。但是您没有使用该驱动程序,您有一个供应商特定的 USB 驱动程序。

这些驱动程序通过将自己连接到串行端口的标准 winapi 函数来模拟串行端口。像 CreateFile()、SetCommConfig() 等。这需要编写 32 位代码才能使用这些功能。他们没有做的是模拟寄存器,所以 DOS 应用程序仍然可以工作,这已经结束了。并且不能正常工作,DOS 只支持 4 个 COM 端口,因此只使用了 4 组寄存器。COM5 及以上没有标准寄存器地址。

也许你可以找到一个 USB 模拟器,它的驱动程序仍然可以做到这一点。但我认为几率非常低。相反,将 90 年代的软件与 90 年代的硬件结合起来。购买您拧入总线的老式 PCI 卡。这样标准的 Microsoft 驱动程序才能工作。上次我看时(胖一年前)这些卡仍然可用,尽管选择越来越少。或者从旧机器中挖出一个。

于 2012-07-13T16:45:48.843 回答
0

如果您运行的是纯 DOS,您将受限于系统上可用的 COM 端口。查看串行端口扩展器的用户手册。它允许您选择最多 7 个 com 端口。

如果您在 Windows 中运行此 DOS 应用程序,请查看设备管理器中的设备资源。它告诉您的 I/O 范围将是您程序的寄存器地址范围。该网页演示了查找信息。

于 2012-07-13T16:22:44.383 回答
-1

超级终端 Hilgraeve/Microsoft 虚拟化 COM1。腻子紧随其后。DOSBox 下一个带有 serial1/realport。示例: http: //www.prosefights.org/irp2014/ganssle.htm#14510USB :)

于 2018-04-22T00:02:50.867 回答