Skip to content

Commit ba3f29b

Browse files
committed
Update README.md
1 parent 7e92096 commit ba3f29b

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

README.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Raspicode
2-
High precision Python transmitter of RF 315/433Mhz codes for Raspberry Pi using GPIO via Winring Pi C library.
2+
High precision Python transmitter of RF 315/433Mhz codes for Raspberry Pi using GPIO via Wiring Pi C library.
33

44
Implementation example as simple RESTful API Flask Web Server based to transmit "pilight" string format RF 315/433 Mhz codes named "picode".
55

@@ -38,14 +38,14 @@ The WiringPi is very extensive, includes support for many devices, several proto
3838
- Remove softPwm and softTone support
3939
- Remove all PWM init modes
4040
- Remove threads functions
41-
- Remove schedulling priority piHiPri
41+
- Remove scheduling priority piHiPri
4242
- Expose delayMicrosecondsHard function
4343

4444
Wiring Pi is the ideal solution to handle digital GPIOs and solve the timing problem through its **delayMicrosecondsHard()** function.
4545
There are other ways to handle GPIOs, but they are not as simple or as widespread. See: https://elinux.org/RPi_GPIO_Code_Samples
4646

4747
### delayMicrosecondsHard(unsigned int howLong)
48-
Hard loop for watching a built-in counter on the ARM SoC. This uses 100% of assignated CPU something not an issue for recent multi-core SoCs.
48+
Hard loop for watching a built-in counter on the ARM SoC. This uses 100% of assigned CPU something not an issue for recent multi-core SoCs.
4949
```c
5050
void delayMicrosecondsHard (unsigned int howLong)
5151
{
@@ -71,28 +71,41 @@ Use only these four native C functions:
7171
- **digitalWrite(gpio,state)** to set GPIO state, HIGH for odd pulse index or LOW for even pulse index.
7272
- **delayMicrosecondsHard(usecs)** to high precision microseconds program execution pause.
7373
74-
To build the module: `$ python3 setup.py develop --user`
74+
Requires install standard Python modules: **setuptools** and **flask** (for API server):
75+
- Install via OS package manager: `apt install python3-setuptools python3-flask`
76+
- Or install via **pip** Python package manager:
77+
- Install **pip**: `apt install python3-pip` and `pip install setuptools flask`
78+
79+
Requires build C extension Python module: **wiringpiook**
80+
81+
To build the module:
82+
```sh
83+
$ cd wiringpiook
84+
$ python3 setup.py develop --user
85+
```
7586

7687
The "**wiringpiook**" module only has the function "**tx()**", to transmit pulse train using gpio digital levels.
7788
Return total transmission time in milliseconds or a negative error code.
7889

79-
Usage: `tx(bcm_gpio,pulse_list,repeats=4)`
90+
Usage: `tx(bcm_gpio, pulse_list, repeats = 4)`
8091

8192
Example:
8293
```python
83-
>>> import wiringpiook
84-
>>> wiringpiook.tx(21,[500,500,2000,2000])
94+
>>> import wiringpiook as rf
95+
>>> rf.tx(21,[500,500,2000,2000])
8596
>>> 20
8697
```
8798

99+
The pulse list can be Python generated by [pyPiCode](https://github.com/latchdevel/pyPiCode) module, from any **picode** string or encoding any [pilight supported RF protocols.](https://github.com/latchdevel/picoder?tab=readme-ov-file#show-protocol-list)
100+
88101
## Process affinity to isolated CPU
89102
For better timing accuracy when code transmit, the Python script should be executed in a CPU isolated from the OS scheduler.
90103

91104
CPU isolation is a powerful set of features that can be found behind the settings for workloads which rely on specific and often extreme latency or performance requirements.
92105

93106
"isolcpus" is one of the Linux kernel boot params that isolated certain cpus from kernel scheduling, which is especially useful if you want to dedicate some cpus for special tasks with least unwanted interruption (but cannot get to zero) in a multi-core system.
94107

95-
Remove the specified CPUs, as defined by the cpu_number values, from the general kernel SMP balancing and scheduler algroithms.
108+
Remove the specified CPUs, as defined by the cpu_number values, from the general kernel SMP balancing and scheduler algorithms.
96109

97110
Raspberry Pi models 2, 3, 4 and Zero 2, have 4 cores, cpus: `{0,1,2,3}`, so is possible to dedicate one CPU to improve the transmission without much impact over system.
98111

@@ -116,8 +129,8 @@ $ taskset -c 3 ./raspicode.py
116129

117130
Anyway, if there are CPUs isolated from the OS, Python script will try to set affinity to one of the isolated CPUs:
118131
```
119-
[2022-09-19 00:24:38,782] 1388 WARINING - Process id: 1388 not OS scheduler isolated cpu process affinity
120-
[2022-09-19 00:24:38,784] 1388 WARINING - Trying to set process affinity cpu: {3}
132+
[2022-09-19 00:24:38,782] 1388 WARNING - Process id: 1388 not OS scheduler isolated cpu process affinity
133+
[2022-09-19 00:24:38,784] 1388 WARNING - Trying to set process affinity cpu: {3}
121134
[2022-09-19 00:24:38,786] 1388 INFO - OK Process id: 1388 affinity cpu: {3} isolated from OS scheduler cpu: {0, 1, 2}
122135
[2022-09-19 00:24:38,787] 1388 INFO - Web server binding to 0.0.0.0 port 8087 local url http://192.168.1.49:8087/
123136
```
@@ -242,7 +255,7 @@ Remember that in any radio frequency system, the most important element is the a
242255
243256
244257
# License
245-
Copyright (c) 2022 Jorge Rivera. All right reserved.
258+
Copyright (c) 2022-2024 Jorge Rivera. All right reserved.
246259
247260
License GNU Lesser General Public License v3.0.
248261

0 commit comments

Comments
 (0)