我正在使用一个内部软件工具,该工具显示和记录从我为其开发嵌入式软件的产品的串行调试端口收集的格式化诊断数据。它是用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
}当5+ ->串行适配器将显示为时,我有哪些选项来适应COM端口的这种配置?我可以用DOS的mode命令看到它们(在Windows设备管理器中,就像正常人一样),但我不确定如何从诊断程序访问它们。
发布于 2012-07-14 00:45:49
直接寻址I/O寄存器需要模拟传统COM端口行为的设备驱动程序。标准的Microsoft设备驱动程序会执行此操作。但是您没有使用该驱动程序,您有一个特定于供应商的USB驱动程序。
这些驱动程序通过将自身连接到串行端口的标准winapi函数中来模拟串行端口。比如CreateFile()、SetCommConfig()等等。这需要编写32位代码才能使用这些函数。他们不做的是模仿寄存器,这样DOS应用程序仍然可以工作,这已经结束了。一般情况下,DOS只支持4个COM端口,所以只有4组寄存器。COM5和up没有标准寄存器地址。
也许你可以找到一个USB模拟器,它的驱动程序仍然可以做到这一点。但我认为机率很低。取而代之的是,把你90年代的软件和90年代的硬件结合起来。买一张老式的PCI卡,你可以把它拧到公交车上。这样标准的微软驱动程序就可以工作了。上次我看的时候(一年前很丰满),这些卡仍然可以买到,尽管选择的东西越来越少了。或者从旧机器里挖一块。
发布于 2012-07-14 00:22:44
如果您运行的是纯DOS,则只能使用系统上可用的COM端口。请看this串行端口扩展器的用户手册。它允许您选择最多7个com端口。
如果您在Windows中运行此DOS应用程序,请查看设备管理器中的设备资源。它告诉你的I/O范围将是你的程序的寄存器地址范围。此网页demonstrates演示了如何查找信息。
发布于 2018-04-22 08:02:51
微软希尔格雷夫/微软虚拟化COM1。PuTTY紧随其后。DOSBox下一步是serial1/realport。示例:http://www.prosefights.org/irp2014/ganssle.htm#14510USB :)
https://stackoverflow.com/questions/11474180
复制相似问题