Building a software serial driver

Torrie Fischer tdfischer at hackerbots.net
Tue Jun 24 14:19:26 EDT 2014


Apparently all I had to do was set the type attribute on the uart_port 
structure to anything that isn't PORT_UNKNOWN.

Here's a functional driver that takes a GPIO pin and creates a read-only 
serial TTY:

https://github.com/tdfischer/gpio_serial/blob/master/gpiotty.c

:)

On Tuesday, June 24, 2014 21:27:46 Pranay Srivastava wrote:
> Hi Torrie,
> 
> On Tue, Jun 24, 2014 at 6:26 PM, Torrie Fischer
> 
> <tdfischer at hackerbots.net> wrote:
> > Hi, Pranay.
> > 
> > Thanks for having a look.
> > 
> > On Tuesday, June 24, 2014 13:42:35 Pranay Srivastava wrote:
> >> I looked at uart_register code, it seems there's no read callback so
> >> that's why you are getting that -EIO.
> > 
> > From what I understand, I'm supposed to set up the interrupts needed in
> > the
> > startup function which is called when the device is opened. This never
> > happens though, as adding a printk results in no output.
> 
> I think this might be causing it, if you see tty_open then it has a call to
> ,
> 
> tty_open_current_tty , this seems to be the only one which I think is
> not making the driver being looked up and hence no uport->open
> 
> so in case there's an already a tty attached to current then i think
> it isn't opening
> a new one. Maybe you need to detach this tty? Not so sure I'll look
> again what can be done.
> 
> >> I think you can put this call in your start_tx since uart_start is
> >> calling port->start_tx at the end so i guess you should be good there.
> > 
> > I suspect that start_tx is not getting called since adding a printk in my
> > start_tx function doesn't result in any output.
> > 
> >> I don't have much idea how will you read from it though.
> > 
> > I'm able to read from it by waiting for a rising edge interrupt and then
> > bit- banging the GPIO line in userspace, though at a slow baud that is
> > unusable. I need 9600 to read from my device :)
> 
> Ok good!. I don't have much idea about GPIO. While searching I found
> there's a GPIO library for Raspi. I don't know how much help that
> would be but i
> guess you don't want to use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140624/855dadf3/attachment.bin 


More information about the Kernelnewbies mailing list