Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial Access including RS232 (Feature request) #12

Open
Odianosen25 opened this issue Jun 9, 2018 · 10 comments
Open

Serial Access including RS232 (Feature request) #12

Odianosen25 opened this issue Jun 9, 2018 · 10 comments

Comments

@Odianosen25
Copy link

Hello @PierreRust,

Many thanks for your work. Please is it possible to kindly add support for the Serial interface? I went via the doc on the pigpio library, and it seems to support serial.

I have a serial interface at “/dev/ttyAMA0”, and was hoping to be able to access it asynchronously using your code. Also support for RS485 will be great as mine is on “/dev/ttyRS485”.

Thanks and regards

@Odianosen25
Copy link
Author

@jabdoa2 and @alexander3771,

Please is there anyway someone could assist me with this request? I know Asyncio, but not so confident in it.

Even if the code is just a patch together, at least it gives me a start and I could walk via it, if its buggy; so no need to spend so much time on it.

Thanks

@alexander3771
Copy link

Hello, @Odianosen25!

I didn't make anything with apigpio since my last commit, but I worked on other asyncio-projects :)

As far as I understand, you want to connect to your gpio via serial port.
I guess, you only need to implement connection from this snippet https://gist.github.com/potens1/914b738a2ca6fed7a7b3
Inherit methods connect, _pigpio_aio_command and close here, and make sending data via serial connection
https://github.com/alexander3771/apigpio/blob/2df1aafff4a3e274c35bc6509afd06d28b08bc13/apigpio/apigpio.py#L540-L600

Hope it helped, btw I can review your code :)

@Odianosen25
Copy link
Author

@alexander3771,

Oh thanks for your response.

Thanks for the examples, and I am aware of the serial over asyncio, but that's not really want I want. Not that I want to read the GPIO from serial, but I want to use the apigpio to read the serial port on the Raspi which is part of the GPIO ('/dev/ttyAMA0' to be precise). As the pigpio supports that with some SER.. commands.

I am working on a project, and I want to use the pigpio daemon via asyncio to read my GPIO using python. So that was what brought me here. I noticed you made a PR, which I have downloaded, and I want to make some modes to it, so I can read not just the pins, but also the serial port.

I also what to use the pipe option over /dev/pigerr, instead of the socket to improve security; but I will look into this later.

Thanks for the offer to review my code, and I will go via that option so I don't use up your time. I am already presently making some modes already, so once done will send it over.

Thanks and regards

@Odianosen25
Copy link
Author

Hello @alexander3771,

I have made some changes to your files, in which I added the i2c changes made by @jabdoa2 and some serial by myself. You can see the files here.

Please can you kindly go via it and confirm I didn't do anything naughty?

Thanks and kind regards

@jabdoa2
Copy link
Contributor

jabdoa2 commented Jun 10, 2018

Looks good to me. Can you create a PR against this or my repo? That would allow us to merge it later.

@Odianosen25
Copy link
Author

Ok thanks @jabdoa2, I will do just that now and create a PR also against your repo.

Regards

@alexander3771
Copy link

alexander3771 commented Jun 10, 2018

It's ok for me too. But let me wrap this code in if py35:

+    async def __aenter__(self):
+        await self.connect()
+        return self
+
+    async def __aexit__(self, exc_type, exc_val, exc_tb):
+        await self.stop()

because of #10 (comment)
I can make it tomorrow

@Odianosen25
Copy link
Author

Elmm @alexander3771 I honestly have no clue what you saying, but I believe you can make changes to it right?

So I will wait till tomorrow, before using the code in my project so I will be certain I have the latest.

Thanks and kind regards

@jabdoa2
Copy link
Contributor

jabdoa2 commented Jun 10, 2018

@Odianosen25 just use the older syntax (yield from and asyncio.coroutine) like the other functions

@Odianosen25
Copy link
Author

@jabdoa2, thanks, but I have just started learning to use asyncio, and I am actually so much more used to async def and await, so not so used to the old yield stuff; that's why I said I didn't get what he meant.

If its about the conversion as the linked comment, I will actually prefer that, as I am kind of more comfortable with the new way of doing it, since that is my first way I learnt it.

Thanks once again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants