@Antony The easiest method is to just use subprocess function to call the command from within your python code. I think many people will just add the the command to their /etc/rc.local so the pin is set to gpio when the device boots.
Go-to resource for frequently asked technical questions
Looking for a way to probe the hardware to reliably detect if it is a Omega2/2S (64MB MB RAM, 16 MB Flash) or an Omega2+/2S+ (128MB MB RAM, 32 MB Flash)
Why is this useful?
If an Omega2+ is flashed with Omega2 firmware, the software (like ubus call system board) will identify it as an Omega2 regardless of the hardware differences.
We need a way to identify the actual hardware on the device to determine if it is an Omega2 or Omega2+
Solution that works from Linux Userspace
In the kernel messages (which can be viewed with the dmesg command), there is a line like:
[ 0.358842] m25p80 spi0.0: w25q128 (16384 Kbytes)
or (in newer OpenWrt versions):
[ 0.639801] spi-nor spi0.0: w25q256 (32768 Kbytes)
This is a message from the spi-nor kernel driver after detecting the actual flash chip. So it is not dependent on the flash size that is baked into the firmware image, but shows the real size of the flash chip. Both of the example lines above are from a firmware made for the Omega2. The first is run on an actual Omega2, the second shows 32M so it is a Omega2+.
The only gotcha with this is that the dmesg buffer is not infinite and will loose older lines when too many new ones arrive. This means detecting the flash chip size needs to be done shortly after startup.
So I put the following line into a startup script (e.g. /etc/rc.local) :
dmesg | sed -n -r -e '/spi0.0: .*w25q/s/.*(w25q.*\))/\1/p' > /tmp/flashchip
With this, the chip name and size is captured and can be read any time later from /tmp/flashchip to detect an Omega2(S)+ vs Omega2(S)+.
Solution found and published by @luz: https://community.onion.io/topic/4212/any-way-to-detect-an-omega2-when-running-with-omega2-fw
How can I get point datas to plot or process point datas in Python? Moreover, I also need to know how you arrange data in an array such as x, y, z datas to use the point datas correctly. Could you explain to me, such as how I can modify your example (such as distance.py) to meet what I want.