简体   繁体   English

自己的RS232设备作为linux文件系统设备

[英]Own RS232 device as linux filesystem device

Is there a way to expose own RS232 AVR device as Linux file system device eg /dev/avr_device ? 有没有办法将自己的RS232 AVR设备公开为Linux文件系统设备,例如/dev/avr_device The program must be written as kernel space module or in user space? 该程序必须作为内核空间模块或在用户空间中编写? Is this possible to do by libfuse ? libfuse可以做到吗? Maybe should I use FIFO pipes as communication channel with device? 也许我应该使用FIFO管道作为与设备的通信通道?

To be able to mount a device, in which you have installed a linux filesystem, you need that device to be a block device , but a serial tty device is a char device , incompatible with that. 为了能够挂载安装了Linux文件系统的设备,您需要将该设备作为块设备 ,而串行tty设备是与之不兼容的char设备

To be able to solve that problem in the classical view of the system, you need to develop a block device driver, that attaches to that char device (the serial port) and uses it to control de block device emulation protocol, this means to convert the block number and block data into packets to be sent over the serial line to a receiver at the other side an implement the block device details of being some kind of storage device. 为了能够在系统的经典视图中解决该问题,您需要开发一个块设备驱动程序,该驱动程序附加到该char设备(串行端口)并使用它来控制de块设备仿真协议,这意味着要进行转换将块号和块数据打包成数据包,然后通过串行线发送到另一侧的接收器,以实现作为某种存储设备的块设备详细信息。 This can be done with some effort.... the problem is if using a slow serial line will be of interest to simulate any kind of storage. 这可以通过一些努力来完成。...问题是,如果使用慢速串行线来模拟任何类型的存储是否会引起人们的兴趣。

The advantage of the last approach is that you only have to simulate a block device and will be able to create any local filesystem available for linux. 最后一种方法的优势在于,您只需模拟一个块设备,就可以创建可用于linux的任何本地文件系统。

On a higher level, you can implement a filesystem type, which is a higher level abstraction (fuse allows you for this) but this makes that a more difficult problem, as you have to implement every filesystem primitives (and believe me, there are far more primitives to emulate a filesystem than a block device) to implement every remote primitive as a set of local primitives (this can be unfeasible for a single programmer only) 在更高级别上,您可以实现文件系统类型,这是更高级别的抽象(保险丝允许您这样做),但这使问题变得更加棘手,因为您必须实现每个文件系统原语(并且相信我,比块设备更多的用于模拟文件系统的原语),以将每个远程原语实现为一组本地原语(仅对于单个程序员而言这是不可行的)

This second approach fixes completely the functionality of the filesystem, and fixes completely the set of operations you can do to files to the implemented primitives you write. 第二种方法完全修复了文件系统的功能,并且完全修复了可以对文件执行的一组操作,这些操作都已写入您编写的已实现原语。 It is far more difficult and normally lacks uniformity with the rest of the system, so I should not recommend you to follow this approach. 这要困难得多,并且通常与系统的其余部分缺乏统一性,因此,我不建议您采用这种方法。

The second approach has only one advantage, and it is: as the filesystem uses high level primitives, these can be encoded more compactly into network messages and be more efficiently transmitted over the line, giving more speed for a slow connection. 第二种方法仅具有一个优点,它是:由于文件系统使用高级原语,因此可以将它们更紧凑地编码为网络消息,并可以更有效地通过线路传输,从而为慢速连接提供了更高的速度。 But at the cost of having to implement all the filesystem functionality, and loosing uniformity on the use of these kind of filesystems (you have to implement user access, security, caching of requests, etc). 但是,这是以必须实现所有文件系统功能以及在使用这类文件系统上失去统一性为代价的(您必须实现用户访问,安全性,请求缓存等)。

In the first approach, you have only to implement 4 or 5 primitives, and you get all the functionality of any filesystem that can be installed on a block device. 在第一种方法中,您只需要实现4个或5个原语,就可以获得可以安装在块设备上的任何文件系统的所有功能。

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

相关问题 用于嵌入式系统中RS232设备的Linux设备驱动程序 - Linux device driver for a RS232 device in embedded system 如何在Linux中将二进制数据写入串行端口(RS232)设备文件中? - How to write binary data into a serial port (RS232) device file in linux? Linux无法使用rs232接口连接到设备,Windows没有问题 - Linux cannot connect to device using rs232 interface, Windows does not have problems LINUX 中的串行通信 (RS232) - Serial Communication (RS232) in LINUX 使socat链接到udp rs232连接的串行设备持久的最佳方法是什么? - What is the best way to make a socat link to a udp rs232 connected serial device persistent? RS232串行引脚在Linux中读取C语言 - RS232 Serial Pin Read in C in Linux 如何在Linux中有效地等待RS232的CTS或DSR? - How to efficiently wait for CTS or DSR of RS232 in Linux? 在Linux上登录RS232而无需等待换行符 - Logging RS232 on Linux without waiting for newline 仅在 Linux 中与 TDK-Lambda ZUP 的串行 RS485 / RS232 通信非常慢 - Serial RS485 / RS232 communication with TDK-Lambda ZUP very slow only in Linux 当数据到达Linux中的串行端口(RS232)时,是否可以向用户应用发送通知消息? - Is it possible to send notification message to user app when data arrives at serial port (RS232) in Linux?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM