简体   繁体   English

Linux TTY和驱动程序

[英]Linux TTYs and drivers

For a project, we have several FTDI serial to USB converters on a custom piece of hardware. 对于一个项目,我们在定制的硬件上有多个FTDI串行到USB转换器。 Some of these serial to USB converters have special parameters that need to be set(ie where they are getting their data from). 这些串行到USB转换器中的一些具有需要设置的特殊参数(即它们从何处获取数据)。 Now, the normal way to set this would be to use the FTD2XX library, which would allow us to set data on the USB to serial converters directly. 现在,通常的设置方法是使用FTD2XX库,该库使我们可以直接将USB上的数据设置为串行转换器。 However, the D2XX drivers can't be used at the same time as the standard ftdi_sio drivers, which means that we can't use the serial port like a normal device. 但是,D2XX驱动程序不能与标准ftdi_sio驱动程序同时使用,这意味着我们不能像普通设备一样使用串行端口。

I have three basic options here: 我在这里有三个基本选择:

  1. Modify the standard drivers to use new IOCTLs. 修改标准驱动程序以使用新的IOCTL。 Since we have a very specific environment that we're targeting, I would be fine with this, however I am not sure if it is possible to handle all the possible nuances that may come up with how the USB converter works when put into different modes. 由于我们要针对的是非常特定的环境,因此我可以接受,但是我不确定是否有可能处理USB转换器在进入不同模式时如何工作的所有细微差别。

  2. Have everything use the D2XX drivers. 让一切都使用D2XX驱动程序。 This is not ideal, because if we need to use another FTDI usb to serial converter, whatever program needs to use that serial converter would also have to use the D2XX drivers, which would be good until we wanted to use a different USB to serial converter(as we would then open /dev/ttyUSBX as normal) 这不是理想的,因为如果我们需要使用另一个FTDI usb到串行转换器,则需要使用该串行转换器的任何程序还必须使用D2XX驱动程序,这在不希望使用其他USB到串行转换器之前会非常有用。 (然后我们将像往常一样打开/ dev / ttyUSBX)

  3. Make a fake TTY, such as /dev/serialX, which would then pass information through to the D2XX driver. 制作一个伪造的TTY,例如/ dev / serialX,然后将信息传递到D2XX驱动程序。 That way, we could still open the serial port as normal, but we could add in new functions to do more advanced options. 这样,我们仍然可以照常打开串行端口,但是我们可以添加新功能来执行更多高级选项。 The naming is similar to what we do now, which is to use udev to create symlinks to the correct ports. 命名与我们现在所做的相似,即使用udev创建指向正确端口的符号链接。

Option #3 would probably be the best option here, but I'm not sure exactly how to do it. 选项#3可能是这里最好的选择,但我不确定确切如何做。 I've looked into the openpty function, but that doesn't seem to do exactly what I want, mainly being able to set TTY settings on the fake serial port and have the same settings set on the real serial port. 我已经研究过openpty函数,但这似乎并不能完全满足我的要求,主要是能够在伪串行端口上设置TTY设置,并在真实串行端口上设置相同的设置。 I'm guessing that mknod/mkdev would be used here somehow, but I can't figure out exactly how. 我猜想这里会以某种方式使用mknod / mkdev,但是我不知道具体如何使用。

What's the best way to go around this? 解决此问题的最佳方法是什么?

The normal way to do this is to take advantage of the fact that the FTDI chip can use a small attached EEPROM to load config settings. 这样做的通常方法是利用FTDI芯片可以使用连接的小型EEPROM加载配置设置这一事实。 So instead of using D2XX to set the custom params, you burn the EEPROM, and the FTDI will autoconfigure itself. 因此,您不用烧录D2XX来设置自定义参数,而是烧写EEPROM,FTDI会自动进行自我配置。 Then you just use the noraml serial port drivers. 然后,您只需使用noraml串行端口驱动程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM