WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Using Gpio pins through Python  (Read 2894 times)

Offline xuraax

  • Newbie
  • *
  • Posts: 37
Using Gpio pins through Python
« on: March 25, 2022, 01:04:01 PM »
The standard way I know of using the input /output pins of the RPI through python3.8 is to install RPi.GPIO using PIP.

However on this forum, as recently as 2020, there was a reference to an addon called RPi.GPIO.tcz seemingly for this purpose. I could not track this package at all in the repository. However, I did find pigpio.tcz which seems related.

Can somebody please explain the differences between the 3?

Also, as an aside, the only way I know currently to search the online .tcz repository is through TC.tcz App. How can I browse and download an extension from the command line?

Salutations

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: Using Gpio pins through Python
« Reply #1 on: March 25, 2022, 02:06:26 PM »
Hi xuraax
... How can I browse and download an extension from the command line?
Try:
Code: [Select]
tce-ab

Offline xuraax

  • Newbie
  • *
  • Posts: 37
Re: Using Gpio pins through Python
« Reply #2 on: March 27, 2022, 06:59:45 AM »
Thank you Rich for the suggestion.

I tried to search for more info on using the tce -ab command but was largely unsuccessful. What an I doing wrong?

Anyway entering tce -ab or tce -h or just tce always returned the same prompt for me the most important is S)earch. This prompts you to insert a string to search but the standard "*" was not accepted.

The best way I found to browse through the whole list (I hope) was to search for a "." which turned up "python3.8-rpi-gpio.tcz". I don't think I had seen this in the AppBrowser.

To download I then used the usual "tce-load -iw" command.

If there is a more direct way to carry such operations outside the graphical interface please do tell.

In the meantime are there any comments to my original question re using GPIO inside python?




Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: Using Gpio pins through Python
« Reply #3 on: March 27, 2022, 09:44:19 AM »
Hi xuraax
... This prompts you to insert a string to search but the standard "*" was not accepted. ...
Ah,  see the problem. The prompt says:
Quote
Enter starting chars of desired extension, e.g. abi:
but that is not really true. The search is very broad. The term searched for is neither case nor position sensitive.
For example, under TC10 x86 a search for  pic  returns:
Code: [Select]
tce - Tiny Core Extension browser

         1. flpicsee.tcz
         2. gpicview-locale.tcz
         3. gpicview.tcz
         4. ngspice.tcz
         5. PicFormat.tcz

Enter selection ( 1 - 5 ) or (q)uit:
As you can see, if the term  pic  shows up anywhere in the name, regardless of case, it shows up in the list.

Offline xuraax

  • Newbie
  • *
  • Posts: 37
Re: Using Gpio pins through Python
« Reply #4 on: March 27, 2022, 11:56:23 AM »
Hi Rich,

I understood that and it works well if you know what part of the phrase you are looking for.

I was looking for a way to browse through the whole list to see if there was anything of interest. The best way I found to do that was to search for a "."

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: Using Gpio pins through Python
« Reply #5 on: March 27, 2022, 12:26:34 PM »
Hi xuraax
Maybe this is what you want:
Code: [Select]
less /etc/sysconfig/tcedir/optional/info.lst
The  /etc/sysconfig/tcedir/optional/info.lst  file gets created/updated anytime the GUI appsbrowser gets run. Since it is
in the  tce/optional/  directory, it is persistent.

Offline xuraax

  • Newbie
  • *
  • Posts: 37
Re: Using Gpio pins through Python
« Reply #6 on: March 31, 2022, 04:57:17 AM »
My system does not have an "info.lst" file in that directory but there is a "tce.lst" file which contains a number of .tcz files. Also the directory itself contains about 370 .tcz files which is interesting.

However note that running the command tce then S) then "." turns up 1202 .tcz files in total.

regards

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11587
Re: Using Gpio pins through Python
« Reply #7 on: March 31, 2022, 09:36:54 AM »
Hi xuraax
My system does not have an "info.lst" file in that directory ...
Here are 2 ways. You don't mention which version and architecture you are running, so I will assume version 13.x.
To find the architecture of you board, enter:
Code: [Select]
uname -rif it comes back with  piCore , it's  armv6
if it comes back with  piCore-v7 , it's  armv7
if it comes back with  piCore-v7l , it's  armv7l
if it comes back with  piCore-v8 , it's  aarch64

Using a web browser, go to:
http://www.tinycorelinux.net/13.x/
Click on the link matching your architecture. Click on the  tcz  link. That lists all of the extensions available for that
version and architecture.

If you want to download that list, you can do it from the command line. For example:
Code: [Select]
wget http://www.tinycorelinux.net/13.x/armv7/tcz/info.lstIf you have bandwidth limitations, there is a compressed version available:
Code: [Select]
wget http://www.tinycorelinux.net/13.x/armv7/tcz/info.lst.gz

Offline xuraax

  • Newbie
  • *
  • Posts: 37
Re: Using Gpio pins through Python
« Reply #8 on: April 01, 2022, 11:39:17 AM »
Hi Rich,

Thanks again for your continued help.

I have only started playing with picore in the last couple of months so I am sure I am running version 13.
The list you indicated is quite extensive and appears to be the same length as the one generated by the tce search. I think I prefer to bookmark the link rather than to download the list.

Whilst waiting for the RPi Zero to become available again and hopefully at reasonable prices I have dug up an old modelB which I had bought ages ago to play around with. For sure it is armv6 and uname -r confirms this.

Actually this old RPi seems quite suited for this project since I don't need enormous speed. At the same time it needs to be very compact.

Basically I need to collect OBD2 data from my motorbike while on the go for further analysis later. Basically I have already written the Python program on my Linux Notebook which is connected to the bike's ECU through a usb2RS232 interface. This setup is not very stable to carry around on a bumpy motorbike.

The RPi is very small and the serial interface is already on board so it was quite easy to setup a rig to carry around under the seat.

For sure I am having a lot of fun.

Regards