Reputation: 13
I have a task to write a serial driver for uart and tty_uart driver too on Zephyr (It's my first time in developing drivers).
1.So what is the difference between a serial driver and a tty driver?
Upvotes: 1
Views: 1859
Reputation: 395
Regarding your questions:
So what is the difference between a serial driver and a tty driver?
Is there any interdependence relation between them? I mean to write a tty driver should I write by first a serial driver, that will be a base to the tty driver or what?
It all depends on your operating system.
Previous answers relate mostly to Linux/Windows. You don't provide more points about it, but I'm assuming your question relates to Zephyr RTOS Project. I also assume you're developing a BSP for a custom board not yet fully supported by the RTOS.
The device driver model in Zephyr is different from Linux's or Window's driver models. You can take a look at the board porting guide and architecture porting guide.
The documentation contains a lot of samples, including quite a few of driver samples.
You'll also find more information here covering how to have access to support from the community.
Upvotes: 0
Reputation: 37212
So what is the difference between a serial driver and a tty driver?
A serial driver makes no assumption about the kind of device attached, it merely sends and receives raw "bytes" (see note), and probably offers some way to configure the communication (which baud rate, how many data bits, what kind of parity scheme, what kind of flow control, etc). The device attached to the serial port could be a serial mouse, or a bar code scanner, or a printer, or ... - the serial driver doesn't care.
Note: "byte" might not be a synonym for "octet" - e.g. it could be a group of 7 bits.
A TTY driver is tied to the assumption that the device is an type writer with a keyboard. Note: For the history; before computers existed we went from "people waving flags at each other" (semaphores) to "morse code with a single key" (telegraph) to teleprinters/teletypewriter (see https://en.wikipedia.org/wiki/Teleprinter ); and when computers got invented the (mechanical/electric) teleprinters were simply replaced with (computerized) dumb terminals.
Mostly; TTY is all about what bytes mean (and doesn't care much how the bytes are sent/received); and a serial driver is all about how bytes are sent/received (and doesn't care what the bytes mean).
Is there any interdependence relation between them? I mean to write a tty driver should I write by first a serial driver, that will be a base to the tty driver or what?
Crudely; a TTY driver has IO in 4 directions - getting key press info from local keyboard, sending bytes to remote whatever, receiving bytes from remote whatever, and putting characters on the local screen. For sending/receiving bytes with "remote whatever" you can use a serial driver; but (especially during development/testing) you could use anything else (TCP/IP stream, pipes, file IO, ...) instead - you don't necessarily need to implement the serial driver first.
Upvotes: 3