【发布时间】:2012-07-13 16:06:33
【问题描述】:
我正在使用一种内部软件工具,该工具可以显示和记录从我为其开发嵌入式软件的产品的串行调试端口收集的格式化诊断数据。它是 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->Serial 适配器将显示为时,我有哪些选项可以为 COM 端口 5+ 调整这种配置?我可以使用 DOS mode 命令(以及在 Windows 设备管理器中像普通人一样)按预期看到它们,但我不确定如何从诊断程序中访问它们。
【问题讨论】:
-
哇,有些死灵术。我只是评论 - 考虑查看
chgport命令将传统的 com1 映射到 com4 到其他 comport。 docs.oracle.com/cd/E35310_01/E35309/html/…
标签: c usb serial-port dos turbo-c