简体   繁体   English

pxa255中的RS485支持

[英]RS485 support in pxa255

I want to use rs485 placed on my card. 我想使用卡上的rs485。 I'm working on arm-linux and with pxa255 processor. 我正在使用arma Linux和pxa255处理器。 I have already checked "serial.h" located in arm-linux tool chain but unfortunately i couldn't find the appropriate rs485 settings struct although it is supported in some other environments like cris. 我已经检查了位于arm-linux工具链中的“ serial.h”,但不幸的是,尽管在cris等其他环境中也支持它,但我找不到合适的rs485设置结构。 So now, do i have to write a low-level driver to enable rs485 or is there any other easier way to do this? 所以现在,我是否必须编写一个低级驱动程序来启用rs485或还有其他更简单的方法来做到这一点?

我建议您阅读有关Linux RS-485支持的页面

There seems to be quite a lot of confusion about serial ports with regards to RS485 mode support on Linux drivers. 关于Linux驱动程序对RS485模式的支持,关于串行端口似乎有很多困惑。 I think I might be able to shed some light answering this question. 我认为我也许可以回答这个问题。

First off, you should ask yourself: why do I want to activate RS485 support on my serial port? 首先,您应该问自己:为什么我要在串行端口上激活RS485支持? I don't know what development board or hardware you're using but be aware that most UARTs work with single-ended TTL levels only (5V or 3.3V levels). 我不知道您在使用什么开发板或硬件,但是请注意,大多数UART仅在单端TTL电平(5V或3.3V电平)下工作。 That means you won't be able to talk to RS485 devices directly because they only handle differential signals. 这意味着您将无法直接与RS485设备通信,因为它们仅处理差分信号。 If you want more details you can see this link: https://www2.htw-dresden.de/~huhle/ArtScienceRS485.pdf for a good introduction. 如果您需要更多详细信息,请参见以下链接: https : //www2.htw-dresden.de/~huhle/ArtScienceRS485.pdf ,以获取良好的介绍。

So you can write as many lines of code and drivers as you want but that won't help your TTL UART talk to RS485. 因此,您可以根据需要编写任意多行代码和驱动程序,但这不会帮助您的TTL UART与RS485通讯。 Even if you have a device that supports RS485 on its driver, the hardware itself needs to have a level translator IC (like a MAX485) for you to be able to use it. 即使驱动器上支持RS485的设备,硬件本身也需要具有电平转换器IC(如MAX485)才能使用。 Fortunately, our beloved Linux Kernel developers know a lot about hardware and you don't have to worry about this (for most devices anyway). 幸运的是,我们心爱的Linux内核开发人员对硬件了解很多,并且您不必为此担心(对于大多数设备而言)。 Then, answering your question: if you are not able to find the RS485 settings on your driver it will most likely mean your hardware does not offer support directly . 然后,回答您的问题: 如果您无法在驱动程序上找到RS485设置,则很可能意味着您的硬件不直接提供支持

Luckily for you, the solution is quite easy: just get a cheap USB to RS485 dongle. 幸运的是,该解决方案非常简单:只需购买一个便宜的USB到RS485加密狗即可。 You can find them from 5-10$ and they should work fine out of the box for most scenarios. 您可以在5到10美元之间找到它们,它们在大多数情况下都可以正常使用。 In my experience, FTDI chips work well. 以我的经验,FTDI芯片效果很好。

If you really have to go with one particular UART for any reason whatsoever, for instance, imagine you want to use the UART on your Raspberry Pi or any other where you only have TX and RX signals accessible . 例如,如果出于任何原因确实需要使用一个特定的UART,请想象您想在Raspberry Pi或仅可访问TX和RX信号的任何其他设备上使用UART。 Then you have a slightly more difficult challenge ahead of you and you need to study a bit more about how RS485 devices work. 这样,您面临的挑战就更加艰巨,您需要进一步研究RS485设备的工作方式。 The key aspect here is to understand that RS485 on a half-duplex two-wire link (see note below for more details on this). 此处的关键方面是要了解半双工两线链路上的RS485(有关更多详细信息,请参见下面的注释)。 To be able to share a two-wire bus where one or multiple devices are listening and only one is talking at any time, you need an additional control signal (Drive Enable/~Read Enable) on top of your TX and RX (note that when you go on single-ended TTL you have two signals referred to GND using three wires compared to one differential bus with two wires for the RS485 side). 为了能够共享两线制总线,其中一个或多个设备正在侦听而任何时候都只有一个正在讲话,您需要在TX和RX的顶部附加一个控制信号(驱动使能/〜读使能)(请注意,当您使用单端TTL时,与使用一根差分总线的两根RS485端的差分总线相比,使用三根导线的两个信号被称为GND。 Your RS485 transceiver (say MAX485) will need this RE/~DE signal to arrange who is talking and who is listening on the bus, namely: all devices listening on the bus will have this signal low (read enable set) while the talker will be high (drive enable). 您的RS485收发器(例如MAX485)将需要此RE /〜DE信号来安排谁正在通话和谁正在总线上监听,即:在总线上监听的所有设备都将使该信号为低电平(读启用设置),而讲话者将高(驱动器使能)。

Here we get to the essence of your question: where can you get this additional signal? 在这里,我们进入了您问题的实质:在哪里可以得到这个额外的信号? Well, the answer is: it depends on your UART chip. 好吧,答案是:它取决于您的UART芯片。 Some chips don't offer anything to work with, then you're left with the option of manually driving in your software application a GPIO line or flow controls signals (RTS or DTR) for UARTS where you have them available. 某些芯片无法提供任何支持,因此您可以选择在软件应用程序中手动驱动GPIO线路或UARTS的流控制信号(RTS或DTR)(如果有)。 You can read more details on this topic for the particular case of the FTDI chips here: RS485: Inappropriate ioctl for device . 您可以在以下位置针对FTDI芯片的特定情况阅读有关此主题的更多详细信息: RS485:设备的ioctl不适当 There is also a reference to a nice hardware solution to this problem using the mythical 555 timer IC. 也有使用神话般的555定时器IC来解决此问题的一种很好的硬件解决方案的参考。

Note : more confusing areas: one, RS485 is half-duplex and sometimes mixed up with RS422, which is full duplex and needs four wires; 注意 :更令人困惑的领域:一,RS485是半双工的,有时与RS422混合在一起,后者是全双工的,需要四根电线; and two: where I say two-wire and four wires I should better say three-wire and five wires because the differential voltage signals need a GND to serve as a return path; 第二:在说两线和四线的地方,我最好说三线和五线,因为差分电压信号需要一个GND作为返回路径。 sadly, most practical implementations of RS485 are two-wire and they seem to work reliably for most people, but that's a huge topic itself and we can talk about it somewhere else. 不幸的是,RS485的大多数实际实现都是两线制的,并且对于大多数人来说似乎可以可靠地工作,但这本身就是一个巨大的话题,我们可以在其他地方谈论它。

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

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