diff --git a/shredder/asterix-pp/.osr/discourse_raw.md b/shredder/asterix-pp/.osr/discourse_raw.md
deleted file mode 100644
index ddf2a1d02..000000000
--- a/shredder/asterix-pp/.osr/discourse_raw.md
+++ /dev/null
@@ -1,117 +0,0 @@
-
-## Features
-
-- Jam detection / Auto-Reverse
-- Rigid, flexible and modular framework – enabling hacking and extensions
-- Electronics and wiring according to standards
-- Auto-Stop after being idle
-- Visual feedback
-
-
-#### Brief
-
-- **Status**: Testing : Testing RevA
-- [**Last Change**](https://git.osr-plastic.org/osr-plastic/osr-machines/commit/f3c2fa23d8106f532c0638b27c0ae6b80d1fb475) : Sunday, July 30, 2023 8:28 PM by [ lovebird ](https://git.osr-plastic.org/osr-plastic/osr-machines/lovebird) - ```dh shredder v2.1 | lucy-clamp-30mm | discourse meta```
-
-
-
-
-
-
-
-[wrap="center"]
-
-[/wrap]
-
-
-
-## Specification
-
-
-
- | Weight |
- 70 Kg |
-
-
-
-
- | Knife Material |
- Stainless |
-
-
- | Shaft |
- 35mm |
-
-
- | Voltage |
- 220V or 380V |
-
-
- | Motor – Power |
- 2.2kW |
-
-
- | Type |
- Single Shaft |
-
-
- | License |
- CERN Open Source Hardware License |
-
-
- | Compliance |
- CE |
-
-
- | Control |
- PLC – Auto-Reverse |
-
-
- | Sieve |
- 5mm |
-
-
- | Hexbar |
- 32mm |
-
-
- | Chamber |
- Steel – Powder – coated |
-
-
- | Housing |
- Powder coated |
-
-
-
-
-[Source : http://files.osr-plastic.org/files/osr-machines/shredder/asterix-pp/specs.xlsx](http://files.osr-plastic.org/files/osr-machines/shredder/asterix-pp/specs.xlsx)
-
-
-## Authors
-
-- [ PlasticHub S.L. ]( https://osr-plastic.org )
-- [ Jason Knight ]( https://www.mandin.earth/ )
-
-
-
-
-
-
-
-#### Resources
-- [Firmware](http://files.osr-plastic.org/files/firmware/zoe_min-sm/)
-
-- [Files](http://files.osr-plastic.org/files/osr-machines/shredder/asterix-pp)
-- [Git Source](https://git.osr-plastic.org/osr-plastic/osr-machines/src/branch/master/shredder/asterix-pp)
-- [3D Preview](https://assets.osr-plastic.org/machines//shredder/asterix-pp/resources/edrawings.html)
-- [Gallery](http://files.osr-plastic.org/files/osr-machines/shredder/asterix-pp/media/gallery)
-
-
-
-
-
-
-
-
-
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Arduino/Arduino.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Arduino/Arduino.meta.json
deleted file mode 100644
index c75e272c3..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Arduino/Arduino.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Shredder",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "COM22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": true,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "aa504ee4-6cd3-8a5e-4654-56294ef78fd6",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "serial",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "xxx1",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "21201d2f-6d4f-99f9-5d10-873c9d629150",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"baudRate\": \"57600\",\n \"databits\": 8,\n \"stopbits\": 1,\n \"parity\": \"none\",\n \"rtscts\": false,\n \"xon\": false,\n \"xoff\": false,\n \"flowcontrol\": false,\n \"buffersize\": 65536\n}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 16,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 51,\n \"Send Command\": 51,\n \"Device Disonnected\": 55,\n \"Device Connected\": 55\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Arduino/CNC.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Arduino/CNC.meta.json
deleted file mode 100644
index d4af9a2c6..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Arduino/CNC.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "CNC",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "COM19",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "e208711c-a51c-8d8a-41f2-883cd95ac7c4",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "serial",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "85d635a0-5b24-dae7-2b86-71556acbd587",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "",
- "visible": true,
- "enumType": "-1"
- },
- false,
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 16,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 35,\n \"Send Command\": 35,\n \"Device Connected\": 37,\n \"Device Error\": 39\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Extrusion/Lydia-v3.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Extrusion/Lydia-v3.meta.json
deleted file mode 100644
index 2bf255b32..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Extrusion/Lydia-v3.meta.json
+++ /dev/null
@@ -1,139 +0,0 @@
-{
- "inputs": [
- {
- "name": "Title",
- "value": "Lydia-v3",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": true,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Title",
- "params": null
- },
- {
- "name": "Host",
- "value": "Search",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Host",
- "params": null
- },
- {
- "name": "Enabled",
- "value": false,
- "type": 0,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Enabled",
- "params": null
- },
- {
- "name": "Driver",
- "value": "b22efaaa-0122-63df-c073-63b9784e7b1d",
- "type": 3,
- "enumType": "Driver",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Driver",
- "params": null
- },
- {
- "name": "Protocol",
- "value": "serial",
- "type": 3,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Protocol",
- "params": null
- },
- {
- "name": "Port",
- "value": "23",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Port",
- "params": null
- },
- {
- "name": "Id",
- "value": "0c7d0820-afeb-170c-0006-7e225a67f8be",
- "type": 13,
- "enumType": "-1",
- "visible": false,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Id",
- "params": null
- },
- {
- "name": "Options",
- "value": "{\n \"baudRate\": \"19200\",\n \"databits\": 8,\n \"stopbits\": 1,\n \"parity\": \"none\",\n \"rtscts\": false,\n \"xon\": false,\n \"xoff\": false,\n \"flowcontrol\": true,\n \"buffersize\": 65536\n}",
- "type": 21,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Options",
- "params": null
- },
- {
- "name": "DriverOptions",
- "value": 0,
- "type": 5,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Driver",
- "user": null,
- "dst": null,
- "id": "DriverOptions",
- "params": null
- },
- {
- "id": "Logging Flags",
- "name": "Logging Flags",
- "parentId": -1,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "value": "{\n \"Device Connected\": 47,\n \"Response\": 35,\n \"Send Command\": 51,\n \"Device Disonnected\": 39,\n \"Device Error\": 1\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/House/WebCam.meta.json b/shredder/asterix-pp/asterix-hmi/devices/House/WebCam.meta.json
deleted file mode 100644
index 2d1ce1cb0..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/House/WebCam.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Security-Cam",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "mqtt:\/\/localhost",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "cd3956ce-2fcb-d674-d59e-b903db3a4296",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "mqtt",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "1883",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "96bc14d5-8d0e-8bb9-f7cf-648fa3ad7e42",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 65812,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 55,\n \"Device Connected\": 55,\n \"Device Disonnected\": 55\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/House/iPhone.meta.json b/shredder/asterix-pp/asterix-hmi/devices/House/iPhone.meta.json
deleted file mode 100644
index 4d6a261e9..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/House/iPhone.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "iPhone",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.33",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "117554bc-f6ef-3442-f163-901d5d35d158",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "1b53dd5c-bda3-a45b-27ea-b1adb876d729",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"username\": \"root\",\n \"password\": \"alpine\"\n}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 51,\n \"Send Command\": 55\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/JSON-RPC/KODI-JSON-RPC.meta.json b/shredder/asterix-pp/asterix-hmi/devices/JSON-RPC/KODI-JSON-RPC.meta.json
deleted file mode 100644
index 3a795c63f..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/JSON-RPC/KODI-JSON-RPC.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "KODI-JSON-RPC",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "http:\/\/192.168.1.34:8080\/jsonrpc?tm=1481624757945",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "55ad4a31-2f0c-bfde-2338-b31bac6e56e5",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "driver",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "c486a884-1e85-0d19-42a6-3089191d889d",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 21,
- "uid": -1,
- "value": "{\n \"interface\": \"http\"\n}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "DriverOptions",
- "enabled": true,
- "flags": -1,
- "group": "Driver",
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "DriverOptions",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true,
- "enumType": "-1"
- },
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 33,\n \"Send Command\": 33\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz-Serial.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz-Serial.meta.json
deleted file mode 100644
index 97bf49968..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz-Serial.meta.json
+++ /dev/null
@@ -1,203 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Marantz-Serial",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "\/dev\/ttyUSB0",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "ffa5d764-cb4c-e6b7-2d5e-7d0a97994dc0",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "serial",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "59fed2f8-5289-9ae3-0243-7e347efc6965",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 33,\n \"Send Command\": 0,\n \"Device Disonnected\": 0,\n \"Device Error\": 0,\n \"Device Connected\": 0\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz.meta.json
deleted file mode 100644
index 16b26db6b..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Marantz/Marantz.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Marantz",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.20",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "235eb680-cb87-11e3-9c1a-0800200c9a66",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 13,
- "uid": -1,
- "value": "tcp",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "23",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "e5a06e24-6aa4-c8c5-3ffc-9d84d8528a91",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"allowHalfOpen\": true,\n \"readable\": true,\n \"writable\": true\n}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Device Connected\": 47,\n \"Response\": 35,\n \"Send Command\": 51,\n \"Device Disonnected\": 39,\n \"Device Error\": 1\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Raspberry/PI-GPIO.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Raspberry/PI-GPIO.meta.json
deleted file mode 100644
index d5087d04e..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Raspberry/PI-GPIO.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "PI-GPIO",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "0.0.0.0",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "91e6a9e2-d2cd-4258-c647-3e708ce4a749",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "driver",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "xxx2",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "8b2e512a-51d0-dc9d-60ee-f30281e0d691",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 16,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Device Disonnected\": 39,\n \"Response\": 35,\n \"Send Command\": 35\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Raspberry/Raspberry-One.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Raspberry/Raspberry-One.meta.json
deleted file mode 100644
index 300b2194d..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Raspberry/Raspberry-One.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Raspberry-One",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.36",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "40276f07-b0a8-f6bb-56f3-124b76262d5c",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "7da7b6a8-8ec1-4f2e-c10a-c414edb34adb",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\"username\":\"pi\",\"password\":\"asdasd\",\"html\":true}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/Raspberry-Build.meta.json b/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/Raspberry-Build.meta.json
deleted file mode 100644
index f47344f57..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/Raspberry-Build.meta.json
+++ /dev/null
@@ -1,203 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Raspberry-Build",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.33",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "f445e66f-467c-e7df-926d-f5694302ee5b",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "6f007f98-4770-f53a-3761-c052ca7db89a",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"username\": \"root\",\n \"password\": \"asdasd\"\n}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Local.meta.json b/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Local.meta.json
deleted file mode 100644
index c9806c068..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Local.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "SSH-Local",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.37",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "b08405ac-a878-351f-7bab-f4174de7e669",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "83a2e4ab-27b0-6c89-23c9-743ad6c40031",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"username\": \"mc007\",\n \"password\": \"214,,asd\",\n \"localhostName\": \"\",\n \"tryKeyboard\": false,\n \"keepaliveInterval\": 0,\n \"keepaliveCountMax\": 3,\n \"readyTimeout\": 11102,\n \"strictVendor\": true\n}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 51,\n \"Send Command\": 49\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Pearls-Media.meta.json b/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Pearls-Media.meta.json
deleted file mode 100644
index c4f9ee280..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Pearls-Media.meta.json
+++ /dev/null
@@ -1,203 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "SSH-Pearls-Media",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "pearls-media.com",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "ae5e86ab-3183-7dc9-4300-74e6cad50ac6",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "0592a125-227c-f0eb-ee46-4d3e1661729c",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\n \"username\": \"vu2003\",\n \"privateKeyPath\": \"\/home\/mc007\/.ssh\/id_rsa\"\n}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 16,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Windows.meta.json b/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Windows.meta.json
deleted file mode 100644
index 1a1f6c367..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/SSH-Servers/SSH-Windows.meta.json
+++ /dev/null
@@ -1,202 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "SSH-Windows",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "192.168.1.99",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "c8451d91-9167-ac64-92f8-25fda925d659",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "ssh",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "22",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "41cf1120-2ddb-9ad0-71fd-534df87203e6",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{\"username\":\"Admin\",\"password\":\"admin\",\"debug\":false,\"html\":false,\"waitForEOF\":true,\"ansiUp\":false}",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Shredder/Asterix.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Shredder/Asterix.meta.json
deleted file mode 100644
index 98c97be58..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Shredder/Asterix.meta.json
+++ /dev/null
@@ -1,139 +0,0 @@
-{
- "inputs": [
- {
- "name": "Title",
- "value": "Asterix",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": true,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Title",
- "params": null
- },
- {
- "name": "Host",
- "value": "COM21",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Host",
- "params": null
- },
- {
- "name": "Enabled",
- "value": true,
- "type": 0,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Enabled",
- "params": null
- },
- {
- "name": "Driver",
- "value": "5bd99163-aeac-c16e-baab-4fce4fc5803c",
- "type": 3,
- "enumType": "Driver",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Driver",
- "params": null
- },
- {
- "name": "Protocol",
- "value": "serial",
- "type": 3,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Protocol",
- "params": null
- },
- {
- "name": "Port",
- "value": "23",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Port",
- "params": null
- },
- {
- "name": "Id",
- "value": "349e4b1c-451a-61e8-4178-a976f9c8392e",
- "type": 13,
- "enumType": "-1",
- "visible": false,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Id",
- "params": null
- },
- {
- "name": "Options",
- "value": "{\n \"baudRate\": \"19200\",\n \"databits\": 8,\n \"stopbits\": 1,\n \"parity\": \"none\",\n \"rtscts\": false,\n \"xon\": false,\n \"xoff\": false,\n \"flowcontrol\": true,\n \"buffersize\": 65536\n}",
- "type": 21,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Options",
- "params": null
- },
- {
- "name": "DriverOptions",
- "value": 16,
- "type": 5,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Driver",
- "user": null,
- "dst": null,
- "id": "DriverOptions",
- "params": null
- },
- {
- "id": "Logging Flags",
- "name": "Logging Flags",
- "parentId": -1,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "value": "{\n \"Device Connected\": 47,\n \"Response\": 35,\n \"Send Command\": 51,\n \"Device Disonnected\": 39,\n \"Device Error\": 1\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Shredder/Plunger.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Shredder/Plunger.meta.json
deleted file mode 100644
index 9fb2eed6c..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Shredder/Plunger.meta.json
+++ /dev/null
@@ -1,139 +0,0 @@
-{
- "inputs": [
- {
- "name": "Title",
- "value": "Plunger",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": true,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Title",
- "params": null
- },
- {
- "name": "Host",
- "value": "COM19",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Host",
- "params": null
- },
- {
- "name": "Enabled",
- "value": false,
- "type": 0,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Enabled",
- "params": null
- },
- {
- "name": "Driver",
- "value": "6657b4bc-c41a-144b-ef4f-f9a8045eb457",
- "type": 3,
- "enumType": "Driver",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Common",
- "user": null,
- "dst": null,
- "id": "Driver",
- "params": null
- },
- {
- "name": "Protocol",
- "value": "serial",
- "type": 3,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Protocol",
- "params": null
- },
- {
- "name": "Port",
- "value": "23",
- "type": 13,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Port",
- "params": null
- },
- {
- "name": "Id",
- "value": "3eebdb07-1a76-2adb-6b43-d244faf2e00e",
- "type": 13,
- "enumType": "-1",
- "visible": false,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Id",
- "params": null
- },
- {
- "name": "Options",
- "value": "{\n \"baudRate\": \"250000\",\n \"databits\": 8,\n \"stopbits\": 1,\n \"parity\": \"none\",\n \"rtscts\": false,\n \"xon\": false,\n \"xoff\": false,\n \"flowcontrol\": true,\n \"buffersize\": 65536\n}",
- "type": 21,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Network",
- "user": null,
- "dst": null,
- "id": "Options",
- "params": null
- },
- {
- "name": "DriverOptions",
- "value": 16,
- "type": 5,
- "enumType": "-1",
- "visible": true,
- "active": false,
- "changed": false,
- "group": "Driver",
- "user": null,
- "dst": null,
- "id": "DriverOptions",
- "params": null
- },
- {
- "id": "Logging Flags",
- "name": "Logging Flags",
- "parentId": -1,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "value": "{\n \"Device Connected\": 47,\n \"Response\": 35,\n \"Send Command\": 51,\n \"Device Disonnected\": 39,\n \"Device Error\": 1\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback-Client.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback-Client.meta.json
deleted file mode 100644
index c591f98e1..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback-Client.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Loopback-Client",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "127.0.0.1",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "1961a5bd-29da-807c-affa-b59cba74b6cb",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "tcp",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "9999",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "e5644c28-542c-2475-8870-03ca02960e41",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 0,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Device Disonnected\": 39,\n \"Response\": 0,\n \"Send Command\": 0\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback.meta.json b/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback.meta.json
deleted file mode 100644
index 29de0d6a3..000000000
--- a/shredder/asterix-pp/asterix-hmi/devices/Tests/Loopback.meta.json
+++ /dev/null
@@ -1,204 +0,0 @@
-{
- "inputs": [
- {
- "dataRef": null,
- "description": "Title",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Title",
- "name": "Title",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Title",
- "type": 13,
- "uid": -1,
- "value": "Loopback",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Host",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Host",
- "name": "Host",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Host",
- "type": 13,
- "uid": -1,
- "value": "127.0.0.1",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Enabled",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Enabled",
- "name": "Enabled",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Enabled",
- "type": 0,
- "uid": -1,
- "value": false,
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Driver",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Driver",
- "name": "Driver",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver",
- "type": 3,
- "uid": -1,
- "value": "0f4a9e08-1def-f9ba-e996-b56c86e74524",
- "visible": true,
- "enumType": "Driver"
- },
- {
- "dataRef": null,
- "description": "Protocol",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Protocol",
- "name": "Protocol",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Protocol",
- "type": 3,
- "uid": -1,
- "value": "tcp",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Port",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Port",
- "name": "Port",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Port",
- "type": 13,
- "uid": -1,
- "value": "9999",
- "visible": true,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Id",
- "enabled": true,
- "flags": -1,
- "group": "Common",
- "id": "Id",
- "name": "Id",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Id",
- "type": 13,
- "uid": -1,
- "value": "3b687086-1613-9704-5e86-15c93ff54bf2",
- "visible": false,
- "enumType": "-1"
- },
- {
- "dataRef": null,
- "description": "Options",
- "enabled": true,
- "flags": -1,
- "group": "Network",
- "id": "Options",
- "name": "Options",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Options",
- "type": 28,
- "uid": -1,
- "value": "{}",
- "visible": true,
- "enumType": "-1"
- },
- false,
- false,
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": -1,
- "id": "DriverOptions",
- "name": "DriverOptions",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Driver Options",
- "type": 5,
- "uid": -1,
- "value": 65552,
- "visible": true
- },
- {
- "dataRef": null,
- "description": "",
- "enabled": true,
- "flags": -1,
- "group": "Logging",
- "id": "Logging Flags",
- "name": "Logging Flags",
- "order": -1,
- "params": null,
- "parentId": -1,
- "platform": null,
- "storeDestination": null,
- "title": "Logging Flags",
- "type": "Logging Flags",
- "uid": -1,
- "value": "{\n \"Response\": 51,\n \"Send Command\": 51,\n \"Device Disonnected\": 55,\n \"Device Connected\": 55\n}",
- "visible": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.js b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.js
deleted file mode 100644
index 7ba98800e..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.js
+++ /dev/null
@@ -1,636 +0,0 @@
-define([
- "dcl/dcl",
- "xide/utils",
- "xide/types",
- "xide/console",
- "xcf/model/Command",
- "xdojo/has!host-node?nxapp/protocols/ProtocolBase",
- "xdojo/has!host-node?dojo/node!yargs-parser"
-], function (dcl,utils,types, console,Command,ProtocolBase,yargs) {
- var five = null;
- var debug = true;
- // The returning module
- var Module = null;
-
- //the johnny-five module, set when connected.
- var JohnnyFive = null;
-
- // client side, return nothing
- if (!ProtocolBase) {
- //create dummy module
- Module = dcl(null, {});
- patchModule();
- return Module;
- }
-
-
- Module = dcl(ProtocolBase, {
- isNodeJS: true,
- board: null,
- context:null,
- inputs: {
- A0: {pin: {}, value: 0},
- A1: {pin: {}, value: 0},
- A2: {pin: {}, value: 0},
- A3: {pin: {}, value: 0},
- A4: {pin: {}, value: 0},
- A5: {pin: {}, value: 0}
- },
- outputs: {
- D1: {pin: {}, value: 0},
- D2: {pin: {}, value: 0},
- D3: {pin: {}, value: 0},
- D4: {pin: {}, value: 0},
- D5: {pin: {}, value: 0},
- D6: {pin: {}, value: 0},
- D7: {pin: {}, value: 0},
- D8: {pin: {}, value: 0},
- D9: {pin: {}, value: 0},
- D10: {pin: {}, value: 0},
- D11: {pin: {}, value: 0},
- D12: {pin: {}, value: 0},
- D13: {pin: {}, value: 0}
- },
- get: function(field) {
- if(this.inputs[field]){
- return this.inputs[field].value;
- }else{
- console.error('pin doesnt exists : ' + field,this.inputs);
- }
- },
- set: function(field, value) {
- value = parseInt(value,10);
-
- if(this.inputs[field] != undefined) {
-
- if(parseInt(this.inputs[field].value, 10) !== parseInt( value, 10 )) {
- this.inputs[field].value = value;
- //this.emit('change', {field: field, value: this.inputs[field].value});
- }
- }
- else if(this.outputs[field] !== undefined) {
- if(parseInt(this.outputs[field].value,10) !== parseInt(value,10)) {
- this.outputs[field].value = value;
- if(this.connected) {
- this.setHardwarePin(field, value);
- }
- }
- }
- return this;
- },
- setHardwarePin: function(field, value) {
- var outputField = this.outputs[field];
-
- if(outputField && outputField.pin) {
- var pinMode = outputField.pin.mode;
- }
-
- if(outputField !== undefined && (field === 'D3'
- || field === 'D5'
- || field === 'D6'
- || field === 'D9'
- || field === 'D10'
- || field === 'D11') ) {
- var pinMode = outputField.pin.mode;
-
- // Check which pinmode is set on the pin to determine which method to call
- if (pinMode === this.PINMODES.PWM || pinMode === this.PINMODES.OUTPUT) {
- this.outputs[field].pin.brightness(value);
-
- } else if(pinMode === this.PINMODES.SERVO) {
- this.outputs[field].pin.to(value);
- }
-
- // For reference:
- //MODES:
- //{ INPUT: 0,
- //OUTPUT: 1,
- //ANALOG: 2,
- //PWM: 3,
- //SERVO: 4,
- //SHIFT: 5,
- //I2C: 6,
- //ONEWIRE: 7,
- //STEPPER: 8,
- //IGNORE: 127,
- //UNKOWN: 16 },
-
- }
- else if(pinMode == this.PINMODES.OUTPUT) {
- var pinMode = outputField.pin.mode;
- if(value >= 255) {
- this.outputs[field].pin.on();
- }
- else {
- this.outputs[field].pin.off();
- }
- }
- },
- addDefaultPins:function(){
- var self = this;
- // Store all pin mode mappings (string -> integer)
- this.PINMODES = this.board.io.MODES;
-
- var pollFreq = 100;
-
- // Instantiate each sensor listed on the model to the sensors array
- for(var input in this.inputs) {
-
- (function() {
-
- if(!parseInt(input, 10)) {
- var sensor = JohnnyFive.Sensor({
- pin: input,
- freq: pollFreq
- });
-
- this.inputs[input].pin = sensor;
-
- sensor.scale([0, 1023]).on("data", function() {
- self.set('A'+this.pin, Math.floor(this.value));
- //console.log('sensor data '+'A'+this.pin,Math.floor(this.value));
- });
- }
- else {
- this.board.pinMode(input, JohnnyFive.Pin.INPUT);
- }
-
- }.bind(this))();
- }
-
-
- // Cycle through and add all the outputs here
- for(var output in this.outputs) {
- (function() {
- // hack for right now to hard code pin <3 as pwm, pin 9 as servo
- var pin = parseInt(output.substr(1),10);
- var outputPin;
-
- if (pin === 3 || pin === 5 || pin === 6 || pin === 10 || pin === 11 || pin === 9) {
- outputPin = new JohnnyFive.Led(pin);
- }
- //else if(pin === 9) {
- //outputPin = new five.Servo({
- //pin: pin,
- //range: [0,180],
- //});
- //}
-
- this.outputs[output].pin = outputPin;
-
- }.bind(this))();
- }
-
- },
- constructor:function(options){
- utils.mixin(this,options);
- },
- _sendError: function (data, command, options) {
- if(!options){
- console.error('have no options',options);
- options = {};
- }
- if(!options.params){
- console.error('have no params',options);
- options.params = {wait:true};
- }
- var wait = options.params.wait;
- var self = this;
- var outString = JSON.stringify(utils.mixin({
- command: command
- }, data, null, 2));
- if (wait) {
- self.owner.onError(command, options, new Buffer(outString));
- } else {
- self.owner.onData(outString, new Buffer(outString));
- }
- },
- setMode:function(nr,mode,options){
- var board = this.board;
- //nr = parseInt(nr,10);
- mode = parseInt(mode,10);
-
- //this.context.pinMode(nr,mode);
- this.setHardwarePin(nr,mode);
- },
- digitalWrite:function(nr,value,options){
- this.board.digitalWrite(parseInt(nr,10), parseInt(value,10));
- },
- digitalRead:function(nr,options){
- this.board.digitalRead(parseInt(nr,10),function(value){
- console.log('digitalRead: ',value);
- this._send({
- value:value,
- gpio:nr
- },'digitalRead',options);
- }.bind(this));
- },
- _send: function (data, command, options) {
- var wait = options.params.wait;
- var self = this;
- var outString = JSON.stringify(utils.mixin({
- command: command
- }, data, null, 2));
-
- if (wait) {
- self.owner.onFinish(command, options, new Buffer(outString));
- } else {
- self.owner.onData(outString, new Buffer(outString));
- }
- },
- analogRead:function(nr,options){
- var self = this;
- /*
- var handler = function(value){
- console.log('analogRead: ',value);
- self._send({
- value:value,
- gpio:nr
- },'analogRead',options);
- }.bind(this);
-
- //this.board.analogRead.apply(this.board,[parseInt(nr,10),handler]);
- this.context.analogRead(parseInt(nr,10),handler);*/
-
- self._send({
- value:this.get(nr,10),
- gpio:parseInt(nr,10)
- },'analogRead',options);
-
- },
- /**
- *
- * @param what {string} A string encoded byte array in the 01,02,... format
- * @returns {null}
- */
- write:function(what,options){
- var _parsed = null;
- //convert buffer from byte array string to string
- var intArray = utils.bufferFromDecString(what);
- var buffer = new Buffer(intArray);
-
- what = buffer.toString();
-
- var args = what.split(" ");
- var cmd = "" + args[0];
- args.shift();
-
- this.isDebug() && console.log('write : ' + what, args);
-
- if (typeof this[cmd] === 'function') {
- args.push(options);
- try {
- return this[cmd].apply(this, args);
- }catch(e){
- console.error('Error running '+cmd + " : " + e.message);
- this._sendError({
- error:e.message
- },cmd,options);
- }
- }else{
- console.error('cant find command '+cmd);
- }
-
- return;
-
- try {
- _parsed = (new Function("{\n" + what + "\n}")).apply(this.context,[console,this]);
- }catch(e) {
- console.error('Arduino: Error running code : ' + e.message, e);
- console.trace();
- this.owner.onError(what, e);
- utils.stack();
- }
-
- debug && console.log('Arduino,result '+_parsed);
- return null;
- },
- onButton:function(){
- console.log('on button');
- //send to IDE or clients
- this.owner.onData("on button");
- },
- onConnected:function(){
- this.owner.onConnected();
- },
- onInfo:function(evt){
- var owner=this.owner;
- var connectionManager = owner.delegate;
- connectionManager.onData(owner,evt);
- },
- connect: function () {
- var five = null;
- var self = this;
- try {
- five = require(["dojo/node!johnny-five"],function(_five){
- JohnnyFive = _five;
- five = _five;
- var myBoard;
- try {
- //if(global['_j5_context']) {
-
- if(global['_j5_context'] && global['_j5_context'][self.options.host]){
- console.error('re-use!');
- self.context = global['_j5_context'][self.options.host].context;
- self.board = global['_j5_context'][self.options.host].board;
- self.inputs = global['_j5_context'][self.options.host].inputs;
- self.outputs = global['_j5_context'][self.options.host].outputs;
- self.connected = true;
- self.onConnected();
- return;
- }
-
- myBoard = new five.Board({
- repl: false,
- debug: false,
- port: self.options.host
- });
-
- myBoard.on("error", function (e) {
- console.error('johnny-five ', e);
- self._sendError(e['class'] + ':' + e.message, 'connect', self.options);
- })
- myBoard.on("ready", function () {
- self.context = this;
- self.context.j5 = _five;
- self.context.log = console.log;
- self.board = myBoard;
- self.addDefaultPins();
- self.connected = true;
- self.onConnected();
-
-
- if(!global['_j5_context']){
- global['_j5_context'] = {}
- }
- global['_j5_context'][self.options.host] = {
- context:self.context,
- board:myBoard,
- inputs : self.inputs,
- outputs : self.outputs
- };
- });
-
- myBoard.on("info", function (event) {
- self.onInfo(event);
- //console.log("%s sent an 'info' message: %s", event.class, event.message);
- });
-
- }catch(e){
- console.error('----'+ e.message,e.stack);
- utils.stack();
- }
- });
- }catch(e){
- console.error('error requiring '+ e.message,e);
- }
- },
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage: function (data) {},
- end:function(){
- console.error('disconnect');
- if(this.context){
- this.context.disconnect();
- this.board = null;
- }
- },
- destroy: function () {
- console.error('disconnect');
- if(this.context){
- this.board = null;
- }
- }
- });
-
- Module.is = function(){
- return types.PROTOCOL.SERIAL;
- };
-
- function patchModule(){
-
- var PIN_MODES = {
- INPUT: 0x00,
- OUTPUT: 0x01,
- ANALOG: 0x02,
- PWM: 0x03,
- SERVO: 0x04
- };
-
- Module.getFields = function (command, fields) {
- var result = [];
- //add a GPIO field
- if(command._isGPIO) {
- command._gpio = command._gpio || 17;
- result.push(utils.createCI('test', types.ECIType.STRING, command._gpio, {
- group: 'GPIO',
- title: 'GPIO',
- dst: '_gpio',
- order: 197
- }));
- }
-
- //add gpio mode field
- if(command._gpioFunc === 'setMode') {
- command._mode = command._mode || "OUTPUT";
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._mode, {
- group: 'GPIO',
- title: 'Mode',
- dst: '_mode',
- order: 198,
- widget:{
- options:[
- {value:PIN_MODES.INPUT,label:"INPUT"},
- {value:PIN_MODES.OUTPUT,label:"OUTPUT"},
- {value:PIN_MODES.ANALOG,label:"ANALOG"},
- {value:PIN_MODES.PWM,label:"PWM"},
- {value:PIN_MODES.SERVO,label:"SERVO"}
- ]
- }
- }));
- }
-
- if(command._gpioFunc === 'digitalWrite') {
- command._value = command._value || 1;
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._value, {
- group: 'GPIO',
- title: 'Value',
- dst: '_value',
- order: 199,
- widget:{
- options:[
- {value:0,label:"0"},
- {value:1,label:"1"}
- ]
- }
- }));
- }
-
- if(command._gpioFunc === 'analogWrite') {
- command._value = command._value || 1;
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._value, {
- group: 'GPIO',
- title: 'Value',
- dst: '_value',
- order: 199,
- widget:{
- options:[
- {value:0,label:"0"},
- {value:1,label:"1"}
- ]
- }
- }));
- }
-
-
- return result;
- };
- /**
- *
- * @param label
- * @param icon
- * @param ctrAgs
- * @param variables
- * @param send
- * @param func
- * @param description
- * @param scope
- * @param owner
- * @param target
- * @param group
- */
- function createBlock(label,icon,ctrAgs,variables,send,func,description,scope, owner, target, group){
- return {
- name: label,
- owner: owner,
- icon: icon,
- proto: Command,
- target: target,
- ctrArgs: utils.mixin({
- icon:icon,
- flags:0,
- name:label,
- scope: scope,
- group: group,
- variables:variables ? JSON.stringify(variables) : "{}",
- send:send,
- _isGPIO:true,
- _gpioFunc:func,
- description:description
- },ctrAgs)
- };
- }
-
- /**
- * Extend xblox for new blocks/commands.
- * @param scope
- * @param owner
- * @param target
- * @param group
- * @param items
- * @returns {*}
- */
- Module.getNewBlocks=function(scope, owner, target, group, items){
-
- if(!items){
- return null;
- }
- items.push({
- name: 'Johnny-Five',
- iconClass: 'fa-code',
- items: [
- createBlock('Set GPIO Mode','fa-cogs',null,
- { 'GPIO': '_gpio','GPIO_MODE': '_mode'},
- "setMode {{GPIO}} {{GPIO_MODE}}","setMode",
- "Set the mode of a specific pin, one of INPUT, OUTPUT, ANALOG, PWM, SERVO. Mode constants are exposed via the Pin class",
- scope,owner,target,group),
-
- createBlock('Digital Write','fa-send',null,
- { 'GPIO': '_gpio','GPIO_VALUE': '_value'},
- "digitalWrite {{GPIO}} {{GPIO_VALUE}}","digitalWrite",
- "Write a digital value (0 or 1) to a digital pin.",
- scope,owner,target,group),
-
- createBlock('Digital Read','fa-send',null,
- { 'GPIO': '_gpio'},
- "digitalRead {{GPIO}}","digitalRead",
- "Returns the GPIO level",
- scope,owner,target,group),
-
- createBlock('Analog Read','fa-send',null,
- { 'GPIO': '_gpio'},
- "analogRead {{GPIO}}","analogRead",
- "Register a handler to be called whenever the board reports the voltage value (0-1023) of the specified analog pin.",
- scope,owner,target,group),
-
- createBlock('Analog Write','fa-send',null,
- { 'GPIO': '_gpio'},
- "analogWrite {{GPIO}} {{GPIO_VALUE}}","analogWrite",
- "Write an unsigned, 8-bit value (0-255) to an analog pin.",
- scope,owner,target,group)
- ]
- });
- return items;
- };
- /**
- * Override interface for "toText"
- * @param command
- * @param text
- * @returns {*}
- */
- Module.toText = function (command, text) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
-
- for(var variable in commandVariables){
- variables[variable]=command[commandVariables[variable]] || " ";
- }
- text = utils.replace(text,null,variables,{
- begin:'{{',
- end:'}}'
- });
- return text;
- }
-
- };
- Module.resolveAfter = function (command,inputString) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
- for(var variable in commandVariables){
- variables[variable]=command._resolve(command[commandVariables[variable]],{
- flags:0x00000800
- },false);
- }
- inputString = utils.replace(inputString,null,variables,{
- begin:'{{',
- end:'}}'
- });
- }
- return inputString;
- };
- }
-
- patchModule();
-
- return Module;
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.meta.json
deleted file mode 100644
index aa010caff..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "Arduino",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "aa504ee4-6cd3-8a5e-4654-56294ef78fd6",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./Arduino/Arduino.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"<<\",\"end\":\">>\"},\"send\":{\"mode\":false,\"interval\":\"2000\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.xblox
deleted file mode 100644
index e0be6e6cb..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/Arduino.xblox
+++ /dev/null
@@ -1,186 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "name": "LED STATUS",
- "group": "basicVariables",
- "id": "569e8f22-e470-ef80-27d8-70b4b04e3485",
- "type": "added",
- "icon": "fa-bullseye",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": -1,
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "id": "18c655ff-f9f1-66a5-504b-89034fe3f274",
- "name": "value",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "name": "A3",
- "group": "basicVariables",
- "id": "77b335c4-0a6c-942e-81d4-3f01c550179d",
- "value": 396,
- "type": "added",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "PowerOff",
- "id": "075f0201-74a7-9470-63b4-a69f32c8899a",
- "send": "1;2;32;1;Power:off:1",
- "type": "added",
- "flags": 0,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "PowerOn",
- "id": "dc862aaf-b934-d9a7-93e2-48a538bfda4c",
- "send": "1;2;32;1;Power:on:1",
- "type": "added",
- "flags": 0,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Reverse",
- "id": "d8739058-ad1b-3c9f-a202-c0a50e4bc43f",
- "send": "1;2;32;1;VFD:rev:1",
- "type": "added",
- "flags": 0,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Forward",
- "id": "ed847438-9f8e-c8ec-cce7-10a97a4a1da3",
- "send": "1;2;32;1;VFD:fwd:1",
- "type": "added",
- "auto": false,
- "interval": "1600",
- "flags": 0,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Stop",
- "id": "c77785cc-4821-0fae-ba62-03333b6fd65a",
- "send": "1;2;32;1;VFD:stop:1",
- "type": "added",
- "flags": 0,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "conditionalProcess",
- "id": "89318503-6ae3-d7a0-cac2-5100ab7fefd5",
- "type": "added",
- "method": "var message = arguments[0].string;\nconsole.log(\"message: \", message);\n\n",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.js b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.js
deleted file mode 100644
index 180f7393a..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.js
+++ /dev/null
@@ -1,24 +0,0 @@
-define(["dcl/dcl"], function(dcl){
- return dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- },
- test:function(){
- //send a message :
- this.sendMessage('pwon',true);//sends message to device , respecting start & end settings . forcing now!
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.meta.json
deleted file mode 100644
index 08e08e432..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "CNC",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "e208711c-a51c-8d8a-41f2-883cd95ac7c4",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./Arduino/CNC.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"0x0d\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"0x0a\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.xblox
deleted file mode 100644
index 4d84a6e93..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/CNC.xblox
+++ /dev/null
@@ -1,311 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "id": "292a3664-6002-d77f-3a56-dfd7df94b33f",
- "name": "value",
- "value": "ok",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "52289d34-f411-2658-014c-c9afa36df11c",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M101",
- "name": "Extruder on, fwd",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "b311f313-eeec-f5a1-7cb5-63fb0fb96691",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M103",
- "name": "Extruder off,",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "b2576b63-15f6-91b6-6eda-09a624dcb96e",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M128",
- "name": "Get Postion",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "dc056e30-0b3e-3b50-2902-dbdd8b51dcda",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M106",
- "name": "FAN On",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "190ba358-b460-5881-e943-4c720fe35009",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M107",
- "name": "FAN Off",
- "interval": "0",
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "basic",
- "id": "119ecf16-5744-1d96-78b0-205a024d1229",
- "items": [
- "e566a3b2-a6e6-7fcb-5073-c3728567040d",
- "7a23a3cf-48ee-33f6-da04-1855df9461aa",
- "3f5f6894-65c3-f4aa-5967-e93649bdb063",
- "3d9b7428-9852-fceb-2b8c-53ba3b39b64c"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "",
- "name": "Test Move X",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "id": "e566a3b2-a6e6-7fcb-5073-c3728567040d",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G91",
- "name": "G91",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Relative Positioning",
- "order": 0,
- "type": "added",
- "parentId": "119ecf16-5744-1d96-78b0-205a024d1229"
- },
- {
- "_containsChildrenIds": [],
- "id": "7a23a3cf-48ee-33f6-da04-1855df9461aa",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G0 X10.0 F3000",
- "name": "Move 1 on X",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Absolute Positioning",
- "order": 0,
- "type": "added",
- "parentId": "119ecf16-5744-1d96-78b0-205a024d1229"
- },
- {
- "_containsChildrenIds": [],
- "id": "3f5f6894-65c3-f4aa-5967-e93649bdb063",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G90",
- "name": "G90",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Absolute Positioning",
- "order": 0,
- "type": "added",
- "parentId": "119ecf16-5744-1d96-78b0-205a024d1229"
- },
- {
- "_containsChildrenIds": [],
- "id": "3d9b7428-9852-fceb-2b8c-53ba3b39b64c",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M114",
- "name": "Get Current Position",
- "interval": "0",
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "parentId": "119ecf16-5744-1d96-78b0-205a024d1229"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "basic",
- "id": "2fb7c3a8-8f34-8cae-0213-46deda3555c0",
- "items": [
- "a5c56481-03c3-38a7-b58c-e5d128930421",
- "eff574ed-4959-2efc-e076-25b5c6f7501b",
- "a9426989-3564-7ab8-60c3-8d611b5e4a03",
- "4852cb65-9bca-fb63-6510-1b84dde39b84"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "",
- "name": "Test Move Y",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "id": "a5c56481-03c3-38a7-b58c-e5d128930421",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G91",
- "name": "G91",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Relative Positioning",
- "order": 0,
- "type": "added",
- "parentId": "2fb7c3a8-8f34-8cae-0213-46deda3555c0"
- },
- {
- "_containsChildrenIds": [],
- "id": "eff574ed-4959-2efc-e076-25b5c6f7501b",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G0 Y10.0 F3000",
- "name": "Move 1 on Y",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Absolute Positioning",
- "order": 0,
- "type": "added",
- "parentId": "2fb7c3a8-8f34-8cae-0213-46deda3555c0"
- },
- {
- "_containsChildrenIds": [],
- "id": "a9426989-3564-7ab8-60c3-8d611b5e4a03",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "G90",
- "name": "G90",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "Set Absolute Positioning",
- "order": 0,
- "type": "added",
- "parentId": "2fb7c3a8-8f34-8cae-0213-46deda3555c0"
- },
- {
- "_containsChildrenIds": [],
- "id": "4852cb65-9bca-fb63-6510-1b84dde39b84",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "M114",
- "name": "Get Current Position",
- "interval": "0",
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "parentId": "2fb7c3a8-8f34-8cae-0213-46deda3555c0"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/package.json b/shredder/asterix-pp/asterix-hmi/drivers/Arduino/package.json
deleted file mode 100644
index 8cf7bc67a..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Arduino/package.json
+++ /dev/null
@@ -1,15 +0,0 @@
-{
- "name": "CF-Raspberry",
- "version": "1.0.0",
- "description": "",
- "main": "PI-GPIO.js",
- "scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
- },
- "keywords": [],
- "author": "",
- "license": "ISC",
- "dependencies": {
- "johnny-five": "^0.10.6"
- }
-}
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.js b/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.js
deleted file mode 100644
index 742f3fe87..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @module xcf/driver/DefaultDriver */
-define([
- "dcl/dcl",
- 'xdojo/has',
- 'xide/utils'
-], function (dcl, has, utils) {
-
- // The returning module
- var Module = null;
-
- //////////////////////////////////////////////////////////
- //
- // Constants
- //
- var isServer = has('host-node'); // We are running server-side ?
- var isIDE = has('xcf-ui'); // We are running client-side and in the IDE?
-
- /**
- * Default driver template. This will used for new drivers!
- *
- * @class module:xcf/driver/DefaultDriver
- * @extends module:xcf/driver/DriverBase
- * @augments module:xide/mixins/EventedMixin
- * @link http://rawgit.com/net-commander/windows-dist/master/docs/Driver/modules/module-xcf_driver_DriverBase.html
- */
- Module = dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- //onMessage: function (data) {}
- });
-
-
- //////////////////////////////////////////////////////////
- //
- // Optional: An example implementation to extend commands in the interface for additional fields
- //
- if (isIDE) {
- /**
- *
- * @param command {module:xcf/model/Command} The command which for which want to populate the fields.
- * @param fields {Object[]}
- * @link http://rawgit.com/net-commander/windows-dist/master/docs/Driver/modules/xcf_model_Command.js.html
- */
- Module.getFields = function (command, fields) {
- /*
- return [utils.createCI('test', 0, command.test, {
- group: 'General',
- title: 'test',
- dst: 'test',
- order: 198
- })];
- */
- return [];
- };
- }
-
- //////////////////////////////////////////////////////////
- //
- // Optional: An example implementation to modify the string sent to a advice. This makes sense if you added additional fields as shown above.
- //
- /**
- * Callback when a command is before parsing the expression in the "send" field.
- * @param command {module:xcf/model/Command}
- * @param inputString {string}
- * @returns {string}
- */
- /*
- Module.resolveBefore = function (command,inputString) {
- return inputString;
- };
- */
- /**
- * Callback when a command was parsing the expression in the "send" field.
- * @param command {module:xcf/model/Command}
- * @param inputString {string}
- * @returns {string}
- */
- /*
- Module.resolveAfter = function (command,inputString) {
- return inputString;
- };
- */
-
- return Module;
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.meta.json
deleted file mode 100644
index 99b7e4ba8..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.meta.json
+++ /dev/null
@@ -1,168 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "Lydia-v3",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "b22efaaa-0122-63df-c073-63b9784e7b1d",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./Extrusion/Lydia-v3.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.xblox
deleted file mode 100644
index c3ae61200..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Extrusion/Lydia-v3.xblox
+++ /dev/null
@@ -1,62 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Extrude",
- "id": "d5c11168-db1e-5d66-0091-9bfcce710ccd",
- "type": "added",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "fwd",
- "interval": 0,
- "flags": 2048,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Stop",
- "id": "f9473067-0159-9e1f-5308-9cc51580ad39",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "rev",
- "interval": 0,
- "flags": 2048,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "condition": "",
- "name": "Velocity",
- "id": "c56e0a6f-e5dc-1ef6-6551-86102fdd3318",
- "send": "vsi-%speed%",
- "type": "added",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "flags": 2048,
- "icon": "fa-exclamation",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.js b/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.js
deleted file mode 100644
index 180f7393a..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.js
+++ /dev/null
@@ -1,24 +0,0 @@
-define(["dcl/dcl"], function(dcl){
- return dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- },
- test:function(){
- //send a message :
- this.sendMessage('pwon',true);//sends message to device , respecting start & end settings . forcing now!
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.meta.json
deleted file mode 100644
index 69a4f9ee8..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "WebCam",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "cd3956ce-2fcb-d674-d59e-b903db3a4296",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": ".\/project1\/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": ".\/House\/WebCam.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.xblox b/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.xblox
deleted file mode 100644
index f72e5ebea..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/WebCam.xblox
+++ /dev/null
@@ -1,143 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "105c6870-86ce-a275-bbd3-2dd158b1074d",
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Cam move",
- "topic": "camMove",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "camMove",
- "qos": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "items": [
- "9fc90c77-3cbf-1dec-0dab-6a65534d3ea0",
- "bf7f0b01-2f08-8750-4ef7-dd439fa5f974",
- "d932e1ab-f0ae-6b87-8149-42be007247bc"
- ]
- },
- {
- "_containsChildrenIds": [],
- "id": "c8f38e6e-2697-bedd-42bc-069e184036e6",
- "name": "value",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "105c6870-86ce-a275-bbd3-2dd158b1074d",
- "id": "9fc90c77-3cbf-1dec-0dab-6a65534d3ea0",
- "declaredClass": "xblox.model.functions.CallBlock",
- "command": "command://deviceScope=user_devices&device=deda59c1-0386-bb6c-548d-8b0300736e0e&driver=52f4b5dd-889d-a5c9-0221-edaa0dce1a6f&driverScope=user_drivers&block=6253e301-a9ee-f03c-87a4-cb4666ce00f8",
- "icon": "",
- "_timeout": 100,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "5ad2654e-d325-007d-f7ee-1f2e8a022753",
- "items": [
- "aa830cbe-8870-dd00-9ad4-ba10ade4baf3"
- ],
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "camMoveStopped",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "",
- "qos": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "5ad2654e-d325-007d-f7ee-1f2e8a022753",
- "id": "aa830cbe-8870-dd00-9ad4-ba10ade4baf3",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "console.error('not moving');",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "105c6870-86ce-a275-bbd3-2dd158b1074d",
- "id": "bf7f0b01-2f08-8750-4ef7-dd439fa5f974",
- "declaredClass": "xblox.model.functions.CallBlock",
- "command": "command://deviceScope=user_devices&device=1b53dd5c-bda3-a45b-27ea-b1adb876d729&driver=117554bc-f6ef-3442-f163-901d5d35d158&driverScope=user_drivers&block=2d2ce608-9a1f-18d6-5298-fefcd85f8bc9",
- "icon": "",
- "_timeout": 100,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "105c6870-86ce-a275-bbd3-2dd158b1074d",
- "id": "d932e1ab-f0ae-6b87-8149-42be007247bc",
- "declaredClass": "xblox.model.logging.Log",
- "name": "Log Message",
- "level": "info",
- "message": "return \"Something Moved \";",
- "_type": "XBlox",
- "host": "this host",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "icon": "fa-play"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.js b/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.js
deleted file mode 100644
index 180f7393a..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.js
+++ /dev/null
@@ -1,24 +0,0 @@
-define(["dcl/dcl"], function(dcl){
- return dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- },
- test:function(){
- //send a message :
- this.sendMessage('pwon',true);//sends message to device , respecting start & end settings . forcing now!
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.meta.json
deleted file mode 100644
index a0ccab558..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "iphone",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "117554bc-f6ef-3442-f163-901d5d35d158",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": ".\/project1\/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": ".\/House\/iphone.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.xblox b/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.xblox
deleted file mode 100644
index 50f1e8f5b..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/House/iphone.xblox
+++ /dev/null
@@ -1,63 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "2d2ce608-9a1f-18d6-5298-fefcd85f8bc9",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "return \"sh /install/alarm.sh\"",
- "name": "Alarm",
- "interval": "0",
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "id": "c615e748-66fa-5638-dde7-bb82fdc08231",
- "name": "value",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "4bfd6f39-e95c-edfc-cd19-f8dff7a2a78b",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "ls",
- "name": "ls",
- "interval": "0",
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.js b/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.js
deleted file mode 100644
index 1f126502b..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.js
+++ /dev/null
@@ -1,290 +0,0 @@
-/** @module nxapp/protocols/JSON-RPC */
-define([
- 'dcl/dcl',
- "xide/utils",
- "xide/types",
- 'xdojo/has!host-node?nxapp/protocols/ProtocolBase',
- "dojo/Deferred",
- 'xdojo/has',
- "xcf/model/Command"
-],function(dcl,utils,types,ProtocolBase,Deferred,has,Command){
-
- var debug = true;
- var debugData = true;
- // The returning module
- var Module = null;
- //////////////////////////////////////////////////////////
- //
- // Constants
- //
- var isServer = has('host-node'); // We are running server-side ?
- var isIDE = has('xcf-ui'); // We are running client-side and in the IDE?
-
- //No ProtocolBase means we're running on client side
- if (!ProtocolBase) {
- //create dummy module
- Module = dcl(null, {});
- patchModule();
- return Module;
- }
- /**
- * MQTT protocol mqttClient
- * @class module:nxapp/protocols/MQTT
- * @extends module:nxapp/protocols/ProtocolBase
- */
- Module = dcl(ProtocolBase,{
- declaredClass:"nxapp.protocols.JSON-RPC",
- _socket:null,
- protocolName:'json-rpc',
- instance:null,
- getOptions:function(host,port,deviceOptions){
- var options = {
- };
- return utils.mixin(options,deviceOptions);
- },
- onConnected:function(){
- this.owner.onConnected();
- },
- onError:function(error,options) {
- this.delegate.onError(this.connection,utils.mixin({
- code:error
- },options),this.options);
- },
- onClose:function(data) {
- this.delegate.onClose(this.connection,data);
- },
- _client:null,
- connect:function(){
- var _options = this.options;
- if(!_options || !_options.driver){
- debug || this.isDebug() && console.error('no driver in options',_options);
- return this;
- }
- var host = _options.host;
- var port = _options.port;
- var deviceOptions = utils.getJson(_options.options || {});
- if(deviceOptions.debug===true){
- debug = true;
- }
- var self = this;
- this.getModule('jayson').then(function(jayson){
- try {
- self._client = jayson.client[deviceOptions.interface](host);
- self.onConnected();
- }catch(e){
- console.error('error creating client',e);
- }
- });
-
- this.host = host;
- this.port = port;
- this.protocol = this.protocolName;
- this._socket = {};
- this._socket.writable=true;
- return this;
- },
- onData:function(evt,buffer){
- debugData || this.isDebug() && console.log('MQTT->onData ' + evt.topic,utils.inspect(evt));
- this.delegate.onData(this.connection,evt,buffer);
- },
- onCommandError:function(cmd,options){
- debug || this.isDebug() && console.log('MQTT->CommandError ' + cmd + ' id ' + options.id + ' src ' + options.src);
- try {
- this.delegate.onData(this.connection, utils.mixin({
- cmd: cmd,
- event: types.EVENTS.ON_COMMAND_ERROR
- },options));
- }catch(e){
- console.error('---',e);
- }
- },
- onFinish:function(cmd,options,buffer){
- debug || this.isDebug() && console.log('MQTT onFinish ' + cmd + ' id ' + options.id + ' src ' + options.src);
- try {
- this.delegate.onData(this.connection, utils.mixin({
- cmd: cmd,
- event: types.EVENTS.ON_COMMAND_FINISH
- },options),buffer);
- }catch(e){
- console.error('onFinish-Error:',e);
- }
- },
- /**
- *
- * @param data {string} A string encoded byte array in the 01,02,... format
- * @param command
- * @param options
- * @private
- */
- _send: function (data, command, options) {
- var wait = options.params.wait;
- var self = this;
- var outString = JSON.stringify(utils.mixin({
- command: command
- }, data, null, 2));
-
- if (wait) {
- self.owner.onFinish(command, options, new Buffer(outString));
- } else {
- self.owner.onData(outString, new Buffer(outString));
- }
- },
- write:function(what,options) {
- var _parsed = null;
- //convert buffer from byte array string to string
- var intArray = utils.bufferFromDecString(what);
- var buffer = new Buffer(intArray);
- what = buffer.toString();
- var self = this;
- try {
- var args = utils.getJson(options.params.args);
- if(!_.isArray(args)){
- args = [];
- }
- this._client.request(what,args, function (err, response) {
- if (err) {
- console.error('error: ', err);
- }
- self._send({
- value: response.result
- }, 'request ' + what + '(' + JSON.stringify(args)+')', options);
- });
- }catch(e){
- console.error("error making client request");
- }
- },
- send:function(cmd,options) {
-
- return;
- },
- close:function() {
-
- }
- });
-
- function patchModule(){
- /**
- *
- * @param label
- * @param icon
- * @param ctrAgs
- * @param variables
- * @param send
- * @param func
- * @param description
- * @param scope
- * @param owner
- * @param target
- * @param group
- */
- function createBlock(label,icon,ctrAgs,variables,send,func,description,scope, owner, target, group){
- return {
- name: label,
- owner: owner,
- icon: icon,
- proto: Command,
- target: target,
- ctrArgs: utils.mixin({
- icon:icon,
- flags:32768,
- name:label,
- scope: scope,
- group: group,
- send:send,
- _isJSONRPC:true,
- _func:func,
- description:description
- },ctrAgs)
- };
- }
-
- Module.getFields = function (command, fields) {
- var result = [];
- if (command._isJSONRPC) {
- command._args = command._args || {};
- result.push(utils.createCI('arguments',types.ECIType.ARGUMENT,command._args,{
- group:'Arguments',
- title:'Arguments',
- dst:'_args'
- }));
- }
- return result;
- };
-
- /**
- * @param command
- * @returns {*|{}}
- */
- Module.getCommandArgs = function (command) {
- return command._args;
- };
-
- /**
- * Extend xblox for new blocks/commands.
- * @param scope
- * @param owner
- * @param target
- * @param group
- * @param items
- * @returns {*}
- */
- Module.getNewBlocks=function(scope, owner, target, group, items){
- if(!items){
- return null;
- }
- items.push({
- name: 'JSON-RPC',
- iconClass: 'fa-code',
- items: [
- createBlock('Request','fa-send',null,
- { 'GPIO': '_gpio'},
- "request","request",
- "",
- scope,owner,target,group)
- ]
- });
- return items;
- };
-
- Module.options = function (query) {
- try {
- var dfd = new Deferred();
- var ECIType = types.ECIType;
- var NetworkGroup = 'Network';
- function createOption(label, value) {
- return {
- label: label,
- value: value
- }
- }
- var cis = [
- utils.createCI('interface', ECIType.ENUMERATION,'', {
- group: NetworkGroup,
- title:'Interface',
- description:"",
- value:'http',
- options:[
- createOption('Tcp','tcp'),
- createOption('Tls','tls'),
- createOption('HTTP','http'),
- createOption('HTTPS','https')
- ]
- })
-
- ];
- dfd.resolve(cis);
- return dfd;
- } catch (e) {
- console.error('error', e);
- }
- return dfd;
- };
- }
- Module._is=function(){
- return types.PROTOCOL.TCP;
- };
-
- patchModule();
-
- return Module;
-});
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.meta.json
deleted file mode 100644
index 3afd6ec6c..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "JSON_RPC",
- "visible": true,
- "_active": false,
- "changed": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "55ad4a31-2f0c-bfde-2338-b31bac6e56e5",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./JSON_RPC/JSON_RPC.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "[]",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.xblox b/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.xblox
deleted file mode 100644
index c06b5424e..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/JSON_RPC/JSON_RPC.xblox
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [
- "items"
- ],
- "icon": "fa-send",
- "flags": 32768,
- "name": "Request",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\"}",
- "send": "Player.GetActivePlayers",
- "_isJSONRPC": true,
- "_func": "request",
- "description": "",
- "id": "7596452c-d283-6463-1ebc-781e780c6e94",
- "type": "added",
- "_args": "[]",
- "items": [
- "e7931261-cf51-2fe9-1018-297e6a9ace36"
- ],
- "startup": true,
- "auto": false,
- "declaredClass": "xcf.model.Command",
- "interval": 0,
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "id": "197d85f1-f8b0-3ab0-4960-dd49d5929dfd",
- "name": "value",
- "value": "",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "7596452c-d283-6463-1ebc-781e780c6e94",
- "id": "e7931261-cf51-2fe9-1018-297e6a9ace36",
- "method": "console.log('result',arguments);",
- "outlet": 8,
- "type": "added",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "order": 0,
- "enabled": true,
- "shareTitle": ""
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.js b/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.js
deleted file mode 100644
index 6f705daad..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.js
+++ /dev/null
@@ -1,33 +0,0 @@
-define(["module","dcl/dcl"], function(module,dcl){
- return dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
-
- //let driver base do its job:
- //this.inherited(arguments);
-
-
- console.log('message : 2',data);
-
-
- },
- test:function(){
-
- //send a message :
- this.sendMessage('pwon',true);//sends message to device , respecting start & end settings . forcing now!
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.meta.json
deleted file mode 100644
index 830d278b5..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "Kodi-MQTT",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "8fec6dd4-f647-291d-0a9b-27eea266f6d0",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": ".\/project1\/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": ".\/Kodi\/MQTT.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.xblox
deleted file mode 100644
index 59c2a9374..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Kodi/MQTT.xblox
+++ /dev/null
@@ -1,407 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "parentId": "eda78a69-707f-2841-9418-66311495c955",
- "id": "42c1fc32-f30b-8480-1774-077ec433dc63",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "log",
- "method": "console.log('mqtt message ' + arguments[0]);",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "enabled": true,
- "shareTitle": "",
- "description": "Runs an expression.
\n\nBehaviour\n\n\n\n //to abort execution (child blocks), return something negative as -1 or false.\n return false;\n\n
",
- "order": 0,
- "type": "added",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "id": "c09e8c2d-9b1d-b7cf-1f9e-13a78215b13c",
- "name": "value",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "value": -1,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "eda78a69-707f-2841-9418-66311495c955",
- "items": [
- "42c1fc32-f30b-8480-1774-077ec433dc63"
- ],
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "192.168.1.20/23/Variable/Volume",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "value",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "540ed71b-8f87-d9fd-a900-085d2ba7ae0f",
- "items": [
- "704253d9-1352-0ab6-8f89-51d51d6725fc"
- ],
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "kodi/connected",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Kodi-Connected",
- "group": "basicVariables",
- "id": "a782d2ff-200c-5262-d21f-79fc4012fae2",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": "0",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "variable": "a782d2ff-200c-5262-d21f-79fc4012fae2",
- "variableId": "c09e8c2d-9b1d-b7cf-1f9e-13a78215b13c",
- "value": "",
- "parentId": "540ed71b-8f87-d9fd-a900-085d2ba7ae0f",
- "id": "704253d9-1352-0ab6-8f89-51d51d6725fc",
- "declaredClass": "xblox.model.variables.VariableAssignmentBlock",
- "name": "Set Variable",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "flags": 4,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "b061bd8c-3045-03c7-0dfb-e284422c1202",
- "items": [
- "72660613-080c-d93d-ba08-97fda3dfc4d4"
- ],
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "kodi/status/playbackstate",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "kodi_state",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Kodi-Playbackstate",
- "group": "basicVariables",
- "id": "3cb668c3-5b50-e200-f51f-bf7a22a437f3",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": "started",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "variable": "3cb668c3-5b50-e200-f51f-bf7a22a437f3",
- "variableId": "c09e8c2d-9b1d-b7cf-1f9e-13a78215b13c",
- "value": "",
- "parentId": "b061bd8c-3045-03c7-0dfb-e284422c1202",
- "id": "72660613-080c-d93d-ba08-97fda3dfc4d4",
- "declaredClass": "xblox.model.variables.VariableAssignmentBlock",
- "name": "Set Variable",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "flags": 4,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "89ea751f-b00c-6d60-387c-c5c85eb1d20e",
- "items": [
- "90d07af1-d300-863c-23d0-8de48ea45b1d"
- ],
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "kodi/status/title",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "kodi_details.label",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Kodi-Playing Title",
- "group": "basicVariables",
- "id": "d8dd613c-2b71-05b7-adcc-ec0dc82f8d87",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": "return YOKOO - REACTIONS - RADIO VENAO",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "variable": "d8dd613c-2b71-05b7-adcc-ec0dc82f8d87",
- "variableId": "c09e8c2d-9b1d-b7cf-1f9e-13a78215b13c",
- "value": "",
- "parentId": "89ea751f-b00c-6d60-387c-c5c85eb1d20e",
- "id": "90d07af1-d300-863c-23d0-8de48ea45b1d",
- "declaredClass": "xblox.model.variables.VariableAssignmentBlock",
- "name": "Set Variable",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "flags": 4,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "07e7b04f-c6ec-a04d-6e9d-732b4e8462cb",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Next",
- "topic": "kodi/command/playbackstate",
- "args": "next",
- "deferred": false,
- "icon": "fa-arrow-circle-right",
- "qos": "1",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "retain": false,
- "startup": false,
- "send": "",
- "interval": "0",
- "waitForResponse": false,
- "flags": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "98007916-03a9-0457-c2cd-54e33dea311d",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Prev",
- "topic": "kodi/command/playbackstate",
- "args": "previous",
- "deferred": false,
- "icon": "fa-arrow-circle-left",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "retain": false,
- "startup": false,
- "send": "",
- "interval": 0,
- "waitForResponse": false,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "d0f70902-8122-e57f-4bb4-5b4495a730dd",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Pause",
- "topic": "kodi/command/playbackstate",
- "args": "2",
- "deferred": false,
- "icon": "fa-pause",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "retain": false,
- "startup": false,
- "send": "",
- "interval": 0,
- "waitForResponse": false,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "33681f61-5309-f884-0395-4ec42ed47e5f",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Stop",
- "topic": "kodi/command/playbackstate",
- "args": "0",
- "deferred": false,
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "retain": false,
- "startup": false,
- "send": "",
- "interval": 0,
- "waitForResponse": false,
- "flags": 2048,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "b892d78a-000e-0c82-17e4-f43b1d23716d",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Resume",
- "topic": "kodi/command/playbackstate",
- "args": "1",
- "deferred": false,
- "icon": "fa-stop",
- "qos": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "retain": false,
- "startup": false,
- "send": "",
- "interval": "0",
- "waitForResponse": false,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "0c7d9511-eb8c-3f26-b5f9-14669497c862",
- "declaredClass": "xblox.model.mqtt.Publish",
- "name": "Play-Sonica",
- "topic": "kodi/command/play",
- "args": "plugin://plugin.audio.shoutcast/resolve/9480264",
- "deferred": false,
- "icon": "fa-send",
- "qos": 0,
- "retain": false,
- "startup": false,
- "send": "",
- "interval": "0",
- "flags": 2048,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.js b/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.js
deleted file mode 100644
index 9b0bc54bf..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.js
+++ /dev/null
@@ -1,248 +0,0 @@
-define([
- "dcl/dcl",
- "nxapp/protocols/Tcp",
- "xide/mixins/EventedMixin",
- "dojo/node!net",
- "dojo/node!util",
- "dojo/node!events",
- "dojo/has",
- "xide/utils"
-], function(dcl,Tcp,EventedMixin,net,util,events,has,utils){
-
- var EventEmitter = events.EventEmitter;
- var MPD_SENTINEL = /^(OK|ACK|list_OK)(.*)$/m;
- var OK_MPD = /^OK MPD /;
-
- function noop(err) {
- if (err) {
- console.error('error : ',err);
- this.emit('error', err);
- }
- }
-
-
-
-
- function Command(name, args) {
- this.name = name;
- this.args = args;
- }
-
- Command.prototype.toString = function() {
- return this.name + " " + this.args.map(argEscape).join(" ");
- };
-
- function argEscape(arg){
- // replace all " with \"
- return '"' + arg.toString().replace(/"/g, '\\"') + '"';
- }
-
-
-
-
-
-
-
-
-
-
-// convenience
- function cmd(name, args) {
- return new Command(name, args);
- }
-
- function parseKeyValueMessage(msg) {
- var result = {};
-
- msg.split('\n').forEach(function(p){
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
- result[keyValue[1]] = keyValue[2];
- });
- return result;
- }
-
- function parseArrayMessage(msg) {
- var results = [];
- var obj = {};
-
- msg.split('\n').forEach(function(p) {
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
-
- if (obj[keyValue[1]] !== undefined) {
- results.push(obj);
- obj = {};
- obj[keyValue[1]] = keyValue[2];
- }
- else {
- obj[keyValue[1]] = keyValue[2];
- }
- });
- results.push(obj);
- return results;
- }
-
-
- return dcl([Tcp,EventedMixin.dcl], {
- onReloaded:function(){
- console.error('on reloaded');
- },
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- console.log('on message : ')
- },
- handleMessage : function(err, msg) {
- //console.log('message: ' + err,msg);
- var handler = this.msgHandlerQueue.shift();
- handler && handler(err, msg);
- var self = this;
- if(msg){
- var bufferInt = utils.stringToBuffer(self.buffer.toString());
- var buffer = new Buffer(bufferInt);
- //console.log('handle message : ' + self.buffer.toString());
- self.owner.onData(self.buffer.toString(),buffer);
- }
- },
- sendWithCallback : function(cmd, cb) {
- cb = cb || noop.bind(this);
- this.msgHandlerQueue.push(cb);
- this.send(cmd + "\n");
- },
- setupIdling : function() {
- var self = this;
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- self.idling = true;
- self._emit('ready');
- },
- send:function(data){
- this._socket.write(data);
- console.log('send : ',data);
- },
- handleIdleResults : function(msg) {
- var self = this;
- msg.split("\n").forEach(function(system) {
- if (system.length > 0) {
- var name = system.substring(9);
- self._emit('system-' + name);
- self._emit('system', name);
- }
- });
- },
-
- handleIdleResultsLoop : function(err, msg) {
- var self = this;
- if (err) {
- self._emit('error', err);
- return;
- }
- self.handleIdleResults(msg);
- if (self.msgHandlerQueue.length === 0) {
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- }
- },
- sendCommand :function(command, callback) {
-
-
-
-
- var self = this;
- callback = callback || noop.bind(this);
- self.send("noidle\n");
- self.sendWithCallback(command, callback);
- /*
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });*/
- },
- onConnect:function(){
- var self = this;
-
- console.error('module path : ' + this.modulePath);
-
- self._on('system-player', function() {
- self.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log(msg);
- });
- });
- this._socket.setEncoding('utf8');
-
- this.buffer = "";
- this.msgHandlerQueue = [];
- this.idling = false;
-
-
-
- this._socket.on('data',function(data){
- var m;
- self.buffer += data;
- while (m = self.buffer.match(MPD_SENTINEL)) {
- var msg = self.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- self.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- self.setupIdling();
- } else {
- self.handleMessage(null, msg);
- }
-
- self.buffer = self.buffer.substring(msg.length + line.length + 1);
- }
- var bufferInt = utils.stringToBuffer(self.buffer.toString());
- var buffer = new Buffer(bufferInt);
- console.log('received : ' + self.buffer.toString(),util.inspect(bufferInt));
- self.owner.onData(self.buffer.toString(),buffer);
- });
- },
- write:function(what) {
- var intArray = utils.bufferFromDecString(what);
- var buffer = new Buffer(intArray);
- what = buffer.toString();
- console.log('write xx'+what);
-
-
- this.sendCommand(cmd(what,[]),function(e){
-
- });
- /*
- //convert buffer from byte array string to string
-
- this.owner.isDebug() && console.log('write '+what);
- this.send(buffer);
- */
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.meta.json
deleted file mode 100644
index f666f77ed..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "MPD6000",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "bbe1705a-b6a8-3445-cbc9-d56c6e13ec2c",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": ".\/project1\/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": ".\/MPD\/MPD6000.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"0x0d\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.xblox b/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.xblox
deleted file mode 100644
index 2bb1e03ad..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000.xblox
+++ /dev/null
@@ -1,79 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "id": "23ec6cb8-cb06-f8e6-01aa-c32cedfc538f",
- "name": "value",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "9cc052bc-9c2c-265d-3ab5-2940f2aa03c2",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "listplaylists",
- "name": "listplaylists",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "id": "83d19fc6-e430-a309-8f7a-226ebd609900",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "auto": false,
- "send": "status",
- "name": "status",
- "interval": "0",
- "flags": 0,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "group": "basic"
- },
- {
- "_containsChildrenIds": [],
- "group": "basic",
- "id": "9eb9b6cc-e5cc-3262-98ae-01dbc9392976",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "lsinfo",
- "name": "lsinfo",
- "interval": 0,
- "flags": 2048,
- "waitForResponse": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_standalone.js b/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_standalone.js
deleted file mode 100644
index aa15ef45c..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_standalone.js
+++ /dev/null
@@ -1,472 +0,0 @@
-define([
- "dcl/dcl",
- "nxapp/protocols/Tcp",
- "xide/mixins/EventedMixin",
- "dojo/node!net",
- "dojo/node!util",
- "dojo/node!events",
- "module",
- "dojo/has"
-], function(dcl,Tcp,EventedMixin,net,util,events,module,has){
- var EventEmitter = events.EventEmitter;
- var MPD_SENTINEL = /^(OK|ACK|list_OK)(.*)$/m;
- var OK_MPD = /^OK MPD /;
-
- function noop(err) {
- if (err) {
- this.emit('error', err);
- }
- }
-
-
- MpdClient.Command = Command;
- MpdClient.cmd = cmd;
- MpdClient.parseKeyValueMessage = parseKeyValueMessage;
- MpdClient.parseArrayMessage = parseArrayMessage;
-
- function MpdClient() {
- EventEmitter.call(this);
- this.buffer = "";
- this.msgHandlerQueue = [];
- this.idling = false;
- }
- if(has("host-node")) {
- util.inherits(MpdClient, EventEmitter);
- }
-
- var defaultConnectOpts = {
- host: 'localhost',
- port: 6600
- };
-
- MpdClient.connect = function(options) {
- options = options || defaultConnectOpts;
-
- var client = new MpdClient();
- client.socket = net.connect(options, function() {
- client.emit('connect');
- });
- client.socket.setEncoding('utf8');
- client.socket.on('data', function(data) {
- client.receive(data);
- });
- client.socket.on('close', function() {
- client.emit('end');
- });
- client.socket.on('error', function(err) {
- client.emit('error', err);
- });
- return client;
- }
-
- MpdClient.prototype.receive = function(data) {
-
- console.log('received : ',data);
-
- var m;
- this.buffer += data;
-
- while (m = this.buffer.match(MPD_SENTINEL)) {
- var msg = this.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- this.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- this.setupIdling();
- } else {
- this.handleMessage(null, msg);
- }
-
- this.buffer = this.buffer.substring(msg.length + line.length + 1);
-
- }
- };
-
- MpdClient.prototype.handleMessage = function(err, msg) {
- var handler = this.msgHandlerQueue.shift();
- handler(err, msg);
- };
-
- MpdClient.prototype.setupIdling = function() {
- var self = this;
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- self.idling = true;
- self.emit('ready');
- };
-
- MpdClient.prototype.sendCommand = function(command, callback) {
- var self = this;
- callback = callback || noop.bind(this);
- self.send("noidle\n");
- self.sendWithCallback(command, callback);
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- };
-
- MpdClient.prototype.sendCommands = function(commandList, callback) {
- var fullCmd = "command_list_begin\n" + commandList.join("\n") + "\ncommand_list_end";
- this.sendCommand(fullCmd, callback || noop.bind(this));
- };
-
- MpdClient.prototype.handleIdleResultsLoop = function(err, msg) {
- var self = this;
- if (err) {
- self.emit('error', err);
- return;
- }
- self.handleIdleResults(msg);
- if (self.msgHandlerQueue.length === 0) {
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- }
- };
-
- MpdClient.prototype.handleIdleResults = function(msg) {
- var self = this;
- msg.split("\n").forEach(function(system) {
- if (system.length > 0) {
- var name = system.substring(9);
- self.emit('system-' + name);
- self.emit('system', name);
- }
- });
- };
-
- MpdClient.prototype.sendWithCallback = function(cmd, cb) {
- cb = cb || noop.bind(this);
- this.msgHandlerQueue.push(cb);
- this.send(cmd + "\n");
- };
-
- MpdClient.prototype.send = function(data) {
- this.socket.write(data);
- };
-
- function Command(name, args) {
- this.name = name;
- this.args = args;
- }
-
- Command.prototype.toString = function() {
- return this.name + " " + this.args.map(argEscape).join(" ");
- };
-
- function argEscape(arg){
- // replace all " with \"
- return '"' + arg.toString().replace(/"/g, '\\"') + '"';
- }
-
-
-
-// convenience
- function cmd(name, args) {
- return new Command(name, args);
- }
-
- function parseKeyValueMessage(msg) {
- var result = {};
-
- msg.split('\n').forEach(function(p){
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
- result[keyValue[1]] = keyValue[2];
- });
- return result;
- }
-
- function parseArrayMessage(msg) {
- var results = [];
- var obj = {};
-
- msg.split('\n').forEach(function(p) {
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
-
- if (obj[keyValue[1]] !== undefined) {
- results.push(obj);
- obj = {};
- obj[keyValue[1]] = keyValue[2];
- }
- else {
- obj[keyValue[1]] = keyValue[2];
- }
- });
- results.push(obj);
- return results;
- }
-
-
- return dcl([Tcp,EventedMixin.dcl], {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- //console.log('on message : ')
- },
- handleMessage : function(err, msg) {
- console.log('message ' +msg);
- var handler = this.msgHandlerQueue.shift();
- handler(err, msg);
- },
- sendWithCallback : function(cmd, cb) {
- cb = cb || noop.bind(this);
- this.msgHandlerQueue.push(cb);
- this.send(cmd + "\n");
- console.log('send : '+cmd);
- },
- setupIdling : function() {
- var self = this;
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- self.idling = true;
- self._emit('ready');
- },
- send:function(data){
- this._socket.write(data);
- },
- handleIdleResults : function(msg) {
- var self = this;
- msg.split("\n").forEach(function(system) {
- if (system.length > 0) {
- var name = system.substring(9);
- console.log('emit');
- self._emit('system-' + name);
- self._emit('system', name);
- }
- });
- },
-
- handleIdleResultsLoop : function(err, msg) {
- var self = this;
- if (err) {
- self._emit('error', err);
- return;
- }
- self.handleIdleResults(msg);
- if (self.msgHandlerQueue.length === 0) {
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- }
- },
- onData:function(connection,string,buffer){
- console.log('on data ' + string);
- },
- sendCommand :function(command, callback) {
- var self = this;
- callback = callback || noop.bind(this);
- self.send("noidle\n");
- self.sendWithCallback(command, callback);
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- },
- connectB: function () {
- console.log('connect ');
-
-
- var defaultConnectOpts = {
- host: 'localhost',
- port: 6600
- };
-
-
- var client = MpdClient.connect({
- port: 6600,
- host: 'localhost'
- });
- client.on('system', function(name) {
- console.log("update", name);
- });
-
- client.on('system-player', function() {
- console.log('system-player : ',arguments);
- client.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log('status',msg);
- });
- });
- return;
-
- var self = this;
- this._socket = net.connect(defaultConnectOpts, function() {
- console.log('connected');
- self.buffer = "";
- self.msgHandlerQueue = [];
- self.idling = false;
- });
-
- this._socket.setEncoding('utf8');
-
- this._socket.on('data', function(data) {
- console.log('data '+data.toString());
- var m;
- self.buffer += data;
- while (m = self.buffer.match(MPD_SENTINEL)) {
-
- var msg = self.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- self.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- self.setupIdling();
- } else {
- self.handleMessage(null, msg);
- }
-
- self.buffer = self.buffer.substring(msg.length + line.length + 1);
- console.log('received : ' + self.buffer.toString());
- }
- });
- },
- connect2: function () {
-
-
-
- var defaultConnectOpts = {
- host: 'localhost',
- port: 6600
- };
-
- /*
-
- var client = MpdClient.connect({
- port: 6600,
- host: 'localhost'
- });
- client.on('system', function(name) {
- console.log("update", name);
- });
-
- client.on('system-player', function() {
- console.log('system-player : ',arguments);
- client.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log('status',msg);
- });
- });
- return;*/
-
-
- var self = this;
- this._socket = net.connect(defaultConnectOpts, function() {
- console.log('connected');
- self.buffer = "";
- self.msgHandlerQueue = [];
- self.idling = false;
- self._on('system-player', function() {
- console.log('system player',arguments)
- self.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log(msg);
- });
- });
- });
-
- this._socket.setEncoding('utf8');
-
- this._socket.on('data', function(data) {
- console.log('data '+data.toString());
- var m;
- self.buffer += data;
- while (m = self.buffer.match(MPD_SENTINEL)) {
-
- var msg = self.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- self.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- self.setupIdling();
- } else {
- self.handleMessage(null, msg);
- }
-
- self.buffer = self.buffer.substring(msg.length + line.length + 1);
- console.log('received : ' + self.buffer.toString());
- }
- });
-
- },
- test:function(){
- //send a message :
- this.sendMessage('pwon',true);//sends message to device , respecting start & end settings . forcing now!
- },
- onConnect:function(){
- var self = this;
- self._on('system-player', function() {
- self.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log(msg);
- });
- });
- this._socket.setEncoding('utf8');
-
- this.buffer = "";
- this.msgHandlerQueue = [];
- this.idling = false;
-
-
- this._socket.on('data',function(data){
- var m;
- self.buffer += data;
- while (m = self.buffer.match(MPD_SENTINEL)) {
- var msg = self.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- self.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- self.setupIdling();
- } else {
- self.handleMessage(null, msg);
- }
-
- console.log('received : ' + self.buffer.toString());
- self.buffer = self.buffer.substring(msg.length + line.length + 1);
-
- }
- });
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_tcp.js b/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_tcp.js
deleted file mode 100644
index b2b5db21b..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/MPD6000_tcp.js
+++ /dev/null
@@ -1,227 +0,0 @@
-define([
- "dcl/dcl",
- "nxapp/protocols/Tcp",
- "xide/mixins/EventedMixin",
- "dojo/node!net",
- "dojo/node!util",
- "dojo/node!events",
- "dojo/has",
- "xide/utils"
-], function(dcl,Tcp,EventedMixin,net,util,events,has,utils){
-
- var EventEmitter = events.EventEmitter;
- var MPD_SENTINEL = /^(OK|ACK|list_OK)(.*)$/m;
- var OK_MPD = /^OK MPD /;
-
- function noop(err) {
- if (err) {
- this.emit('error', err);
- }
- }
-
-
-
- function Command(name, args) {
- this.name = name;
- this.args = args;
- }
-
- Command.prototype.toString = function() {
- return this.name + " " + this.args.map(argEscape).join(" ");
- };
-
- function argEscape(arg){
- // replace all " with \"
- return '"' + arg.toString().replace(/"/g, '\\"') + '"';
- }
-
-
-
-// convenience
- function cmd(name, args) {
- return new Command(name, args);
- }
-
- function parseKeyValueMessage(msg) {
- var result = {};
-
- msg.split('\n').forEach(function(p){
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
- result[keyValue[1]] = keyValue[2];
- });
- return result;
- }
-
- function parseArrayMessage(msg) {
- var results = [];
- var obj = {};
-
- msg.split('\n').forEach(function(p) {
- if(p.length === 0) {
- return;
- }
- var keyValue = p.match(/([^ ]+): (.*)/);
- if (keyValue == null) {
- throw new Error('Could not parse entry "' + p + '"')
- }
-
- if (obj[keyValue[1]] !== undefined) {
- results.push(obj);
- obj = {};
- obj[keyValue[1]] = keyValue[2];
- }
- else {
- obj[keyValue[1]] = keyValue[2];
- }
- });
- results.push(obj);
- return results;
- }
-
-
- return dcl([Tcp,EventedMixin.dcl], {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- onMessage:function(data){
- console.log('on message : ')
- },
- handleMessage : function(err, msg) {
- //console.log('message: ' + err,msg);
- var handler = this.msgHandlerQueue.shift();
- handler && handler(err, msg);
- var self = this;
- if(msg){
- var bufferInt = utils.stringToBuffer(self.buffer.toString());
- var buffer = new Buffer(bufferInt);
- //console.log('handle message : ' + self.buffer.toString());
- self.owner.onData(self.buffer.toString(),buffer);
- }
- },
- sendWithCallback : function(cmd, cb) {
- cb = cb || noop.bind(this);
- this.msgHandlerQueue.push(cb);
- this.send(cmd + "\n");
- },
- setupIdling : function() {
- var self = this;
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- self.idling = true;
- self._emit('ready');
- },
- send:function(data){
- this._socket.write(data);
- },
- handleIdleResults : function(msg) {
- var self = this;
- msg.split("\n").forEach(function(system) {
- if (system.length > 0) {
- var name = system.substring(9);
- self._emit('system-' + name);
- self._emit('system', name);
- }
- });
- },
-
- handleIdleResultsLoop : function(err, msg) {
- var self = this;
- if (err) {
- self._emit('error', err);
- return;
- }
- self.handleIdleResults(msg);
- if (self.msgHandlerQueue.length === 0) {
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- }
- },
- sendCommand :function(command, callback) {
-
- console.log('send command: '+command);
- var self = this;
- callback = callback || noop.bind(this);
- self.send("noidle\n");
- self.sendWithCallback(command, callback);
- self.sendWithCallback("idle", function(err, msg) {
- self.handleIdleResultsLoop(err, msg);
- });
- },
- onConnect:function(){
- var self = this;
-
- self._on('system-player', function() {
- self.sendCommand(cmd("status", []), function(err, msg) {
- if (err) throw err;
- console.log(msg);
- });
- });
- this._socket.setEncoding('utf8');
-
- this.buffer = "";
- this.msgHandlerQueue = [];
- this.idling = false;
-
-
- this._socket.on('data',function(data){
- var m;
- self.buffer += data;
- while (m = self.buffer.match(MPD_SENTINEL)) {
- var msg = self.buffer.substring(0, m.index)
- , line = m[0]
- , code = m[1]
- , str = m[2];
-
- if (code === "ACK") {
- var err = new Error(str);
- self.handleMessage(err);
- } else if (OK_MPD.test(line)) {
- self.setupIdling();
- } else {
- self.handleMessage(null, msg);
- }
-
- self.buffer = self.buffer.substring(msg.length + line.length + 1);
- }
- var bufferInt = utils.stringToBuffer(self.buffer.toString());
- var buffer = new Buffer(bufferInt);
- console.log('received : ' + self.buffer.toString(),util.inspect(bufferInt));
- self.owner.onData(self.buffer.toString(),buffer);
- });
- },
- write:function(what) {
- var intArray = utils.bufferFromDecString(what);
- var buffer = new Buffer(intArray);
- what = buffer.toString();
-
- this.sendCommand(what);
- /*
- //convert buffer from byte array string to string
- var intArray = utils.bufferFromDecString(what);
- var buffer = new Buffer(intArray);
- what = buffer.toString();
- this.owner.isDebug() && console.log('write '+what);
- this.send(buffer);
- */
- }
- });
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/MPD/mpd.js b/shredder/asterix-pp/asterix-hmi/drivers/MPD/mpd.js
deleted file mode 100644
index 2a1606a11..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/MPD/mpd.js
+++ /dev/null
@@ -1,2742 +0,0 @@
-/**
- * The global MPD function is the main interface and only global varialbe of the MPD.js library.
- * This function returns an object representing an MPD web client.
- * All other methods documented here are member functions of the object returned by a call to the MPD function.
- *
- * @example
- * //EXAMPLE USAGE//
- * //retrives a MPD client interface on port 8800
- * var mpd_client = MPD(8800);
- * //set handler for when the state changes
- * mpd_client.on('StateChanged', updateUiFunction);
- * @class
- * @param {Integer} [_port] - the portnumber our client should try to cennect to our winsockifyed MPD instance with
- * @param {String} [_host=document.URL] - hostname to try to connect to, defaults to the domain of the current page
- * @param {String} [_password] - password to connect with (if needed)
- */
-function MPD(_port, _host, _password){
-
- /**
- * this will be the final output interface, but it is used to refer to the client as a 'this' like object
- * @lends MPD
- */
- var self = {};
-
- /********************\
- |* public interface *|
- \********************/
-
- /**
- * adds an event handler
- * @instance
- * @function
- * @throws {Error} an Error if you try to listen to an invalid event type
- * @param {String} event_name - what sort of event to listen for. must be one of the following: 'Error', 'Event', 'UnhandledEvent', 'AuthFailure', 'DatabaseChanging', 'DataLoaded', 'OutputChanged', 'StateChanged', 'QueueChanged', 'PlaylistsChanged', 'PlaylistChanged','Connect', 'Disconnect'
- * @param {errorEventHandler|disconnectEventHandler|connectEventHandler|playlistsChangedEventHandler|queueChangedEventHandler|outputChangedEventHandler|stateChangedEventHandler|dataLoadedEventHandler|databaseChangingEventHandler|unhandledEventHandler|eventHandler|errorEventHandler} handler - function called when the given event happens
- */
- self.on = on;
-
- /**
- * returns an object representation of the current state of MPD as the client understands it right now
- * this does NOT map to the client's functional API
- * @instance
- * @returns {state} object representing the current state of MPD
- */
- self.getState = function(){
- var ret = cloneObject(_private.state);
- //there are a few things we can't easily clone, but I made a clone method for those, so we can deal with this
- if(_private.state.current_queue !== null){
- ret.current_queue = _private.state.current_queue.clone();
- }
-
- return ret;
- };
-
- /**
- * call to turn off logging to the console
- * @instance
- */
- self.disableLogging = function(){
- _private.do_logging = false;
- };
-
- /**
- * call to turn logging to the console on (debugging)
- * @instance
- */
- self.enableLogging = function(){
- _private.do_logging = true;
- };
-
- /**
- * return the port number this client was instansiated with and thet it is (attempting to) connect with
- * @instance
- * @returns {Integer} the port number the MPD client is (trying to be) connected to
- */
- self.getPort = function(){
- return _port;
- };
-
- /**
- * return the host this client was instansiated with and thet it is (attempting to) connect with
- * @instance
- * @returns {String} the host name the MPD client is (trying to be) connected to
- */
- self.getHost = function(){
- return _host;
- };
-
- /**
- * gets the protocol versing reported on connection
- * @instance
- * @returns {String} string desxriping the protocol version i.e. "1.18.0"
- */
- self.getProtocolVersion = function(){
- return _private.state.version;
- };
-
- /**
- * retruns if we are connected or not
- * @instance
- * @returns {Boolean} true if we are connected, false if we are not
- */
- self.isConnected = function(){
- return _private.state.connected == true;
- };
-
- /**
- * Returns a string enum describing the playback state
- * @instance
- * @returns {String} - 'play', 'pause', 'stop'
- */
- self.getPlaystate = function(){
- return _private.state.playstate;
- };
-
- /**
- * returns the current volume
- * @instance
- * @returns {Float} between 0 and 1
- */
- self.getVolume = function(){
- return _private.state.volume;
- };
-
- /**
- * returns if we are in repeat mode or not
- * @instance
- * @returns {Boolean} true if we are in repeat mode, false otherwise
- */
- self.isRepeat = function(){
- return _private.state.repeat == true;
- };
-
- /**
- * returns if we are in single mode or not
- * @instance
- * @returns {Boolean} true if we are in single mode, false otherwise
- */
- self.isSingle = function(){
- return _private.state.single == true;
- };
-
- /**
- * returns if we are in consume mode or not
- * @instance
- * @returns {Boolean} true if we are in consume mode, false otherwise
- */
- self.isConsume = function(){
- return _private.state.consume == true;
- };
-
- /**
- * returns if we are in random playback mode or not
- * @instance
- * @returns {Boolean} true if we are in random mode, false otherwise
- */
- self.isRandom = function(){
- return _private.state.random == true;
- };
-
- /**
- * ammount of time (in seconds) the MPD server is set to crossfade songs. 0 means disabled
- * @instance
- * @returns {Number} true if we are in random mode, false otherwise
- */
- self.getCrossfadeTime = function(){
- return _private.state.crossfade;
- };
-
- /**
- * honestly don't know what this is, has something to do with some sort of fading mode I never use, but MPD reports it so I'm making an accessor for it in case someone else wants to use it
- * @instance
- * @returns {Float}
- */
- self.getMixRampThreashold = function(){
- return _private.state.mix_ramp_threshold;
- };
-
-
- /**
- * gets the currently playing song
- * @instance
- * @function
- * @returns {Song}
- */
- self.getCurrentSong = getCurrentSong;
-
- /**
- * gets the time of the current song. will calculate it based on the reported time, and how long it's been since that happened
- * @instance
- * @function
- * @returns {Float}
- */
- self.getCurrentSongTime = getCurrentSongTime;
-
- /**
- * get's the queue id of the currently playing song
- * @instance
- * @returns {Integer}
- */
- self.getCurrentSongID = function(){
- return _private.state.current_song.id;
- };
-
- /**
- *gets the position on the queue of the song currently playing
- * @instance
- * @returns {Integer}
- */
- self.getCurrentSongQueueIndex = function(){
- return _private.state.current_song.queue_idx;
- };
-
-
- /**
- * gets the song next to be played
- * @instance
- * @function
- * @returns {Song}
- */
- self.getNextSong =getNextSong;
-
- /**
- * gets the queue id of the next song to play
- * @instance
- * @returns {Integer}
- */
- self.getNextSongID = function(){
- return _private.state.next_song.id;
- };
-
- /**
- * returns the position on the queue of the next song on the queue to play
- * @instance
- * @returns {Integer}
- */
- self.getNextSongQueueIndex = function(){
- return _private.state.next_song.queue_idx;
- };
-
-
- /**
- * get the whole queue
- * @instance
- * @returns {Queue}
- */
- self.getQueue = function(){
- return _private.state.current_queue;
- };
-
- /**
- * returns the version of the queue, this number changes every time the queue does
- * @instance
- * @returns {Integer}
- */
- self.getQueueVersion = function(){
- return _private.state.queue_version;
- };
-
-
- /**
- * fetches a playlist from MPD identified by it's name
- * @instance
- * @param {String} playlist name - the name of the playlist you want
- * @param {playlistCallback} onDone - function to call with the playlist when we get it
- */
- self.getPlaylist = function(name, onDone){
- var ret = null;
- for(var i = 0; i<_private.state.playlists.length; i++){
- if(_private.state.playlists[i].playlist==name){
- issueCommands({
- command:'listplaylistinfo "'+name+'"',
- handler:getPlaylistHandler(onDone, i)
- });
- return;
- }
- };
- onDone(null);
- };
-
-
- /**
- * returns an array of strings that is the list of the names of all available saved playlists
- * @instance
- * @returns {String[]}
- */
- self.getPlaylists = function(){
- var playlists = [];
- _private.state.playlists.forEach(function(playlist){
- playlists.push(playlist.playlist);
- });
- return playlists;
- };
-
-
- /**
- * returns an array of Output objects
- * @instance
- * @returns {Output[]}
- */
- self.getOutputs = function(){
- return _private.outputs.map(function(source){
- return MPD.Output(self, source);
- });
- };
-
-
- /**
- * returns true if the output is enabled, false otherwise
- * @param {Integer} id -- the identifier of the output
- * @instance
- */
- self.outputIsEnabled = function(id){
- return _private.outputs[id].outputenabled == 1;
- };
-
- /**
- * turns on the output specified by the id
- * @param {Integer} id -- the identifier of the output to turn on
- * @instance
- */
- self.enableOutput = function(id){
- issueCommands('enableoutput '+id);
- };
-
- /**
- * turns off the output specified by the id
- * @param {Integer} id -- the identifier of the output to turn off
- * @instance
- */
- self.disableOutput = function(id){
- issueCommands('disableoutput '+id);
- };
-
- /**
- * turns on consume mode
- * @instance
- */
- self.enablePlayConsume = function(){
- issueCommands('consume 1');
- };
-
- /**
- * turns off consume mode
- * @instance
- */
- self.disablePlayConsume = function(){
- issueCommands('consume 0');
- };
-
- /**
- * turns on crossfade
- * @param {String} time -- time to crossfade in seconds, 0 to disable
- * @instance
- */
- self.setCrossfade = function(time) {
- issueCommands('crossfade '+time);
- };
-
- /**
- * turns on random play mode
- * @instance
- */
- self.enableRandomPlay = function(){
- issueCommands('random 1');
- };
-
- /**
- * turns off random play mode
- * @instance
- */
- self.disableRandomPlay = function(){
- issueCommands('random 0');
- };
-
- /**
- * turns on repeat play mode
- * @instance
- */
- self.enableRepeatPlay = function(){
- issueCommands('repeat 1');
- };
-
- /**
- * turns of repeat play mode
- * @instance
- */
- self.disableRepeatPlay = function(){
- issueCommands('repeat 0');
- };
-
- /**
- * turns on single play mode
- * @instance
- */
- self.enableSinglePlay = function(){
- issueCommands('single 1');
- };
-
- /**
- * turns of single play mode
- * @instance
- */
- self.disableSinglePlay = function(){
- issueCommands('single 0');
- };
-
- /**
- * Sets the threshold at which songs will be overlapped. Like crossfading but doesn't fade the track volume, just overlaps. The songs need to have MixRamp tags added by an external tool. 0dB is the normalized maximum volume so use negative values, I prefer -17dB. In the absence of mixramp tags crossfading will be used. See http: // sourceforge.net/projects/mixramp
- * @instance
- * @param {Float} decibels
- */
- self.setMixRampDb = function(decibels){
- issueCommands('mixrampdb '+decibels);
- };
-
- /**
- * Additional time subtracted from the overlap calculated by mixrampdb. A value of "nan" disables MixRamp overlapping and falls back to crossfading.
- * @instance
- * @param {(float|string)} seconds - time in seconds or "nan" to disable
- */
- self.setMixRampDelay = function(seconds){
- issueCommands('mixrampdelay '+seconds);
- };
-
- /**
- * Sets volume, the range of volume is 0-1.
- * @instance
- * @param {Float} volume - 0-1
- */
- self.setVolume = function(volume){
- volume = Math.min(1,volume);
- volume = Math.max(0,volume);
- issueCommands('setvol '+Math.round(volume*100));
- };
-
- /**
- * Begins playing if not playing already. optional parameter starts playing a particular song
- * @instance
- * @param {Integer} [queue_position=] - the song to start playing
- */
- self.play = function(queue_position){
- if(typeof queue_position != 'undefined'){
- issueCommands('play '+queue_position);
- }
- else{
- issueCommands('play');
- }
- };
-
- /**
- * Begins playing the playlist at song identified by the passed song_id.
- * @instance
- * @param {Integer} song_id - the queue id of the song you want to start playing
- */
- self.playById = function(song_id){
- issueCommands('playid '+song_id);
- };
-
- /**
- * pauses/resumes playing
- * @instance
- * @param {Boolean} [do_pause=true] - true if you want to pause, false if you want to be unpaused
- */
- self.pause = function(do_pause){
- if(typeof do_pause == 'undefined' || do_pause){
- issueCommands('pause 1');
- }
- else{
- issueCommands('pause 0');
- }
- };
-
- /**
- * Plays next song in the queue.
- * @instance
- */
- self.next = function(){
- issueCommands('next');
- };
-
- /**
- * Plays previous song in the queue.
- * @instance
- */
- self.previous = function(){
- issueCommands('previous');
- };
-
- /**
- * Seeks to the position time (in seconds) within the current song. If prefixed by '+' or '-', then the time is relative to the current playing position.
- * @instance
- * @param {(float|string)} - what point in the current song to seek to or string with a signed float in it for relative seeking. i.e. "+0.1" to seek 0.1 seconds into the future, "-0.1" to seek 0.1 seconds into the past
- */
- self.seek = function(time){
- issueCommands('seekid '+_private.state.current_song.id+' '+time);
- };
-
- /**
- * Stops playing.
- * @instance
- */
- self.stop = function(){
- issueCommands('stop');
- };
-
- /**
- * Adds the file to the playlist (directories add recursively).
- * @instance
- * @param {String} pathname - of a single file or directory. relative to MPD's mussic root directory
- */
- self.addSongToQueueByFile = function(filename){
- issueCommands('add "'+filename+'"');
- };
-
- /**
- * Clears the current queue
- * @instance
- */
- self.clearQueue = function(){
- issueCommands('clear');
- };
-
- /**
- * Deletes a song from the queue
- * @instance
- * @param {Integer} position - index into the queue to the song you don't want to be on the queue any more
- */
- self.removeSongFromQueueByPosition = function(position){
- issueCommands('delete '+position);
- };
-
- /**
- * Deletes a range of songs from the playlist.
- * @instance
- * @param {Integer} start - the queue index of the first song on the playlist you want to remove
- * @param {Integer} end - the queue index of the last song on the playlist you want to remove
- */
- self.removeSongsFromQueueByRange = function(start, end){
- issueCommands('delete '+start+' '+end);
- };
-
- /**
- * Deletes the song identified with the passed queue id from the playlist
- * @instance
- * @param {Integer} id - the queue id of the song you want to remove from the queue
- */
- self.removeSongFromQueueById = function(id){
- issueCommands('deleteid '+id);
- };
-
- /**
- * a song from one position on the queue to a different position
- * @instance
- * @param {Integer} position - the position of the song to move
- * @param {Integer} to - where you want the sang to go
- */
- self.moveSongOnQueueByPosition = function(position, to){
- issueCommands('move '+position+' '+to);
- };
-
- /**
- * moves a range of songs on the queue
- * @instance
- * @param {Integer} start - the queue index of the first song on the queue you want to move
- * @param {Integer} end - the queue index of the last song on the queue you want to move
- * @param {Integer} to - the queue index were the first song should end up
- */
- self.moveSongsOnQueueByPosition = function(start, end, to){
- issueCommands('move '+start+':'+end+' '+to);
- };
-
- /**
- * moves the song identified with the passed queue id to the passed queue index
- * @instance
- * @param {Integer} id - queue id of the song you want to move
- * @param {Integer} to - the queue indes you want it to be
- */
- self.moveSongOnQueueById = function(id, to){
- issueCommands('moveid '+id+' '+to);
- };
-
- /**
- * Shuffles the current playlist.
- * @instance
- */
- self.shuffleQueue = function(){
- issueCommands('shuffle');
- };
-
- /**
- * Swaps the positions of two songs identified by their queue indexes
- * @instance
- * @param {Integer} pos1 - queue index of the first song
- * @param {Integer} pos2 - queue index of the second song
- */
- self.swapSongsOnQueueByPosition = function(pos1, pos2){
- issueCommands('swap '+pos1+' '+pos2);
- };
-
- /**
- * Swaps the positions of two songs identified by their queue ids
- * @instance
- * @param {Integer} id1 - queue id of the first song
- * @param {Integer} id2 - queue id of the second song
- */
- self.swapSongsOnQueueById = function(id1, id2){
- issueCommands('swapid '+id1+' '+id2);
- };
-
- /**
- * Loads the given playlist to the end of the current queue.
- * @instance
- * @param {String} playlist_name - the name of the playlist you want to append to the queue
- */
- self.appendPlaylistToQueue = function(playlist_name){
- issueCommands('load "'+playlist_name+'"');
- };
-
- /**
- * Loads the given playlist into the current queue replacing it.
- * @instance
- * @param {String} playlist_name - the name of the playlist you want to append to the queue
- */
- self.loadPlaylistIntoQueue = function(playlist_name){
- issueCommands([
- 'clear',
- 'load "'+playlist_name+'"'
- ]);
- };
-
- /**
- * Saves the current queue as a the given playlist, overwrites exsisting playlist of that name if it exsists, otherwise makes a new one
- * @instance
- * @param {String} playlist_name - the name of the playlist you want to use as your new queue
- */
- self.saveQueueToPlaylist = function(playlist_name){
- issueCommands('save "'+playlist_name+'"');
- };
-
- /**
- * adds the given song (filename) to the given playlist
- * @instance
- * @param {String} playlist_name - the playlist to add the song to
- * @param {String} filename - the filename of the song you want to add
- */
- self.addSongToPlaylistByFile = function(playlist_name, filename){
- issueCommands('playlistadd "'+playlist_name+'" "'+filename+'"');
- };
-
- /**
- * Clears the playlist leaving it still in exsistance, but empty
- * @instance
- * @param {String} playlist_name - the poor unfortunate playlist you want to hollow out
- */
- self.clearPlaylist = function(playlist_name){
- issueCommands('playlistclear "'+playlist_name+'"');
- };
-
- /**
- * Deletes the song at the given position from the given playlist
- * @instance
- * @param {String} playlist_name - the name of the playlist with a song on it that you think shouldn't be there anymore
- * @param {Integer} position - the position in the playlist of the song you want to remove
- */
- self.removeSongFromPlaylistByPosition = function(playlist_name, position){
- issueCommands('playlistdelete "'+playlist_name+'" '+position);
- };
-
- /**
- * moves the song from one position on the playlist to another
- * @instance
- * @param {String} playlist_name - the name of the playlist on which you want to move a song
- * @param {Integer} from - position on the playlist of the song you want to move
- * @param {Integer} to - the position to which you want to move the song
- */
- self.moveSongOnPlaylistByPosition = function(playlist_name, from, to){
- issueCommands('playlistmove "'+playlist_name+'" '+from+' '+to);
- };
-
- /**
- * Renames the playlist
- * @instance
- * @param {String} playlist_name - the name is it right now
- * @param {String} new_name - the name it should be
- */
- self.renamePlaylist = function(playlist_name, new_name){
- issueCommands('rename "'+playlist_name+'" "'+new_name+'"');
- };
-
- /**
- * this kills the playlist
- * @instance
- * @param {String} playlist_name - the name of the playlist you want to obliterate and never see any trace of again
- */
- self.deletePlaylist = function(playlist_name){
- issueCommands('rm "'+playlist_name+'"');
- };
-
- /**
- * Updates the music database: find new files, remove deleted files, update modified files.
- * @instance
- */
- self.updateDatabase = function(){
- issueCommands('update');
- };
-
- /**
- * @instance
- * @param {String} [path] - path to the directory you are interested in relative to MPD's music root directory (root is a blank string, never start with '/')
- * @param {directoryContentsCallback}
- */
- self.getDirectoryContents = function(path, onDone){
- issueCommands({
- command:'lsinfo "'+path+'"',
- handler:getDirectoryHandler(onDone)
- });
- };
-
- /**
- * return an array of strings which are all of the valid tags
- * note there might be more undocumented tags that you can use just fine not listed here (like musicbrainz)
- * @instance
- * @returns {String[]}
- */
- self.getTagTypes = function getTagTypes(){
- return cloneObject(_private.tag_types);
- };
-
- /**
- * params is a {tag => value} object, valid tags are enumerated in getTagTypes.
- * onDone is a function that should be called on complete, will be passed an array of strings that are the values of the tag identified by tag_type that are on songs that match the search critaria
- *
- * @example
- * client.tagSearch(
- * 'album',
- * {artist:'bearsuit'},
- * function(albums){
- * //albums == ["Cat Spectacular", "Team Pingpong", "OH:IO", "The Phantom Forest"]
- * //which are all of the albums of the band Bearsuit
- * }
- * );
- * @instance
- * @param {Object[]} params - Array of objects that maps a tag to a value that you want to find matches on that tag for {tag => value}. For a list of acceptable tag/keys @see {@link getTagTypes}. For a list of acceptable values for a given tag @see {@link getTagOptions}.
- * @param {searchResultsCallback} onDone - function called when the search results have come back, is passed the results as it's only parameter
- */
- self.tagSearch = function doTagSearch(tag_type, params, onDone){
- var query = 'list '+tag_type;
- for(key in params){
- var value = params[key];
- query += ' '+key+' "'+value+'"';
- }
- issueCommands({
- command:query,
- handler:getTagSearchHandler(onDone, tag_type)
- });
- };
-
- /**
- * params is a {tag => value} object, valid tags are enumerated in getTagTypes, onDone is a function that should be called on complete, will be passed an array of song objects
- * @instance
- * @param {Object[]} params - Array of objects that maps a tag to a value that you want to find matches on that tag for {tag => value}. For a list of acceptable tag/keys @see {@link getTagTypes}. For a list of acceptable values for a given tag @see {@link getTagOptions}.
- * @param {searchResultsCallback} onDone - function called when the search results have come back, is passed the results as it's only parameter
- */
- self.search = function(params, onDone){
- var query = 'search';
- for(key in params){
- var value = params[key];
- query += ' '+key+' "'+value+'"';
- }
- issueCommands({
- command:query,
- handler:getSearchHandler(onDone)
- });
- };
-
- /**
- * like search except just for finding how many results you'll get (for faster live updates while criteria are edited)
- * params is a {tag => value} object, valid tags are enumerated in getTagTypes, onDone is a function that should be called on complete, will be passed the numver of results the search would produce
- * @instance
- * @param {Object[]} params - Array of objects that maps a tag to a value that you want to find matches on that tag for {tag => value} For a list of acceptable tag/keys @see {@link getTagTypes}. For a list of acceptable values for a given tag @see {@link getTagOptions}.
- * @param {searchCountCallback} onDone - function called when the search results have come back, is passed the results as it's only parameter
- */
- self.searchCount = function(params, onDone){
- var query = 'count';
- for(key in params){
- var value = params[key];
- query += ' '+key+' "'+value+'"';
- }
- issueCommands({
- command:query,
- handler:getSearchHandler(function(results){
- onDone(results[0]);
- })
- });
- };
-
- /**
- * set the password for this client
- * @instance
- * @param {String}
- */
- self.authorize = function(password){
- _password = password;
- if(_private.state.connected){
- //if we are not connected we will issue the password as part of our reconnection
- issueCommands('password '+_password);
- }
- }
-
- /****************\
- |* private data *|
- \****************/
-
- var _private = {
- /**
- * THE web socket that is connected to the MPD server
- * @private
- */
- socket:null,
-
- /**
- * running string of partial responces from MPD
- */
- raw_buffer:'',
-
- /**
- * running list of lines we have gotten from the server
- */
- raw_lines:[],
-
- /**
- * false if we are disconnected or have not completed out initial data load yet
- */
- inited: false,
-
- /**
- * events that have been held until we are consistent
- */
- queued_events:[],
-
- /**
- * object {string:[function]} -- listing of funcitons to call when certain events happen
- *
- * valid handlers:
- * Connect
- * Disconnect
- * Queue
- * State
- * SongChange
- * Mpdhost
- * Error
- * @private
- */
- handlers:{},
-
- /**
- * number -- int number of milisecond to wait until reconnecting after loosing connection
- * set to something falsyto disable automatic reconnection
- * @private
- */
- reconnect_time: 3000,
-
- /**
- * true if we want logging turned on
- * @private
- */
- do_logging: false,
-
- /**
- * Our understanding of what the server looks like
- * @typedef {Object} state
- * @property {String} version - server protocol version
- * @property {Boolean} connected - if we are currently connected to the server or not
- * @property {String} playstate - enum, PLAYING, STOPPED, PAUSED
- * actual MPD attribute: state (int 0,1,2)
- * @property {Integer} volume - 0 to 1 the current volume
- * @property {Boolean} repeat - true if the server is configured to repeat the current song
- * @property {Boolean} single - true if the server is configured to just play one song then quit
- * @property {Boolean} consume - true if the server is configured to not repeat songs in a playlist
- * @property {Boolean} random - true if the server is configured to play music in a random order
- * @property {Integer} crossfade - nonnegitive integer representing number of seconds to crossfade songs
- * @property {Float} mix_ramp_threshold - not sure what this is, but it's reported
- * actual MPD attribute: mixrampdb
- * @property {Object} current_song - info about the currently playing song
- * @property {Integer} current_song.queue_idx - which song in the current playlist is active
- * actual MPD attribute: song
- * @property {Float} current_song.elapsed_time - time into the currently playing song in seconds
- * actual MPD attribute: elapsed
- * @property {Integer} current_song.id - the id of the current song
- * actual MPD attribute: songid
- * @property {Object} next_song - info about the song next to play on the queue
- * @property {Integer} next_song.queue_idx - which song in the current playlist is active
- * actual attribute: song
- * @property {Integer} next_song.id - the id of the current song
- * actual attribute: songid
- * @property {Queue} current_queue - the songs that are currently in rotation for playing, in the order they are to play (unless random is set to true)
- * @property {Integer} queue_version - a number associated with the queue that changes every time the queue changes
- * @property {String[]} playlists - names of all of the saved playlists
- */
- state:{
- version: null,
- connected:false,
- playstate: null,
- volume: null,
- repeat: null,
- single: null,
- consume: null,
- random: null,
- crossfade: null,
- mix_ramp_threshold: null,
- current_song: {
- queue_idx: null,
- elapsed_time: null,
- id: null
- },
-
- next_song: {
- queue_idx: null,
- id: null
- },
- current_queue: null,
- queue_version: null,
- playlists:[]
- },
-
- /**
- * list of tags that are acceptable for this server
- */
- tag_types:[],
-
- /**
- * list of available outputs
- */
- outputs:[],
-
- /**
- * when was the status last updated
- * @private
- */
- last_status_update_time: new Date(),
-
- /**
- *method called when we get a responce from MPD
- */
- responceProcessor:null,
-
- /**
- * sequence of handlers for the sequence of commands that have been issued
- * @private
- */
- commandHandlers:[],
-
- /**
- * commands that are yet to be processed
- */
- command_queue:[],
-
- /**
- *last error we had
- */
- last_error: null
- };
-
-
- /*******************\
- |* private methods *|
- \*******************/
-
- /*************************\
- |* connection management *|
- \*************************/
-
- /**
- * wrapper for sending a message to the server, allows logging
- * @private
- */
- function sendString(str){
- log('sending: "'+str+'"');
- _private.socket.send_string(str);
- }
-
-
- /**
- * initalization funciton
- * called near the end of this file and when we need to (try to) (re)connect
- * @private
- */
- function init(){
- var websocket_url = getAppropriateWsUrl();
- var websocket = new Websock();
- websocket.open(websocket_url);
-
- //these can throw
- websocket.on('open',onConnect);
-
- websocket.on('message', function(){
- _private.responceProcessor.apply(this,arguments);
- });
-
- websocket.on('close',onDisconnect);
-
- _private.socket = websocket;
- }
-
-
- /**
- * function called when the websocke connects
- * @private
- */
- function onConnect(){
- log("connected");
- _private.state.connected = true;
- _private.raw_buffer = '';
- _private.raw_lines = [];
- _private.responceProcessor = handleConnectionMessage;
- callHandler('Connect', arguments);
- }
-
-
- /**
- * called when we disconnected (unexpectedly)
- * @private
- */
- function onDisconnect(){
- log("disconnected");
-
- callHandler('Disconnect', arguments);
-
- _private.state.connected = false;
- _private.socket = null;
- _private.state.version = null;
- _private.commandHandlers = [];
- setInited(false);
-
- _private.responceProcessor = null; //will throw an error if we get any responces before we reconnect
-
- if(_private.reconnect_time){
- setTimeout(init, _private.reconnect_time);
- }
- }
-
-
- /**
- * change the state and deal with what happens when that state changes
- */
- function setInited(inited){
- _private.inited = inited;
- if(inited){
- var events = _private.queued_events;
- _private.queued_events = [];
- events.forEach(function(event){
- for(var key in event){
- callHandler(key, event[key]);
- }
- });
- }
- }
-
-
- /************\
- |* commands *|
- \************/
-
-
- /**
- * issue one or more commands to the server
- * pass one command or an array of commands
- * a command can be in the form of a string, or a object
- * if a string is used as a command it will be assumed to have a 'do nothing' responce handler
- * if an object is passed it must be in the form of {command:, handler:function(String[]), error:function(Error)}
- * this assumes we are starting in and wish to return to an idle state
- * @private
- */
- function issueCommands(commands, is_idling){
- if( Object.prototype.toString.call( commands ) !== '[object Array]' ) {
- //some joker didn't give us a set of commands... wrap it up
- commands = [commands];
- }
-
- if(_private.command_queue.length === 0){
- _private.command_queue = commands;
- //done in a timeout so we can combine commands effecently
- setTimeout(function(){
- processComandQueue(is_idling === false);
- }, 50);
- }
- else{
- //append additional commands, they'll get processed when the above command is done
- _private.command_queue.push.apply(_private.command_queue, commands);
- }
- }
-
-
- /**
- * get the next command off the queue and process it
- */
- function processComandQueue(is_not_idling){
- var command_string = '';
-
- if(_private.commandHandlers.length > 0 && _private.commandHandlers[0].command !== 'idle'){
- //there are outstatnding commands being processed still, wait until the last batch finishes
- //we don't have to timeout call ourself because we will be called when the outstanding commands are done
- //if we are waiting on the idle handler then this doesn't count
- return;
- }
-
- _private.command_queue.forEach(function(command){
- if(command instanceof Function){
- //case when we are given function, an 'on complete command'
- //if we are given a function, it will be called when all previous commands are complete
- _private.commandHandlers.push(command);
- }
- else{
- //normal case
-
- //if it's a string make it be an object
- if(typeof command === 'string'){
- command = {command:command}; //malkovich
- }
-
- //if it doesn't have a handler give it a 'do nothing' handler
- if(typeof command.handler === 'undefined'){
- command.handler = function(){};
- }
-
- //if it doesn't have a error handler give it the default error handler
- if(typeof command.error === 'undefined'){
- command.error = defaultErrorHandler;
- }
-
- //now everything is normalized
-
- //append the command
- command_string += command.command+'\n';
-
- //set the handler
- _private.commandHandlers.push(command);
- }
- });
- _private.command_queue = [];
-
- //issue the command
- if('' === command_string){
- //if we were given nothing but post comand functions don't issue a null command
- //but do call all of those post comand functions
- _private.commandHandlers.forEach(function(func){
- //this whole branch is weird, so lets just check to make sure these are all post comand functions
- if(!func instanceof Function){
- throw new Error('non-"post comand" function in commandHandlers when there was no command!');
- }
- func();
- });
- }
- else{
- var idle_command = {
- command:'idle',
- handler:idleHandler,
- error:defaultErrorHandler
- };
- _private.commandHandlers.push(idle_command);
-
- command_string = 'command_list_ok_begin\n'+command_string+'idle\ncommand_list_end\n';
- if(!is_not_idling){
- command_string = 'noidle\n'+command_string;
- }
-
- sendString(command_string);
- }
- }
-
- /**
- * what to do by default if a command fails
- */
- function defaultErrorHandler(error){
- var error_codes = MPD.getErrorCodes();
- //if it's an error we know something about, maybe we can deal with it, otherwise just call registered handlers
- switch(error.code){
- case error_codes.ACK_ERROR_PASSWORD:
- case error_codes.ACK_ERROR_PERMISSION:
- // we\the user tried to do something they are not allowed to do
- callHandler('AuthFailure', error, true);
- break;
- default:
- debugger;
- alert('***ERROR*** '+error.message);
- callHandler('Error', error, true);
- break;
- }
- }
-
-
- /*************************************\
- |* process responces from the server *|
- \*************************************/
-
-
- /**
- * return all of the lines upto one that matches the passed line
- * MUTATES lines
- * @private
- */
- function getLines(lines, last_line){
- var end_line = -1;
- for(var i = 0; i0){
- if(value.match(/^\d*(\.\d*)?$/)){
- value = parseFloat(value);
- }
- else if(date = parseDate(value)){
- value = date;
- }
- }
- key = key.toLowerCase();
- key = key.replace(/[^\w\d]+/g, '_');
-
- //we are starting a new object
- if(file_marker && key.match(file_marker)){
- output.push(current_thing);
- current_thing = {};
- }
- current_thing[key] = value;
-
- //we want to skip the first, starting key so this is down here
- if(file_marker === null){
- if(new_file_marker){
- file_marker = new_file_marker;
- }
- else{
- file_marker = new RegExp('^'+key+'$');
- }
- }
-
- });
-
- //get the last one
- if(current_thing){
- output.push(current_thing);
- }
-
- return output;
- }
-
-
- /**
- *fetch outstanding lines from MPD
- */
- function getRawLines(){
- _private.raw_buffer += _private.socket.rQshiftStr();//get the raw string
-
- var lines = _private.raw_buffer.split('\n');//split that into lines
-
- _private.raw_buffer = lines.pop(); //last line is incomplete
-
- _private.raw_lines.push.apply(_private.raw_lines,lines); //append these new lines to the running collection we have
-
- if(_private.do_logging){
- lines.forEach(function(str){log('recived: "'+str+'"');}); //log what we got
- }
-
- return _private.raw_lines;
- }
-
-
- /**
- * called when we have some data,
- * might be a message,
- * might be a fragment of a message,
- * might be multiple messages
- * @private
- */
- function onRawData(){
- var lines = getRawLines();
- //keep processing untill we can't process any more
- var command_processor = null;
- var old_lines;//this is infinite loop prevention, should never actually happen
- while(lines.length > 0 && old_lines != lines.length){
- old_lines = lines.length;
-
- var error = getError(lines);
- if(error){
- //this command hit an error
- command_processor = _private.commandHandlers.shift(); //get the next outstanding command processor
- command_processor.error(error);
- }
- else{
- var command_lines = getLines(lines, /^OK$|^list_OK$/);//get everything until the 'OK' line
- if(command_lines === null){
- //we have hit the end of the useable lines
- break;
- }
- command_lines.pop(); //get rid of the 'OK'
-
- command_processor = _private.commandHandlers.shift(); //get the next outstanding command processor
-
- command_processor.handler(command_lines); //execure the processor on the results of the command
- }
-
- //call everything we are supposed to just call
- while(_private.commandHandlers.length > 0 && _private.commandHandlers[0] instanceof Function){
- _private.commandHandlers.shift()();
- }
- }
-
- //if there are no commandHandlers left, we have definitely exauhsted our outstanding commands
- //if there is something in the command_queue, we have another batch of commands to issue
- //so process them
- if(_private.commandHandlers.length === 0 && _private.command_queue > 0){
- processComandQueue();
- }
- }
-
-
- /**
- * we are expecting a connection responce
- * this handles raw data because when we first connect the protocol is comepletely different than at any other point
- * @private
- */
- function handleConnectionMessage(){
- var lines = getRawLines();
-
- if(lines.length < 1){
- return;
- }
-
- var line = lines.shift(1);
-
- _private.state.version = line.replace(/^OK MPD /, '');
-
- _private.responceProcessor = onRawData;
-
- if(typeof _password !== 'undefined'){
- issueCommands({
- command:'password '+_password,
- error:cancelLoad
- });
- }
-
- //issue the commands that will (re)init this object
- loadEverything();
- }
-
- /********************\
- |* command handlers *|
- \********************/
-
- /**
- * handles the 'tagtypes' command
- */
- function tagHandler(lines){
- var tag_types = processListResponce(lines);
- _private.tag_types = ['any'].concat(
- tag_types.map(function(tagtype){
- return tagtype.tagtype.toLowerCase();
- })
- );
- }
-
- /**
- * deal with the result of the 'outputs' command
- */
- function outputHandler(lines){
- _private.outputs = processListResponce(lines);
-
- callHandler('OutputChanged',self.getOutputs());
- }
-
- /**
- * handle the responce from the 'status' command
- * @private
- */
- function stateHandler(lines){
-
- //update this so playtime is calculated accurately
- _private.last_status_update_time = new Date();
-
- log('state');
-
- //convert the lines into an object
- var state = {};
- lines.forEach(function(line){
- var key = line.replace(/([^:]+): (.*)/,'$1');
- var value = line.replace(/([^:]+): (.*)/,'$2');
- if(value.match(/^\d*(\.\d*)?$/)){
- value = parseFloat(value);
- }
- state[key] = value;
- });
-
- //normalize some of the state properties because I don't like them the way they are
- //because of course I know better than the MPD maintainers what things should be called and the ranges things should be in
- state.current_song = {
- queue_idx: state.song,
- elapsed_time: state.elapsed,
- id: state.songid
- };
- delete state.song;
- delete state.elapsed;
- delete state.songid;
-
- state.mix_ramp_threshold = state.mixrampdb;
- state.playstate = state.state;
- state.queue_version = state.playlist;
- state.crossfade = (typeof state.xfade === 'undefined')?0:state.xfade;
- delete state.mixrampdb;
- delete state.state;
- delete state.playlist;
- delete state.xfade;
-
- state.next_song = {
- queue_idx: state.nextsong,
- id: state.nextsongid
- };
- delete state.nextsong;
- delete state.nextsongid;
-
- state.volume /= 100;
-
- for(property in state){
- _private.state[property] = state[property];
- }
-
- callHandler('StateChanged',self.getState());
- }
-
-
- /**
- * handler for the current queue
- * @private
- */
- function queueHandler(lines){
- var queue_songs = processListResponce(lines);
-
- var source = { songs: queue_songs.map(
- function(song){
- return MPD.QueueSong(self,song);
- }
- )};
-
- _private.state.current_queue = MPD.Queue(self, source);
-
- callHandler('QueueChanged',self.getQueue());
- }
-
-
- /**
- * handler for the list of playlists
- * @private
- */
- function playlistsHandler(lines){
- _private.state.playlists = processListResponce(lines);
-
- callHandler('PlaylistsChanged',self.getPlaylists());
- }
-
- /*\
- | meta-handlers
- \*/
-
- /**
- * get a handler wrapper for the results of a search
- * @private
- */
- function getSearchHandler(onDone){
- return function(lines){
- var results = processListResponce(lines);
- onDone(results.map(function(song){
- return MPD.SearchSong(self,song);
- }));
- };
- }
-
-
- /**
- * get a handler wrapper for the results of a tag search
- * @private
- */
- function getTagSearchHandler(onDone, tag){
- return function(lines){
- var results = processListResponce(lines);
- onDone(results.map(function(result){
- return result[tag];
- }));
- };
- }
-
-
- /**
- * handler for the list of directories
- * @private
- */
- function getDirectoryHandler(onDone){
- return function(lines){
- var results = processListResponce(lines, /^file$|^directory$/);
- onDone(results.map(function(file){
- if(typeof file.file !== 'undefined'){
- return MPD.FileSong(self,file);
- }
- else{
- return MPD.Directory(self,file);
- }
- }));
- };
- }
-
-
- /**
- * handler for loading a single playlist
- * @private
- */
- function getPlaylistHandler(onDone, idx){
- return function(lines){
- var results = processListResponce(lines);
-
- var source = cloneObject(_private.state.playlists[idx]);
- source.songs = results.map(function(song, pos){
- song.position = pos;
- return MPD.PlaylistSong(self,song);
- });
- onDone(MPD.Playlist(self,source));
- };
- }
-
-
- /**
- * given a change key, return the command that will result in getting the changed data
- * @private
- */
- function figureOutWhatToReload(change){
- switch(change){
- case 'database': //the song database has been modified after update.
- //reload
- //everything
- return 'everything';
- break;
-
- case 'stored_playlist': //a stored playlist has been modified, renamed, created or deleted, no idea which one
- return 'playlist';
- break;
-
- case 'playlist': //the current playlist has been modified
- return 'queue';
- break;
-
- /*these are all status changed*/
- case 'player': //the player has been started, stopped or seeked
- case 'mixer': //the volume has been changed
- case 'options': //options like repeat, random, crossfade, replay gain
- return 'status';
- break;
-
- case 'output': //an audio output has been enabled or disabled
- return 'outputs';
- break;
-
- /*these are things I'm not interested in (yet)*/
- case 'update': //a database update has started or finished. If the database was modified during the update, the database event is also emitted.
- //we don't want to do anything, but the front end might be interested in knowing about it
- callHandler('DatabaseChanging');
- case 'sticker': //the sticker database has been modified.
- case 'subscription': //a client has subscribed or unsubscribed to a channel
- case 'message': //a message was received on a channel this client is subscribed to; this event is only emitted when the queue is empty
- default:
- //default do nothing
- }
- }
-
-
- /**
- * wait for something to change
- * this is the state we spend most of out time in
- * @private
- */
- function idleHandler(lines){
- if(lines.length > 0){
- var actions = {};
- lines.forEach(function(line){
- var change = line.replace(/([^:]+): (.*)/,'$2');
- actions[figureOutWhatToReload(change)] = true;
- });
-
- if(actions.everything){
- //don't even bother doing anything fancy
- loadEverything(true);
- }
- else{
- //now we have to reload all the stuff we need
- //in the right order
-
- var commands = [];
-
- if(actions.queue){
- commands.push({
- command:'playlistinfo',
- handler:queueHandler
- });
- }
- if(actions.status){
- commands.push({
- command:'status',
- handler:stateHandler
- });
- }
- if(actions.outputs){
- commands.push({
- command:'outputs',
- handler:outputHandler
- });
- //TODO remove this hack when this bug is fixed in MPD
- setTimeout(function(){
- issueCommands({
- command:'status',
- handler:stateHandler
- });
- },500);
- }
- if(actions.playlist){
- commands.push({
- command:'listplaylists',
- handler:playlistsHandler
- });
- }
-
- if(commands.length > 0){
- issueCommands(commands,false);
- }
- }
- }
- }
-
-
- /**
- * method name says it all
- * @private
- */
- function loadEverything(reload){
- setInited(false);
-
- //this loads all of the data from the MPD server we need
- //it gets the queue first, then the state (because the state references the queue),
- //then all of the other data that shouldn't change without MPD going down in no particular order
- issueCommands(
- [
- {
- command:'playlistinfo',
- handler:queueHandler,
- error:cancelLoad
- },
- {
- command:'status',
- handler:stateHandler,
- error:cancelLoad
- },
- {
- command:'tagtypes',
- handler:tagHandler,
- error:cancelLoad
- },
- {
- command:'outputs',
- handler:outputHandler,
- error:cancelLoad
- },
- {
- command:'listplaylists',
- handler:playlistsHandler,
- error:cancelLoad
- },
- function(){
- setInited(true);
- callHandler('DataLoaded',_private.state);
- }
- ],
- reload === true
- );
- }
-
- /**
- * deal with getting an error during initial data load
- */
- function cancelLoad(error){
- _private.socket.close();
- _private.commandHandlers = [];
- _private.command_queue = [];
- _private.state.connected = false;
- defaultErrorHandler(error);
- }
-
-
- /**********\
- |* events *|
- \**********/
-
-
- /**
- * call all event handlers for the specified event
- * @private
- */
- function callHandler(event_name, args, uncached){
- if(!_private.inited && !uncached){
- var event_obj = {};
- event_obj[event_name] = args;
- _private.queued_events.push(event_obj);
- return;
- }
-
- var handler_name = 'on'+event_name;
-
- if(!_private.handlers[handler_name]){
- handler_name = 'onUnhandledEvent';
- }
-
- if(_private.handlers[handler_name]){
- _private.handlers[handler_name].forEach(function(func){
- try{
- func(args, self);
- }
- catch(err){
- callHandler('Error', err, true);
- }
- });
- }
-
- if(event_name !== 'Event'){
- callHandler('Event', {type:event_name, data:args}, uncached);
- }
- }
-
-
- /**
- * add an event handler
- * @private
- */
- function on(event_name, handler){
-
- var acceptable_handlers = ['Error', 'Event', 'UnhandledEvent', 'DatabaseChanging', 'AuthFailure', 'DataLoaded', 'StateChanged', 'OutputChanged', 'QueueChanged', 'PlaylistsChanged', 'PlaylistChanged','Connect', 'Disconnect'];
-
- if(acceptable_handlers.indexOf(event_name) === -1){
- throw new Error("'"+event_name+"' is not a supported event");
- }
-
-
- //bind the passed method to the client interface
- handler = handler.bind(self);
-
- var handler_name = 'on'+event_name;
- if(_private.handlers[handler_name]){
- _private.handlers[handler_name].push(handler);
- }
- else{
- _private.handlers[handler_name] = [handler];
- }
- }
-
- /*******************\
- |* utility methods *|
- \*******************/
-
- /**
- * logging function
- * @private
- */
- function log(message){
- if(_private.do_logging){
- console.log("MPD Client: "+message);
- }
- }
-
- /**
- * private method that gets the right websocket URL
- * @private
- */
- function getAppropriateWsUrl()
- {
- var protocol = '';
- var url = _host;
- if(typeof url === 'undefined'){
- //change the url so it points to the root
- _host = url = document.URL.replace(/((?:https?:\/\/)?[^\/]+).*/, '$1');
- }
-
- /*
- * We open the websocket encrypted if this page came on an
- * https:// url itself, otherwise unencrypted
- */
-
- //figure out protocol to use
- if(url.substring(0, 5) == "https"){
- protocol = "wss://";
- url = url.substr(8);
- }
- else if(url.substring(0, 3) == "wss"){
- protocol = "wss://";
- url = url.substr(6);
- }
- else{
- protocol = "ws://";
- url = url.replace(/^\w+:\/\//, '');
- }
-
- url = protocol+url;
-
- if(_port){
- //use the port this client was initialized with
- url = url.replace(/:\d*$/,'')+':'+_port;
- }
-
- return url;
- }
-
-
- /**
- * converts an string to a Date
- * @private
- */
- function parseDate(source){
- var value = null;
- var matches = null;
- if(matches = source.match(/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})Z/)){
- value = new Date();
- value.setFullYear(parseInt(matches[1],10));
- value.setMonth(parseInt(matches[2],10)-1);
- value.setDate(parseInt(matches[3],10));
- value.setHours(parseInt(matches[4],10));
- value.setMinutes(parseInt(matches[5],10));
- value.setSeconds(parseInt(matches[6],10));
- }
- return value;
- }
-
- /******************\
- |* public methods *|
- \******************/
-
-
- /**
- * get the current play time
- * @private
- */
- function getCurrentSongTime(){
- var current_song = getCurrentSong();
- if(!current_song){
- return 0;
- }
-
- var offset = 0;
- if(_private.state.playstate === 'play'){
- var now = new Date();
-
- offset = (now.getTime() - _private.last_status_update_time.getTime())/1000;
- }
-
- var last_time = _private.state.current_song.elapsed_time;
- last_time = last_time?last_time:0;
-
- return Math.min(last_time + offset, current_song.getDuration());
- }
-
-
- /**
- * get the song identified by it's position on the current queue, or null
- * @private
- */
- function getSongOnQueue(idx){
- var song = null;
- if(idx !== null && _private.state.current_queue.getSongs()[idx]){
- song = _private.state.current_queue.getSongs()[idx];
- }
- return song;
- }
-
-
- /**
- * get the current song, or null
- * @private
- */
- function getCurrentSong(){
- return getSongOnQueue(_private.state.current_song.queue_idx);
- }
-
-
- /**
- * get the song next on the queue, or null
- * @private
- */
- function getNextSong(){
- return getSongOnQueue(_private.state.next_song.queue_idx);
- }
-
- /**
- * make a deep copy of the passed object/array/primitive
- * @private
- */
- function cloneObject(obj){
- return JSON.parse(JSON.stringify(obj));
- }
-
-
- /********\
- |* INIT *|
- \********/
- init();
- //see I told you it was called down here
-
- return self;
-
-};
-
-/******************\
- |* static methods *|
- \******************/
-
-/**
- * return an enum that maps error numbers to something that is almost readable
- * @instance
- * @returns {Object}
- */
-MPD.getErrorCodes = function(){
- return {
- ACK_ERROR_NOT_LIST: 1,
- ACK_ERROR_ARG: 2,
- ACK_ERROR_PASSWORD: 3,
- ACK_ERROR_PERMISSION: 4,
- ACK_ERROR_UNKNOWN: 5,
- ACK_ERROR_NO_EXIST: 50,
- ACK_ERROR_PLAYLIST_MAX: 51,
- ACK_ERROR_SYSTEM: 52,
- ACK_ERROR_PLAYLIST_LOAD: 53,
- ACK_ERROR_UPDATE_ALREADY: 54,
- ACK_ERROR_PLAYER_SYNC: 55,
- ACK_ERROR_EXIST: 56
- };
-};
-
-/******************\
- |* nested classes *|
- \******************/
-
-/**
- * A song that exsists in the MPD database
- * @class Song
- * @param {MPD} client - the MPD client object that owns this
- * @param {song_metadata} source - raw metadata javascript object that contains the MPD reported data for this song
- */
-MPD.Song = function(client, source){
- /**
- * @lends Song
- */
- var me = {};
-
- /**
- * get the MPD reported metadata, raw
- * @instance
- * @returns {song_metadata} gets the all of the raw metadata MPD provided
- */
- me.getMetadata = function(){
- return JSON.parse(JSON.stringify(source));
- };
-
- /**
- * get the best looking name for this song, prefer Title, fallback to something derived from filename
- * @instance
- * @returns {String} a good looking display name for this sing, suitable for presenting to the user
- */
- me.getDisplayName = function(){
- if(typeof source.title === 'undefined'){
- return source.file.replace(/^([^\/]*\/)+|\.\w+/g, '');
- }
- return source.title;
- };
-
- /**
- * get the filename
- * @instance
- * @returns {String} the full path to the music file in MPD's music directory. relative path.
- */
- me.getPath = function(){
- return source.file;
- };
-
- /**
- * when was the song file last altered
- * @instance
- * @returns {Date} when the song file last altered
- */
- me.getLastModified = function(){
- return source.last_modified;
- };
-
- /**
- * get the song's duration
- * @instance
- * @returns {Number} song duration in number of seconds
- */
- me.getDuration = function(){
- return source.time;
- };
-
- /**
- * get the song's artist
- * @instance
- * @returns {String} from the song metadata
- */
- me.getArtist = function(){
- return source.artist;
- };
-
- /**
- * get the song's title
- * @instance
- * @returns {String} from the song metadata
- */
- me.getTitle = function(){
- return source.title;
- };
-
- /**
- * get the song's album
- * @instance
- * @returns {String} from the song metadata
- */
- me.getAlbum = function(){
- return source.album;
- };
-
- /**
- * get the song's track
- * @instance
- * @returns {String} from the song metadata
- */
- me.getTrack = function(){
- return source.track;
- };
-
- /**
- * get the song's genre
- * @instance
- * @returns {String} from the song metadata
- */
- me.getGenre = function(){
- return source.genre;
- };
-
- /**
- * get the reported disk number from of the song, note this need not be a number or numeric, also need not exsist
- * @instance
- * @returns {String} reported disk
- */
- me.getDisk = function(){
- return source.disk;
- };
-
- /**
- * if this song is on the Queue, get the QueueSong
- * @instance
- * @returns {QueueSong}
- */
- me.getQueueSong = function(){
- var queue = client.getQueue().getSongs();
- for(var i = 0; i20",
- "parentId": "1f969cc6-89c4-f559-e824-daf7dfff35cf",
- "id": "c6bc0ef4-5b85-b543-4df7-3c00dd73a9eb",
- "wait": "10",
- "description": "No Description
sdfsdf",
- "type": "added",
- "items": [
- "0caac742-956e-de6b-6b53-36fb8174e5e0"
- ],
- "declaredClass": "xblox.model.loops.WhileBlock",
- "loopLimit": 1500,
- "name": "While",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "name": "Fade-Volume-Up",
- "group": "conditional",
- "id": "48a83acf-f2ef-ccdf-44a7-621fb635e3c4",
- "interval": "0",
- "type": "added",
- "items": [
- "0a561903-9422-f97d-8a76-0757177a7471"
- ],
- "waitForResponse": false,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "",
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "condition": "[Volume]<80",
- "parentId": "48a83acf-f2ef-ccdf-44a7-621fb635e3c4",
- "id": "0a561903-9422-f97d-8a76-0757177a7471",
- "wait": "10",
- "type": "added",
- "items": [
- "660a553b-ff5d-ca79-c114-955800c8de76"
- ],
- "declaredClass": "xblox.model.loops.WhileBlock",
- "loopLimit": 1500,
- "name": "While",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "PowerState",
- "send": "nada",
- "group": "basicVariables",
- "id": "31c98cdd-02a8-3af1-3a49-11955c0fad48",
- "type": "added",
- "value": "on",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "isVariable": true,
- "flags": 4096,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "name": "VolumeDown",
- "send": "return 'MV' + (this.getVariable('Volume') - 2);",
- "group": "basic",
- "id": "69f6d4fb-4300-0498-9bbf-27554f5f1fa4",
- "auto": "-1",
- "type": "added",
- "icon": "fa-arrow-down",
- "interval": "0",
- "waitForResponse": false,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "VolumeNormal",
- "send": "MV35",
- "group": "basic",
- "id": "963944c2-c0b0-fe8a-504e-1b8bedd2a3cf",
- "auto": false,
- "type": "added",
- "interval": "2000",
- "waitForResponse": false,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "group": "conditionalProcess",
- "id": "007e54b9-9d9a-df86-4693-9ea627443700",
- "method": "console.log('run script2 ' + arguments[0]);",
- "enabled": false,
- "type": "added",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "shareTitle": "",
- "order": 0,
- "outlet": 0,
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [],
- "name": "Volume-Loud",
- "group": "basicVariables",
- "id": "b16bfc09-e449-d514-dc98-10b8afbb14f8",
- "value": "61",
- "type": "added",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "isVariable": true,
- "flags": 4096,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "name": "Test",
- "group": "basicVariables",
- "id": "487b9e80-ca4c-c096-0950-91aad9dd4612",
- "value": "return [Volume] + 2;",
- "type": "added",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "isVariable": true,
- "flags": 4096,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "c6bc0ef4-5b85-b543-4df7-3c00dd73a9eb",
- "id": "0caac742-956e-de6b-6b53-36fb8174e5e0",
- "command": "69f6d4fb-4300-0498-9bbf-27554f5f1fa4",
- "type": "added",
- "declaredClass": "xblox.model.functions.CallBlock",
- "icon": "",
- "_timeout": 100,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "startup": false,
- "send": "",
- "name": "No Title",
- "interval": 0,
- "flags": 2048
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "0a561903-9422-f97d-8a76-0757177a7471",
- "id": "660a553b-ff5d-ca79-c114-955800c8de76",
- "command": "6d0c5e0e-5c04-bb98-44a0-705c8269de07",
- "type": "added",
- "declaredClass": "xblox.model.functions.CallBlock",
- "icon": "",
- "_timeout": 100,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "startup": false,
- "send": "",
- "name": "No Title",
- "interval": 0,
- "flags": 2048
- },
- {
- "_containsChildrenIds": [],
- "name": "Set Master Volume",
- "group": "basic",
- "id": "ad01c68d-cdbb-7ba7-0046-c9f4c9113f4b",
- "send": "return \"MV \" + [Volume];",
- "interval": "0",
- "waitForResponse": false,
- "type": "added",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "79fcb092-2465-6561-c1f7-4ceb81bee04a",
- "event": "onDriverVariableChanged",
- "enabled": false,
- "type": "added",
- "filterValue": "Volume",
- "items": [
- "8c824b5b-8daf-0290-8b88-2a268da926ad"
- ],
- "reference": "",
- "declaredClass": "xblox.model.events.OnEvent",
- "name": "On Event",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "filterPath": "item.name",
- "valuePath": "item.value",
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "79fcb092-2465-6561-c1f7-4ceb81bee04a",
- "id": "8c824b5b-8daf-0290-8b88-2a268da926ad",
- "method": "console.log(\"variable changed\" ,arguments[0]);",
- "enabled": false,
- "type": "added",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "shareTitle": "",
- "order": 0,
- "description": "No Description",
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Source",
- "group": "basicVariables",
- "id": "a95618a6-93b3-de15-6eec-2893e2eb2527",
- "value": "BD",
- "type": "added",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "isVariable": true,
- "flags": 4096,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "name": "Ping - Volume",
- "group": "basic",
- "id": "dec01610-0355-f038-71c8-a46b2cde5fd2",
- "send": "MV?",
- "interval": "",
- "waitForResponse": false,
- "type": "added",
- "auto": false,
- "startup": true,
- "declaredClass": "xcf.model.Command",
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Ping - Power",
- "group": "basic",
- "id": "a5423bf7-7b99-023d-c637-363fbf9a7f18",
- "startup": true,
- "send": "PW?",
- "interval": "",
- "waitForResponse": false,
- "icon": "fa-bell",
- "type": "added",
- "auto": false,
- "declaredClass": "xcf.model.Command",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Ping - Source",
- "group": "basic",
- "id": "13bd8c70-9cf3-28c9-8c5c-315e54f3cc9d",
- "send": "SI?",
- "interval": "",
- "waitForResponse": false,
- "icon": "fa-bell",
- "type": "added",
- "auto": false,
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "name": "Last Value",
- "group": "basicVariables",
- "id": "611b5637-dd3e-760e-dcd4-0d21faaaeeff",
- "type": "added",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": -1,
- "register": true,
- "readOnly": false,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "isVariable": true,
- "flags": 4096,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "dstField": "elseIfBlocks",
- "parentId": "980b8fd2-3538-4003-85f9-7f70e2b92cb6",
- "id": "e3720be6-741c-96f4-de07-7edce704264b",
- "condition": "[value]=='END'",
- "type": "added",
- "items": [
- "d99f0616-ab67-efd7-f4c1-01fa0168c1f8"
- ],
- "name": "else if",
- "declaredClass": "xblox.model.logic.ElseIfBlock",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "dstField": "elseIfBlocks",
- "parentId": "980b8fd2-3538-4003-85f9-7f70e2b92cb6",
- "id": "63b534b4-2607-2749-20c5-b109c9c3df3d",
- "type": "added",
- "items": [
- "733c68ae-b22b-c40c-a215-e5a80c8f6dc3"
- ],
- "name": "else if",
- "declaredClass": "xblox.model.logic.ElseIfBlock",
- "condition": "",
- "icon": "",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [
- "items",
- "elseIfBlocks",
- "consequent"
- ],
- "group": "conditionalProcess",
- "condition": "return [value]=='PW';",
- "id": "980b8fd2-3538-4003-85f9-7f70e2b92cb6",
- "items": [
- "e3720be6-741c-96f4-de07-7edce704264b",
- "63b534b4-2607-2749-20c5-b109c9c3df3d"
- ],
- "enabled": false,
- "type": "added",
- "elseIfBlocks": [
- "e3720be6-741c-96f4-de07-7edce704264b",
- "63b534b4-2607-2749-20c5-b109c9c3df3d"
- ],
- "declaredClass": "xblox.model.logic.IfBlock",
- "name": "if",
- "icon": "",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "consequent": [
- "b45e388f-bfa9-9472-c93c-aa3f101e3a80"
- ]
- },
- {
- "_containsChildrenIds": [],
- "id": "d99f0616-ab67-efd7-f4c1-01fa0168c1f8",
- "enabled": false,
- "type": "added",
- "parentId": "e3720be6-741c-96f4-de07-7edce704264b",
- "declaredClass": "xblox.model.logging.Log",
- "name": "Log Message",
- "level": "info",
- "message": "return \"Message: \" + arguments[0];",
- "_type": "XBlox",
- "host": "this host",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "id": "733c68ae-b22b-c40c-a215-e5a80c8f6dc3",
- "enabled": false,
- "type": "added",
- "parentId": "63b534b4-2607-2749-20c5-b109c9c3df3d",
- "declaredClass": "xblox.model.logging.Log",
- "name": "Log Message",
- "level": "info",
- "message": "return \"Message: \" + arguments[0];",
- "_type": "XBlox",
- "host": "this host",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "id": "b45e388f-bfa9-9472-c93c-aa3f101e3a80",
- "enabled": false,
- "type": "added",
- "parentId": "980b8fd2-3538-4003-85f9-7f70e2b92cb6",
- "declaredClass": "xblox.model.logging.Log",
- "name": "Log Message",
- "level": "info",
- "message": "return \"Message: \" + arguments[0];",
- "_type": "XBlox",
- "host": "this host",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "name": "Set TV",
- "group": "basic",
- "id": "e4d05d14-1798-a168-e984-8588d7463b75",
- "send": "SITV",
- "waitForResponse": false,
- "type": "added",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "init",
- "id": "ee4d83cc-b3a4-c2eb-9f32-344fb476d646",
- "send": "PW?",
- "name": "PingPower",
- "type": "added",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "init",
- "id": "e63cba29-0cf3-7839-a631-75fb9424ab8e",
- "send": "MV?",
- "name": "PingVolume",
- "interval": "0",
- "type": "added",
- "items": [
- "7a0bc101-6a7e-1de5-7dab-bc787953022a"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0
- },
- {
- "_containsChildrenIds": [],
- "parentId": "e63cba29-0cf3-7839-a631-75fb9424ab8e",
- "id": "7a0bc101-6a7e-1de5-7dab-bc787953022a",
- "method": "console.error('init');",
- "type": "added",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [],
- "name": "Set Blue-Ray",
- "id": "c9bc7af6-0de9-0aa7-e6de-6a635cd50ea7",
- "send": "SIBD",
- "waitForResponse": false,
- "type": "added",
- "group": "basic",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "icon": "fa-exclamation",
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "flags": 2048,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "group": "conditionalProcess",
- "id": "43062d7e-6cfd-040c-34bf-7a01c428c057",
- "variable": "31c98cdd-02a8-3af1-3a49-11955c0fad48",
- "enabled": false,
- "type": "added",
- "_stopped": false,
- "declaredClass": "xblox.model.variables.VariableSwitch",
- "name": "Switch on Variable",
- "icon": "",
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "outlet": 0
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "53a10527-709b-4c7d-7a90-37f58f17c8db",
- "id": "68f4c183-ef18-cb55-8eb2-da850900c9e8",
- "declaredClass": "xblox.model.functions.CallBlock",
- "command": "command://deviceScope=user_devices&device=fa2b4417-50b5-e74f-e5c1-75c3e7c839f1&driver=8fec6dd4-f647-291d-0a9b-27eea266f6d0&driverScope=user_drivers&block=0c7d9511-eb8c-3f26-b5f9-14669497c862",
- "icon": "",
- "_timeout": 100,
- "startup": false,
- "send": "",
- "name": "No Title",
- "interval": 0,
- "flags": 2048,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Marantz/MyMarantz.js b/shredder/asterix-pp/asterix-hmi/drivers/Marantz/MyMarantz.js
deleted file mode 100644
index 39acfe0fb..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Marantz/MyMarantz.js
+++ /dev/null
@@ -1,270 +0,0 @@
-define([
- "dcl/dcl",
- "xcf/model/Command",
- 'xide/utils',
- 'xide/types',
- 'xdojo/has',
- "xdojo/has!host-node?nxapp/protocols/ProtocolBase"
-], function (dcl,Command,utils,types,has,ProtocolBase) {
- // The returning module
- var Module = dcl(null, {
- updatePower: function (value) {
- value = value || this.getVariable('value');
- var out = 0;
- if (value.indexOf('@PWR:') != -1) {
- var _pw = value.split(':')[1];
- if (!isNaN(_pw)) {
- this.setVariable('PowerState', _pw == 2 ? 'on' : 'off');
- out = _pw;
- }
- }
- return out;
- },
- updateSource: function (value) {
- value = value || this.getVariable('value');
- if (value.startsWith('SI') && value.indexOf("@") ==-1 && value.length>2) {
- var _source = value.substring(2, value.length);
- this.setVariable('Source', _source);
- }
- },
- updateVolume: function (value) {
- value = value || this.getVariable('value') || "";
- var out = 0;
- if (value.indexOf('MV') != -1 && value.indexOf('MVMAX') == -1) {
- var _volume = value.substring(2, value.length);
- _volume = parseInt(_volume.substring(0, 2),10);
- if (!isNaN(_volume)) {
- this.setVariable('Volume', _volume);
- out = _volume;
- } else {
- return null;
- }
- } else {
- return null;
- }
- return out;
- },
- testx: function (arg) {
- console.log('testx');
- return "mv?";
- },
- testCall: function (test) {
- var value = this.callCommand('PowerOn');
- },
- onMessage: function (data) {
- var message = data.message || "";
- if(!message || !message.length){
- return;
- }
- this.updateVolume(message);
- this.updatePower(message);
- this.updateSource(message);
- if (data.message.indexOf('MVMAX') != -1) {
- return;
- }
- },
- onDriverVariableChanged:function(evt){
-
- //grab the variable
- var variable = evt.item;
-
- //grab the xblox scope
- var blockScope = variable.scope;
-
- //abort if is not ours, we also receive here variable changes from other devices
- // notice: we use != instead of !==
- // this is because we compare 2 object pointers and not two primitive's values
- if(blockScope != this.blockScope){
- return;
- }
-
- //Example: make some special effort for variable "Volume"
- //if(variable.name ==="Volume"){
- //console.info("Volume changed : " + variable.value);
- //}
-
-
- //Example: abort if it is not a certain variable
- if(variable.name !=="value"){
- //console.warn("skip variable " + variable.name);
- return;
- }
-
- //Example: print something in console
- //console.log('onDriverVariableChanged ' + variable.name + ' new value:' + variable.value);
-
-
- //Example: do something with the variable
- var value = "" + variable.value; //important, build a new string
- value++;
-
- //Example: call a command
- if(value ==='whatever'){
- this.callCommand("Command Name");
- }
-
- //Example: store it in another variable
- if(value ==='whatever'){
- this.setVariable("the other variable's name ",value);
- }
-
-
- },
- /**
- * This function is called as soon the device is connected
- */
- start:function(){
- //some debugging message
- //console.log('started Marantz',this);
- //Example: we subscribe on variable changes, globally
- this.subscribe("onDriverVariableChanged");
- //Example, specify the event handler explizit
- //this.subscribe("onDriverVariableChanged",this.onDriverVariableChanged);
- }
- });
- //////////////////////////////////////////////////////////
- //
- // Constants
- //
- var isServer = has('host-node'); // We are running server-side ?
- var isIDE = has('xcf-ui'); // We are running client-side and in the IDE?
-
- function patchModule(){
- Module.getFields = function (command, fields) {
- var result = [];
-
- if(command._gpioFunc === 'setMode') {
-
- command._value = command._value || 1;
-
- result.push(utils.createCI('test', types.ECIType.STRING, command._gpio, {
- group: 'GPIO',
- title: 'Value',
- dst: '_gpio',
- order: 199
- }));
- }
- return result;
- };
-
- /**
- *
- * @param label
- * @param icon
- * @param ctrAgs
- * @param variables
- * @param send
- * @param func
- * @param description
- * @param scope
- * @param owner
- * @param target
- * @param group
- */
- function createBlock(label,icon,ctrAgs,variables,send,func,description,scope, owner, target, group){
- return {
- name: label,
- owner: owner,
- icon: icon,
- proto: Command,
- target: target,
- ctrArgs: utils.mixin({
- icon:icon,
- flags:0,
- name:label,
- scope: scope,
- group: group,
- variables:variables ? JSON.stringify(variables) : "{}",
- send:send,
- _isGPIO:true,
- _gpioFunc:func,
- description:description
- },ctrAgs)
- };
- }
-
- /**
- * Extend xblox for new blocks/commands.
- * @param scope
- * @param owner
- * @param target
- * @param group
- * @param items
- * @returns {*}
- */
- Module.getNewBlocks=function(scope, owner, target, group, items){
- if(!items){
- return null;
- }
- items.push({
- name: 'Marantz',
- iconClass: 'fa-code',
- items: [
- createBlock('Set Input','fa-cogs',null,
- { 'GPIO': '_gpio'},
- "SI {{GPIO}}","setMode",
- "Sets the GPIO mode",
- scope,owner,target,group)
- ]
- });
- return items;
- };
-
- /**
- * Override interface for "toText"
- * @param command
- * @param text
- * @returns {*}
- */
- Module.toText = function (command, text) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
-
- for(var variable in commandVariables){
- variables[variable]=command[commandVariables[variable]] || " ";
- }
- text = utils.replace(text,null,variables,{
- begin:'{{',
- end:'}}'
- });
- return text;
- }
-
- };
- Module.resolveAfter = function (command,inputString) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
- for(var variable in commandVariables){
- variables[variable]=command._resolve(command[commandVariables[variable]],{
- flags:0x00000800
- },false);
- }
- inputString = utils.replace(inputString,null,variables,{
- begin:'{{',
- end:'}}'
- });
- }
- return inputString;
- };
- }
-
- //No ProtocolBase means we're running on client side
- if (!ProtocolBase) {
- //create dummy module
- //Module = dcl(null, {});
- patchModule();
- return Module;
- }
-
- patchModule();
-
- return Module;
-});
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.js b/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.js
deleted file mode 100644
index 742f3fe87..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @module xcf/driver/DefaultDriver */
-define([
- "dcl/dcl",
- 'xdojo/has',
- 'xide/utils'
-], function (dcl, has, utils) {
-
- // The returning module
- var Module = null;
-
- //////////////////////////////////////////////////////////
- //
- // Constants
- //
- var isServer = has('host-node'); // We are running server-side ?
- var isIDE = has('xcf-ui'); // We are running client-side and in the IDE?
-
- /**
- * Default driver template. This will used for new drivers!
- *
- * @class module:xcf/driver/DefaultDriver
- * @extends module:xcf/driver/DriverBase
- * @augments module:xide/mixins/EventedMixin
- * @link http://rawgit.com/net-commander/windows-dist/master/docs/Driver/modules/module-xcf_driver_DriverBase.html
- */
- Module = dcl(null, {
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- //onMessage: function (data) {}
- });
-
-
- //////////////////////////////////////////////////////////
- //
- // Optional: An example implementation to extend commands in the interface for additional fields
- //
- if (isIDE) {
- /**
- *
- * @param command {module:xcf/model/Command} The command which for which want to populate the fields.
- * @param fields {Object[]}
- * @link http://rawgit.com/net-commander/windows-dist/master/docs/Driver/modules/xcf_model_Command.js.html
- */
- Module.getFields = function (command, fields) {
- /*
- return [utils.createCI('test', 0, command.test, {
- group: 'General',
- title: 'test',
- dst: 'test',
- order: 198
- })];
- */
- return [];
- };
- }
-
- //////////////////////////////////////////////////////////
- //
- // Optional: An example implementation to modify the string sent to a advice. This makes sense if you added additional fields as shown above.
- //
- /**
- * Callback when a command is before parsing the expression in the "send" field.
- * @param command {module:xcf/model/Command}
- * @param inputString {string}
- * @returns {string}
- */
- /*
- Module.resolveBefore = function (command,inputString) {
- return inputString;
- };
- */
- /**
- * Callback when a command was parsing the expression in the "send" field.
- * @param command {module:xcf/model/Command}
- * @param inputString {string}
- * @returns {string}
- */
- /*
- Module.resolveAfter = function (command,inputString) {
- return inputString;
- };
- */
-
- return Module;
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.meta.json
deleted file mode 100644
index 2edf705b6..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.meta.json
+++ /dev/null
@@ -1,168 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "Motion-Eye-MQTT",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "69e4469f-f2a8-3c22-e973-49380c22f600",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./Motion-Eye/Motion-Eye-MQTT.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "[]",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.xblox
deleted file mode 100644
index af9965a47..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Motion-Eye/Motion-Eye-MQTT.xblox
+++ /dev/null
@@ -1,171 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "id": "ff612a70-4b0c-a0bb-e4ed-a3da1715fffc",
- "name": "value",
- "value": "",
- "type": "added",
- "group": "processVariables",
- "gui": false,
- "cmd": false,
- "declaredClass": "xcf.model.Variable",
- "save": false,
- "target": "None",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "id": "c621527a-d3e0-1db8-50ff-735adcaad462",
- "items": [
- "d3a4572a-7a40-33da-7ef6-f51e565e3704",
- "7c4cd1c9-8a9e-d862-6707-4b34b1ba16fa",
- "4a436c03-1c4b-57a6-95c9-059c5bf0fabb",
- "875b03a9-6085-0ca2-4c55-79ef7806899a"
- ],
- "group": "init",
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "topic": "motionEye/event_start",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "",
- "qos": 0,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "c621527a-d3e0-1db8-50ff-735adcaad462",
- "id": "875b03a9-6085-0ca2-4c55-79ef7806899a",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "console.error('motion detected');",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "id": "8f7bc17d-58df-e96c-1d21-cf00b9eab2dd",
- "items": [
- "4aad0ce4-b62a-56cd-63d4-32ed11915784"
- ],
- "group": "init",
- "topic": "motionEye/event_stop",
- "type": "added",
- "declaredClass": "xblox.model.mqtt.Subscribe",
- "name": "Subscribe",
- "args": "",
- "deferred": false,
- "icon": "fa-bell",
- "path": "",
- "qos": 0,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "parentId": "8f7bc17d-58df-e96c-1d21-cf00b9eab2dd",
- "id": "4aad0ce4-b62a-56cd-63d4-32ed11915784",
- "method": "console.error('motion detected stopped');",
- "type": "added",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": ""
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "c621527a-d3e0-1db8-50ff-735adcaad462",
- "id": "d3a4572a-7a40-33da-7ef6-f51e565e3704",
- "declaredClass": "xblox.model.functions.CallBlock",
- "command": "command://deviceScope=user_devices&device=1b53dd5c-bda3-a45b-27ea-b1adb876d729&driver=117554bc-f6ef-3442-f163-901d5d35d158&driverScope=user_drivers&block=2d2ce608-9a1f-18d6-5298-fefcd85f8bc9",
- "icon": "",
- "_timeout": 100,
- "startup": false,
- "send": "",
- "name": "No Title",
- "interval": 0,
- "flags": 2048,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "condition": "",
- "parentId": "c621527a-d3e0-1db8-50ff-735adcaad462",
- "id": "7c4cd1c9-8a9e-d862-6707-4b34b1ba16fa",
- "declaredClass": "xblox.model.functions.CallBlock",
- "command": "command://deviceScope=user_devices&device=bc09b5c4-cfe6-b621-c412-407dbb7bcef8&driver=9db866a4-bb3e-137b-ae23-793b729c44f8&driverScope=user_drivers&block=450d2c75-29b0-29b7-13c5-be175b2a5749",
- "icon": "",
- "_timeout": 100,
- "startup": false,
- "send": "",
- "name": "No Title",
- "interval": 0,
- "flags": 2048,
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "c621527a-d3e0-1db8-50ff-735adcaad462",
- "id": "4a436c03-1c4b-57a6-95c9-059c5bf0fabb",
- "declaredClass": "xblox.model.logging.Log",
- "name": "Log Message",
- "level": "info",
- "message": "return \"Motion Detected: \" + arguments[0];",
- "_type": "XBlox",
- "host": "this host",
- "description": "No Description",
- "order": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "type": "added",
- "icon": "fa-play"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.js b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.js
deleted file mode 100644
index 3e65083cd..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.js
+++ /dev/null
@@ -1,685 +0,0 @@
-/** @module xcf/driver/DefaultDriver */
-define([
- "dcl/dcl",
- 'xdojo/has',
- 'xide/utils',
- "xcf/model/Command",
- 'xide/types',
- "xdojo/has!host-node?nxapp/protocols/ProtocolBase",
- "xdojo/has!host-node?dojo/node!./node_modules/pigpio",
- "xdojo/has!host-node?dojo/node!yargs-parser"
-], function (dcl, has, utils, Command,types,ProtocolBase, pigpio,yargs) {
-
-
- // The returning module
- var Module = null;
- //////////////////////////////////////////////////////////
- //
- // Constants
- //
- var isServer = has('host-node'); // We are running server-side ?
- var isIDE = has('xcf-ui'); // We are running client-side and in the IDE?
-
- //No ProtocolBase means we're running on client side
- if (!ProtocolBase) {
- //create dummy module
- Module = dcl(null, {});
- patchModule();
- return Module;
- }
-
-
- /**
- * Default driver template. This will used for new drivers!
- *
- * @class module:xcf/driver/DefaultDriver
- * @extends module:xcf/driver/DriverBase
- * @augments module:xide/mixins/EventedMixin
- * @link http://rawgit.com/net-commander/windows-dist/master/docs/Driver/modules/module-xcf_driver_DriverBase.html
- * @link https://github.com/fivdi/pigpio/blob/master/doc/gpio.md#pwmwritedutycycle
- * @link http://www.myelectronicslab.com/tutorial/raspberry-pi-3-gpio-model-b-block-pinout/
- * @link http://razzpisampler.oreilly.com/ch05.html
- */
- Module = dcl([ProtocolBase], {
- _gpios:null,
- destroy: function () {
- for (var id in this._gpios){
- var gpio = this._gpios[id];
- gpio.disableAlert();
- }
- delete this._gpios;
- },
- /**
- * Override connect since we're not really connecting to anything
- */
- connect: function () {
- this._gpios = {};
- this.owner.onConnected();
- },
- /***
- * Standard callback when we have a message from the device we're bound to (specified in profile).
- * 1. put the message in the incoming queue, tag it as 'unread'
- * 2. in case we have messages to send and we are in 'onReply' mode, trigger outgoing queue
- *
- * @param data {Object} : Message Struct build by the device manager
- * @param data.device {Object} : Device info
- * @param data.device.host {String} : The host
- * @param data.device.port {String} : The host's port
- * @param data.device.protocol {String} : The host's protocol
-
- * @param data.message {String} : RAW message, untreated
- */
- write: function (data, options) {
- var intArray = utils.bufferFromDecString(data);
- var buffer = new Buffer(intArray);
- var str = data;
- var args = str.split(" ");
- var cmd = "" + args[0];
- args.shift();
- this.isDebug() && console.log('write : ' + str, args);
- if (typeof this[cmd] === 'function') {
- args.push(options);
- try {
- return this[cmd].apply(this, args);
- }catch(e){
- console.error('Error running '+cmd + " : " + e.message);
- this._sendError({
- error:e.message
- },cmd,options);
- }
- }else{
- console.warn('cmd '+cmd +' doesnt exists');
- }
- },
- _send: function (data, command, options) {
- var wait = options.params.wait;
- var self = this;
- var outString = JSON.stringify(utils.mixin({
- command: command
- }, data, null, 2));
-
- if (wait) {
- self.owner.onFinish(command, options, new Buffer(outString));
- } else {
- self.owner.onData(outString, new Buffer(outString));
- }
- },
- _sendError: function (data, command, options) {
- if(!options){
- console.error('have no options',options);
- }
- if(!options.params){
- console.error('have no params',options);
- }
- var wait = options.params.wait;
- var self = this;
- var outString = JSON.stringify(utils.mixin({
- command: command
- }, data, null, 2));
- if (wait) {
- self.owner.onError(command, options, new Buffer(outString));
- } else {
- self.owner.onData(outString, new Buffer(outString));
- }
- },
- setMode:function(nr,mode,options){
- nr = parseInt(nr,10);
- mode = parseInt(mode,10);
- var gpio = this.getGPIO(nr);
- gpio.mode(mode);
- },
- digitalWrite:function(nr,value,options){
- nr = parseInt(nr,10);
- value = parseInt(value,10);
- var gpio = this.getGPIO(nr);
- gpio.digitalWrite(value);
- this._send({
- value:value,
- gpio:nr
- },'digitalWrite',options);
- },
- digitalRead:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.digitalRead();
- this._send({
- value:value,
- gpio:nr
- },'digitalRead',options);
- },
- getGPIO:function(nr){
- var gpio = this._gpios[nr];
- if(!gpio){
- this._gpios[nr] = new pigpio.Gpio(nr);
- }
- return this._gpios[nr];
- },
- pwmWrite:function(nr,cycle,options){
- nr = parseInt(nr,10);
- cycle = parseInt(cycle,10);
- var gpio = this.getGPIO(nr);
- gpio.pwmWrite(cycle);
- },
- hardwarePwmWrite:function(nr,frequency,cycle,options){
- nr = parseInt(nr,10);
- cycle = parseInt(cycle,10);
- frequency = parseInt(frequency,10);
- var gpio = this.getGPIO(nr);
- gpio.hardwarePwmWrite(frequency,cycle);
- },
- getPwmDutyCycle:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.getPwmDutyCycle();
- this._send({
- value:value,
- gpio:nr
- },'getPwmDutyCycle',options);
- },
- pwmRange:function(nr,range){
- nr = parseInt(nr,10);
- range = parseInt(range,10);
- var gpio = this.getGPIO(nr);
- gpio.pwmRange(range);
- },
- getPwmRange:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.getPwmRange();
- this._send({
- value:value,
- gpio:nr
- },'getPwmRange',options);
- },
- getPwmRealRange:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.getPwmRealRange();
- this._send({
- value:value,
- gpio:nr
- },'getPwmRealRange',options);
- },
- pwmFrequency:function(nr,frequency){
- nr = parseInt(nr,10);
- frequency = parseInt(frequency,10);
- var gpio = this.getGPIO(nr);
- gpio.pwmFrequency(frequency);
- },
- getPwmFrequency:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.getPwmFrequency();
- this._send({
- value:value,
- gpio:nr
- },'getPwmFrequency',options);
- },
- servoWrite:function(nr,pulseWidth,options){
- nr = parseInt(nr, 10);
- pulseWidth = parseInt(pulseWidth, 10);
- var gpio = this.getGPIO(nr);
- gpio.servoWrite(pulseWidth);
-
- },
- getServoPulseWidth:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- var value = gpio.getServoPulseWidth();
- this._send({
- value:value,
- gpio:nr
- },'getServoPulseWidth',options);
- },
- enableInterrupt:function(nr,edge,timeout){
- nr = parseInt(nr,10);
- edge = parseInt(edge,10);
- timeout = parseInt(timeout,10);
- var gpio = this.getGPIO(nr);
- gpio.enableInterrupt(edge,timeout);
- },
- disableInterrupt:function(nr){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- gpio.disableInterrupt();
- },
- enableAlert:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- gpio.enableAlert();
- var self = this;
- gpio.on('alert',function(level,tick){
- self._send({
- level:level,
- tick:tick,
- gpio:nr
- },'enableAlert',options);
- });
- },
- disableAlert:function(nr,options){
- nr = parseInt(nr,10);
- var gpio = this.getGPIO(nr);
- gpio.disableAlert();
- },
- pullUpDown:function(nr,pud){
- nr = parseInt(nr,10);
- pud = parseInt(pud,10);
- var gpio = this.getGPIO(nr);
- gpio.pullUpDown(pud);
-
- },
- trigger:function(nr,pulse,level){
- nr = parseInt(nr,10);
- pulse = parseInt(pulse,10);
- level = parseInt(level,10);
- var gpio = this.getGPIO(nr);
- gpio.trigger(pulse,level);
- },
- init:function(){
- this._gpios = {};
- }
- });
-
-
- //////////////////////////////////////////////////////////
- //
- // Optional: An example implementation to extend commands in the interface for additional fields
- //
-
- function patchModule(){
- Module.getFields = function (command, fields) {
- var result = [];
- //add a GPIO field
- if(command._isGPIO) {
- command._gpio = command._gpio || 17;
- result.push(utils.createCI('test', types.ECIType.STRING, command._gpio, {
- group: 'GPIO',
- title: 'GPIO',
- dst: '_gpio',
- order: 197
- }));
- }
-
- //add gpio mode field
- if(command._gpioFunc === 'setMode') {
- command._mode = command._mode || "OUTPUT";
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._mode, {
- group: 'GPIO',
- title: 'Mode',
- dst: '_mode',
- order: 198,
- widget:{
- options:[
- {value:0,label:"INPUT"},
- {value:1,label:"OUTPUT"},
- {value:4,label:"ALT0"},
- {value:5,label:"ALT1"},
- {value:6,label:"ALT2"},
- {value:7,label:"ALT3"},
- {value:3,label:"ALT4"},
- {value:2,label:"ALT5"}
- ]
- }
- }));
- }
-
-
- if(command._gpioFunc === 'digitalWrite') {
- command._value = command._value || 1;
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._value, {
- group: 'GPIO',
- title: 'Value',
- dst: '_value',
- order: 199,
- widget:{
- options:[
- {value:0,label:"0"},
- {value:1,label:"1"}
- ]
- }
- }));
- }
-
- if(command._gpioFunc === 'pwmWrite') {
- command._value = command._value || 1;
- result.push(utils.createCI('test', types.ECIType.STRING, command._value, {
- group: 'GPIO',
- title: 'Value',
- dst: '_value',
- order: 199
- }));
- }
-
- if(command._gpioFunc === 'hardwarePwmWrite') {
- result.push(utils.createCI('test', types.ECIType.STRING, command._frequency, {
- group: 'GPIO',
- title: 'Frequency',
- dst: '_frequency',
- order: 199
- }));
- }
-
- if(command._gpioFunc === 'servoWrite') {
- result.push(utils.createCI('test', types.ECIType.STRING, command._pulse, {
- group: 'GPIO',
- title: 'Pulse Width',
- dst: '_pulse',
- order: 199
- }));
- }
-
- if(command._gpioFunc === 'pwmRange') {
- result.push(utils.createCI('test', types.ECIType.STRING, command._range, {
- group: 'GPIO',
- title: 'Range',
- dst: '_range',
- order: 199
- }));
- }
-
- if(command._gpioFunc === 'pwmFrequency') {
- result.push(utils.createCI('test', types.ECIType.STRING, command._frequency, {
- group: 'GPIO',
- title: 'Frequency',
- dst: '_frequency',
- order: 199
- }));
- }
-
-
- if(command._gpioFunc === 'enableInterrupt') {
-
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._edge, {
- group: 'GPIO',
- title: 'Edge',
- dst: '_edge',
- order: 200,
- widget:{
- options:[
- {value:0,label:"RISING_EDGE"},
- {value:1,label:"FALLING_EDGE"},
- {value:2,label:"EITHER_EDGE"}
- ]
- }
- }));
-
- result.push(utils.createCI('test', types.ECIType.STRING, command._timeout, {
- group: 'GPIO',
- title: 'Timeout',
- dst: '_timeout',
- order: 201
- }));
- }
-
-
- //add gpio mode field
- if(command._gpioFunc === 'pullUpDown') {
- result.push(utils.createCI('test', types.ECIType.ENUMERATION, command._pud, {
- group: 'GPIO',
- title: 'PUD',
- dst: '_pud',
- order: 199,
- widget:{
- options:[
- {value:0,label:"PUD_OFF"},
- {value:1,label:"PUD_DOWN"},
- {value:2,label:"PI_PUD_UP"}
- ]
- }
- }));
- }
-
- if(command._gpioFunc === 'trigger') {
-
- result.push(utils.createCI('test', types.ECIType.STRING, command._pulse, {
- group: 'GPIO',
- title: 'Pulse Length',
- dst: '_pulse',
- order: 199
- }));
-
- result.push(utils.createCI('test', types.ECIType.STRING, command._level, {
- group: 'GPIO',
- title: 'Level',
- dst: '_level',
- order: 199
- }));
- }
-
- return result;
- };
- /**
- *
- * @param label
- * @param icon
- * @param ctrAgs
- * @param variables
- * @param send
- * @param func
- * @param description
- * @param scope
- * @param owner
- * @param target
- * @param group
- */
- function createBlock(label,icon,ctrAgs,variables,send,func,description,scope, owner, target, group){
- return {
- name: label,
- owner: owner,
- icon: icon,
- proto: Command,
- target: target,
- ctrArgs: utils.mixin({
- icon:icon,
- flags:0,
- name:label,
- scope: scope,
- group: group,
- variables:variables ? JSON.stringify(variables) : "{}",
- send:send,
- _isGPIO:true,
- _gpioFunc:func,
- description:description
- },ctrAgs)
- };
- }
-
- /**
- * Extend xblox for new blocks/commands.
- * @param scope
- * @param owner
- * @param target
- * @param group
- * @param items
- * @returns {*}
- */
- Module.getNewBlocks=function(scope, owner, target, group, items){
-
- if(!items){
- return null;
- }
-
- items.push({
- name: 'PI-GPIO',
- iconClass: 'fa-code',
- items: [
-
- createBlock('Set GPIO Mode','fa-cogs',null,
- { 'GPIO': '_gpio','GPIO_MODE': '_mode'},
- "setMode {{GPIO}} {{GPIO_MODE}}","setMode",
- "Sets the GPIO mode",
- scope,owner,target,group),
-
- createBlock('Digital Write','fa-send',null,
- { 'GPIO': '_gpio','GPIO_VALUE': '_value'},
- "digitalWrite {{GPIO}} {{GPIO_VALUE}}","digitalWrite",
- "Sets the GPIO level to 0 or 1. If PWM or servo pulses are active on the GPIO they are switched off.",
- scope,owner,target,group),
-
- createBlock('Digital Read','fa-send',null,
- { 'GPIO': '_gpio'},
- "digitalRead {{GPIO}}","digitalRead",
- "Returns the GPIO level",
- scope,owner,target,group),
-
- createBlock('PWM Write','fa-send',null,
- { 'GPIO': '_gpio','DUTY_CYCLE': '_value'},
- "pwmWrite {{GPIO}} {{DUTY_CYCLE}}","pwmWrite",
- "Starts PWM on the GPIO. Uses DMA to control and schedule the pulse lengths and duty cycles. pwmRange can be used to change the default range of 255.Parameter Duty Cycle : an unsigned integer >= 0 (off) and <= range (fully on). range defaults to 255.",
- scope,owner,target,group),
-
- createBlock('PWM Hardware Write','fa-send',null,
- { 'GPIO': '_gpio','DUTY_CYCLE': '_value', 'FREQUENCY': '_frequency'},
- "hardwarePwmWrite {{GPIO}} {{FREQUENCY}} {{DUTY_CYCLE}}","hardwarePwmWrite",
- "Starts hardware PWM on the GPIO at the specified frequency and dutyCycle. " +
- "Frequencies above 30MHz are unlikely to work. Returns this. " +
- "The actual number of steps between off and fully on is the integral part of 250 million divided by frequency. " +
- "The actual frequency set is 250 million / steps. There will only be a million steps for a frequency of 250. Lower frequencies will have more steps and higher frequencies will have fewer steps. duytCycle is automatically scaled to take this into account. All models of the Raspberry Pi support hardware PWM on GPIO18.",
- scope,owner,target,group),
-
- createBlock('Get PWM Duty Cycle','fa-send',null,
- { 'GPIO': '_gpio'},
- "getPwmDutyCycle {{GPIO}}","getPwmDutyCycle",
- "Returns the PWM duty cycle setting on the GPIO.",
- scope,owner,target,group),
-
- createBlock('PWM Range','fa-send',null,
- { 'GPIO': '_gpio','RANGE': '_range'},
- "pwmRange {{GPIO}} {{RANGE}}","pwmRange",
- "Selects the duty cycle range to be used for the GPIO. " +
- "Subsequent calls to pwmWrite will use a duty cycle between 0 (off) and range (fully on). If PWM is currently active on the GPIO its duty cycle will be scaled to reflect the new range." +
- "
Parameter Range : an unsigned integer in the range 25 through 40000",
- scope,owner,target,group),
-
- createBlock('Get PWM Range','fa-send',null,
- { 'GPIO': '_gpio'},
- "getPwmRange {{GPIO}}","getPwmRange",
- "Returns the duty cycle range used for the GPIO. If hardware PWM is active on the GPIO the reported range will be 1000000.",
- scope,owner,target,group),
-
- createBlock('Get PWM Real Range','fa-send',null,
- { 'GPIO': '_gpio'},
- "getPwmRealRange {{GPIO}}","getPwmRealRange",
- "Returns the real range used for the GPIO. If hardware PWM is active on the GPIO the reported real range will be approximately 250M divided by the set PWM frequency.",
- scope,owner,target,group),
-
- createBlock('Set PMW Frequency','fa-send',null,
- { 'GPIO': '_gpio','FREQUENCY': '_frequency'},
- "pwmFrequency {{GPIO}} {{FREQUENCY}}","pwmFrequency",
- "Sets the frequency in hertz to be used for the GPIO." +
- "Each GPIO can be independently set to one of 18 different PWM frequencies."+
- "The selectable frequencies depend upon the sample rate which may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The sample rate can be set with the configureClock function. " +
- "If PWM is currently active on the GPIO it will be switched off and then back on at the new frequency.",
- scope,owner,target,group),
-
- createBlock('Get PMW Frequency','fa-send',null,
- { 'GPIO': '_gpio'},
- "getPwmFrequency {{GPIO}}","getPwmFrequency",
- "Returns the frequency (in hertz) used for the GPIO. The default frequency is 800Hz." +
- "If hardware PWM is active on the GPIO the reported frequency will be that set by hardwarePwmWrite.",
- scope,owner,target,group),
-
- createBlock('Servo Write','fa-send',null,
- { 'GPIO': '_gpio','PULSEW': '_pulse'},
- "servoWrite {{GPIO}} {{PULSEW}}","servoWrite",
- "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)." +
- "
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- scope,owner,target,group),
-
- createBlock('Get Servo Pulse Width','fa-send',null,
- { 'GPIO': '_gpio'},
- "getServoPulseWidth {{GPIO}}","getServoPulseWidth",
- "Returns the servo pulse width setting on the GPIO.",
- scope,owner,target,group),
-
- createBlock('Enable Interrupt','fa-send',null,
- { 'GPIO': '_gpio','EDGE': '_edge','TIME_OUT': '_timeout'},
- "enableInterrupt {{GPIO}} {{EDGE}} {{TIMEOUT}}","enableInterrupt",
- "Enables interrupts for the GPIO. Interrupts can have an optional timeout. The level argument passed to the interrupt event listener will be TIMEOUT (2) if the optional interrupt timeout expires.",
- scope,owner,target,group),
-
- createBlock('DisableInterrupt','fa-send',null,
- { 'GPIO': '_gpio'},
- "disableInterrupt {{GPIO}}","disableInterrupt",
- "Enables interrupts for the GPIO. Interrupts can have an optional timeout. The level argument passed to the interrupt event listener will be TIMEOUT (2) if the optional interrupt timeout expires.",
- scope,owner,target,group),
-
- createBlock('Enable Alert','fa-send',null,
- { 'GPIO': '_gpio'},
- "enableAlert {{GPIO}}","enableAlert",
- "Enables alerts for the GPIO. An alert event will be emitted every time the GPIO changes state." +
- "Add a block of type finish to retrieve the even values.",
- scope,owner,target,group),
-
- createBlock('Disable Alert','fa-send',null,
- { 'GPIO': '_gpio'},
- "disableAlert {{GPIO}}","disableAlert",
- "Disables alerts for the GPIO.",
- scope,owner,target,group),
-
- createBlock('Set Pull Type ','fa-send',null,
- { 'GPIO': '_gpio','PUD': '_pud'},
- "pullUpDown {{GPIO}} {{PUD}}","pullUpDown",
- "Sets or clears the resistor pull type for the GPIO.",
- scope,owner,target,group),
-
- createBlock('Trigger','fa-send',null,
- { 'GPIO': '_gpio','PULSE': '_pulse','LEVEL': '_level'},
- "trigger {{GPIO}} {{PULSE}} {{PULSE}}","trigger",
- "Sends a trigger pulse to the GPIO. The GPIO is set to level for pulseLen microseconds and then reset to not level.",
- scope,owner,target,group)
-
-
- ]
- });
- return items;
- };
- /**
- * Override interface for "toText"
- * @param command
- * @param text
- * @returns {*}
- */
- Module.toText = function (command, text) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
-
- for(var variable in commandVariables){
- variables[variable]=command[commandVariables[variable]] || " ";
- }
- text = utils.replace(text,null,variables,{
- begin:'{{',
- end:'}}'
- });
- return text;
- }
-
- };
- Module.resolveAfter = function (command,inputString) {
- if(!command._isGPIO){
- return;
- }
- if(command.variables){
- var commandVariables = utils.fromJson(command.variables);
- var variables = {};
- for(var variable in commandVariables){
- variables[variable]=command._resolve(command[commandVariables[variable]],{
- flags:0x00000800
- },false);
- }
- inputString = utils.replace(inputString,null,variables,{
- begin:'{{',
- end:'}}'
- });
- }
- return inputString;
- };
- }
- patchModule();
- return Module;
-});
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.meta.json b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.meta.json
deleted file mode 100644
index 644907cc6..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.meta.json
+++ /dev/null
@@ -1,170 +0,0 @@
-{
- "inputs": [
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_NAME",
- "name": "CF_DRIVER_NAME",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Display Name",
- "type": 13,
- "uid": "-1",
- "value": "PI-GPIO",
- "visible": true,
- "changed": true,
- "_active": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_ID",
- "name": "CF_DRIVER_ID",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Id",
- "type": 13,
- "uid": "-1",
- "value": "91e6a9e2-d2cd-4258-c647-3e708ce4a749",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Visual",
- "id": "CF_DRIVER_ICON",
- "name": "CF_DRIVER_ICON",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Icon",
- "type": 18,
- "uid": "-1",
- "value": "./project1/318i.jpg",
- "visible": false
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "General",
- "id": "CF_DRIVER_CLASS",
- "name": "CF_DRIVER_CLASS",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Driver Class",
- "type": 4,
- "uid": "-1",
- "value": "./Raspberry/PI-GPIO.js",
- "visible": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Settings",
- "id": "CommandSettings",
- "name": "CF_DRIVER_COMMANDS",
- "order": 1,
- "params": "{\"constants\":{\"start\":\"\",\"end\":\"\"},\"send\":{\"mode\":false,\"interval\":\"300\",\"timeout\":\"500\",\"onReply\":\"\"}}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Commands",
- "type": "CommandSettings",
- "uid": "-1",
- "value": "[]",
- "visible": true,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Variables",
- "id": "VariableSettings",
- "name": "CF_DRIVER_VARIABLES",
- "order": 1,
- "params": null,
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Variables",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- },
- {
- "chainType": 0,
- "class": "cmx.types.ConfigurableInformation",
- "dataRef": "",
- "dataSource": "",
- "description": null,
- "enabled": true,
- "enumType": "-1",
- "flags": -1,
- "group": "Responses",
- "id": "ResponseSettings",
- "name": "CF_DRIVER_RESPONSES",
- "order": 1,
- "params": "{\"start\":false,\"startString\":\"\",\"cTypeByte\":false,\"cTypePacket\":false,\"cTypeDelimiter\":true,\"cTypeCount\":false,\"delimiter\":\"\\\\r\",\"count\":\"\",\"wDelimiter\":\"\\\\r\",\"wCount\":\"\"}",
- "parentId": "myeventsapp108",
- "platform": null,
- "storeDestination": "metaDataStore",
- "title": "Responses",
- "type": 13,
- "uid": "-1",
- "value": "[]",
- "visible": false,
- "view": true
- }
- ]
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.xblox b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.xblox
deleted file mode 100644
index 940aa0c3e..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PI-GPIO.xblox
+++ /dev/null
@@ -1,581 +0,0 @@
-{
- "blocks": [
- {
- "_containsChildrenIds": [],
- "icon": "fa-cogs",
- "flags": 0,
- "name": "Set GPIO Mode",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_MODE\":\"_mode\"}",
- "send": "setMode {{GPIO}} {{GPIO_MODE}}",
- "_isGPIO": true,
- "_gpioFunc": "setMode",
- "description": "Sets the GPIO mode",
- "id": "ebed6e03-999b-54d5-eb88-4940dbe81533",
- "declaredClass": "xcf.model.Command",
- "startup": true,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "17",
- "_mode": "1"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Digital Write",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_VALUE\":\"_value\"}",
- "send": "digitalWrite {{GPIO}} {{GPIO_VALUE}}",
- "_isGPIO": true,
- "_gpioFunc": "digitalWrite",
- "description": "Sets the GPIO level to 0 or 1. If PWM or servo pulses are active on the GPIO they are switched off.",
- "id": "5d6c1752-b25c-8797-fe5d-e1f566bde2af",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_value": "1"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Digital Write",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_VALUE\":\"_value\"}",
- "send": "digitalWrite {{GPIO}} {{GPIO_VALUE}}",
- "_isGPIO": true,
- "_gpioFunc": "digitalWrite",
- "description": "Sets the GPIO level to 0 or 1. If PWM or servo pulses are active on the GPIO they are switched off.",
- "id": "03439381-7f68-03cb-f617-70e03b149b97",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_value": "0"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "icon": "fa-send",
- "flags": 32768,
- "name": "Digital Read",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\"}",
- "send": "digitalRead {{GPIO}}",
- "_isGPIO": true,
- "_gpioFunc": "digitalRead",
- "description": "Returns the GPIO level",
- "id": "c57624ed-8818-fcb6-cb2a-1356efcefc4a",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "items": [
- "0eca6275-b17b-c279-0316-477f3485925f"
- ]
- },
- {
- "_containsChildrenIds": [],
- "parentId": "c57624ed-8818-fcb6-cb2a-1356efcefc4a",
- "id": "0eca6275-b17b-c279-0316-477f3485925f",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "this.setVariable(\"GPIO - \"+arguments[0].gpio,arguments[0].value);",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 8,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [],
- "name": "GPIO - 18",
- "group": "basicVariables",
- "id": "92cae109-c27a-0d8a-9aac-2eb3a1602fb4",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": 0,
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "basic",
- "id": "09ef16ec-e764-906f-3ceb-cdbd90b2e110",
- "items": [
- "5fe48c36-18ce-6309-270a-a9a04bd64f92"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "send": "",
- "name": "Blink",
- "interval": 0,
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "initial": "1",
- "comparator": "<=",
- "final": "5",
- "modifier": "+1",
- "counterName": "value",
- "parentId": "09ef16ec-e764-906f-3ceb-cdbd90b2e110",
- "id": "5fe48c36-18ce-6309-270a-a9a04bd64f92",
- "items": [
- "4e05a2c6-653f-e75f-dcf1-e6095275d854",
- "f41c70d6-5d18-6c17-3e3d-f9ec34594ee3"
- ],
- "declaredClass": "xblox.model.loops.ForBlock",
- "name": "For",
- "icon": "",
- "ignoreErrors": false,
- "_currentForIndex": 6,
- "_forState": false,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Digital Write",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_VALUE\":\"_value\"}",
- "send": "digitalWrite {{GPIO}} {{GPIO_VALUE}}",
- "_isGPIO": true,
- "_gpioFunc": "digitalWrite",
- "description": "Sets the GPIO level to 0 or 1. If PWM or servo pulses are active on the GPIO they are switched off.",
- "id": "4e05a2c6-653f-e75f-dcf1-e6095275d854",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_value": "1",
- "parentId": "5fe48c36-18ce-6309-270a-a9a04bd64f92"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Digital Write",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_VALUE\":\"_value\"}",
- "send": "digitalWrite {{GPIO}} {{GPIO_VALUE}}",
- "_isGPIO": true,
- "_gpioFunc": "digitalWrite",
- "description": "Sets the GPIO level to 0 or 1. If PWM or servo pulses are active on the GPIO they are switched off.",
- "id": "f41c70d6-5d18-6c17-3e3d-f9ec34594ee3",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_value": "0",
- "parentId": "5fe48c36-18ce-6309-270a-a9a04bd64f92"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "icon": "fa-send",
- "flags": 0,
- "name": "Get PWM Duty Cycle",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\"}",
- "send": "getPwmDutyCycle {{GPIO}}",
- "_isGPIO": true,
- "_gpioFunc": "pwmWrite",
- "description": "Returns the PWM duty cycle setting on the GPIO.",
- "id": "4afe9101-2c66-cde6-a8bc-ed7c8b2a0296",
- "items": [
- "5b4cc5ad-74e1-1676-6119-2879c1acc852"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_value": "1"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "4afe9101-2c66-cde6-a8bc-ed7c8b2a0296",
- "id": "5b4cc5ad-74e1-1676-6119-2879c1acc852",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "console.log('getPwmDutyCycle',arguments);",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 8,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "icon": "fa-send",
- "flags": 0,
- "name": "Get PWM Range",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\",\"RANGE\":\"_range\"}",
- "send": "getPwmRange {{GPIO}}",
- "_isGPIO": true,
- "_gpioFunc": "getPwmRange",
- "description": "Returns the duty cycle range used for the GPIO. If hardware PWM is active on the GPIO the reported range will be 1000000.",
- "id": "ad989d6b-f8be-9da0-fe51-3f368549eaf1",
- "items": [
- "7c6fa262-7f74-1e76-4614-baa4ed4eed81"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": 0,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "17"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "ad989d6b-f8be-9da0-fe51-3f368549eaf1",
- "id": "7c6fa262-7f74-1e76-4614-baa4ed4eed81",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "console.log('getPwmRange',arguments);",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 8,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Servo Write",
- "variables": "{\"GPIO\":\"_gpio\",\"PULSEW\":\"_pulse\"}",
- "send": "servoWrite {{GPIO}} {{PULSEW}}",
- "_isGPIO": true,
- "_gpioFunc": "servoWrite",
- "description": "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise).
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- "id": "a0ce241e-7bab-284e-34cc-11256518c1c7",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_pulse": "1300",
- "group": "basic"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "icon": "fa-send",
- "flags": 32768,
- "name": "Enable Alert",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\"}",
- "send": "enableAlert {{GPIO}}",
- "_isGPIO": true,
- "_gpioFunc": "enableAlert",
- "description": "Enables alerts for the GPIO. An alert event will be emitted every time the GPIO changes state.Add a block of type finish to retrieve the even values.",
- "id": "707af144-4dea-4d2d-62a5-b3ad9bb8cc88",
- "items": [
- "e47d30fa-b474-323d-bd20-65f876bf1ee6"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18"
- },
- {
- "_containsChildrenIds": [],
- "parentId": "707af144-4dea-4d2d-62a5-b3ad9bb8cc88",
- "id": "e47d30fa-b474-323d-bd20-65f876bf1ee6",
- "declaredClass": "xblox.model.code.RunScript",
- "name": "Run Script",
- "method": "console.log('alert');",
- "args": "",
- "deferred": false,
- "icon": "fa-code",
- "outlet": 8,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "description": "No Description"
- },
- {
- "_containsChildrenIds": [
- "items"
- ],
- "group": "basic",
- "id": "23a14eb0-dae0-1c7b-4c0d-fea0970f9e8c",
- "items": [
- "74f9dadb-0d8c-20b8-8f23-4f38a01dea50",
- "5dbf7c20-5eaf-e393-4034-b0afdd6db9b1",
- "14810b92-5497-771f-00e0-bab445c612ab",
- "5738cbd3-6c97-39e1-74e7-e0ce08864a64"
- ],
- "declaredClass": "xcf.model.Command",
- "startup": true,
- "send": "",
- "name": "Servo-Test",
- "interval": "0",
- "flags": 2048,
- "icon": "fa-exclamation",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-cogs",
- "flags": 0,
- "name": "Set GPIO Mode",
- "variables": "{\"GPIO\":\"_gpio\",\"GPIO_MODE\":\"_mode\"}",
- "send": "setMode {{GPIO}} {{GPIO_MODE}}",
- "_isGPIO": true,
- "_gpioFunc": "setMode",
- "description": "Sets the GPIO mode",
- "parentId": "23a14eb0-dae0-1c7b-4c0d-fea0970f9e8c",
- "id": "74f9dadb-0d8c-20b8-8f23-4f38a01dea50",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_mode": "1"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 34816,
- "name": "Servo Write",
- "variables": "{\"GPIO\":\"_gpio\",\"PULSEW\":\"_pulse\"}",
- "send": "return \"servoWrite 18 \" + this.getVariable(\"Next Servo Pulse\");",
- "_isGPIO": true,
- "_gpioFunc": "servoWrite",
- "description": "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise).
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- "parentId": "23a14eb0-dae0-1c7b-4c0d-fea0970f9e8c",
- "id": "5dbf7c20-5eaf-e393-4034-b0afdd6db9b1",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": false,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_pulse": "1200"
- },
- {
- "_containsChildrenIds": [],
- "name": "Next Servo Pulse",
- "group": "basicVariables",
- "id": "85365eb1-27f4-9f35-36f3-f94709996f0f",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": "2000",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "icon": "fa-play"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Servo Write",
- "variables": "{\"GPIO\":\"_gpio\",\"PULSEW\":\"_pulse\"}",
- "send": "servoWrite {{GPIO}} {{PULSEW}}",
- "_isGPIO": true,
- "_gpioFunc": "servoWrite",
- "description": "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise).
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- "parentId": "23a14eb0-dae0-1c7b-4c0d-fea0970f9e8c",
- "id": "14810b92-5497-771f-00e0-bab445c612ab",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_pulse": "1300"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Servo Write",
- "variables": "{\"GPIO\":\"_gpio\",\"PULSEW\":\"_pulse\"}",
- "send": "servoWrite {{GPIO}} {{PULSEW}}",
- "_isGPIO": true,
- "_gpioFunc": "servoWrite",
- "description": "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise).
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- "id": "5738cbd3-6c97-39e1-74e7-e0ce08864a64",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_pulse": "[Next Servo Pulse]",
- "parentId": "23a14eb0-dae0-1c7b-4c0d-fea0970f9e8c"
- },
- {
- "_containsChildrenIds": [],
- "icon": "fa-send",
- "flags": 0,
- "name": "Update Servo",
- "group": "basic",
- "variables": "{\"GPIO\":\"_gpio\",\"PULSEW\":\"_pulse\"}",
- "send": "servoWrite {{GPIO}} {{PULSEW}}",
- "_isGPIO": true,
- "_gpioFunc": "servoWrite",
- "description": "Starts servo pulses at 50Hz on the GPIO, 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise).
pulseWidth - pulse width in microseconds, an unsigned integer, 0 or a number in the range 500 through 2500",
- "id": "8331247f-9606-7423-f8a4-77d91c9545b9",
- "declaredClass": "xcf.model.Command",
- "startup": false,
- "interval": "0",
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "order": 0,
- "type": "added",
- "_gpio": "18",
- "_pulse": "[SERVO_SLIDER]"
- },
- {
- "_containsChildrenIds": [],
- "name": "SERVO_SLIDER",
- "group": "basicVariables",
- "id": "5868ef1a-cfa4-cb94-79f4-38a570458d14",
- "declaredClass": "xcf.model.Variable",
- "gui": "off",
- "cmd": "off",
- "save": false,
- "target": "None",
- "value": "1589",
- "register": true,
- "readOnly": false,
- "isVariable": true,
- "flags": 4096,
- "outlet": 0,
- "enabled": true,
- "shareTitle": "",
- "description": "No Description",
- "order": 0,
- "type": "added",
- "icon": "fa-play"
- }
- ],
- "variables": null
-}
\ No newline at end of file
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/MakeRemote b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/MakeRemote
deleted file mode 100644
index a3a235c39..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/MakeRemote
+++ /dev/null
@@ -1,101 +0,0 @@
-#
-CC = gcc
-SIZE = size
-SHLIB = gcc -shared
-STRIPLIB = strip --strip-unneeded
-
-CFLAGS += -O3 -Wall -pthread
-
-ALL = libpigpiod_if.so libpigpiod_if2.so pigs x_pigpiod_if x_pigpiod_if2
-
-prefix = /usr/local
-exec_prefix = $(prefix)
-bindir = $(exec_prefix)/bin
-includedir = $(prefix)/include
-libdir = $(prefix)/lib
-mandir = $(prefix)/man
-
-all: $(ALL) pigpio.py setup.py
-
-pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h
- $(CC) $(CFLAGS) -fpic -c -o pigpiod_if.o pigpiod_if.c
-
-pigpiod_if2.o: pigpiod_if2.c pigpio.h command.h pigpiod_if2.h
- $(CC) $(CFLAGS) -fpic -c -o pigpiod_if2.o pigpiod_if2.c
-
-command.o: command.c pigpio.h command.h
- $(CC) $(CFLAGS) -fpic -c -o command.o command.c
-
-pigs: command.o pigs.o
- $(CC) $(CFLAGS) -fpic -o pigs pigs.c command.c
-
-x_pigpiod_if: x_pigpiod_if.o $(LIB1)
- $(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL1)
-
-x_pigpiod_if2: x_pigpiod_if2.o $(LIB2)
- $(CC) -o x_pigpiod_if2 x_pigpiod_if2.o $(LL2)
-
-clean:
- rm -f *.o *.i *.s *~ $(ALL)
-
-install: $(LIB1) $(LIB2)
- install -m 0755 -d $(DESTDIR)$(includedir)
- install -m 0644 pigpio.h $(DESTDIR)$(includedir)
- install -m 0644 pigpiod_if.h $(DESTDIR)$(includedir)
- install -m 0644 pigpiod_if2.h $(DESTDIR)$(includedir)
- install -m 0755 -d $(DESTDIR)$(libdir)
- install -m 0644 libpigpiod_if.so $(DESTDIR)$(libdir)
- install -m 0644 libpigpiod_if2.so $(DESTDIR)$(libdir)
- install -m 0755 -d $(DESTDIR)$(bindir)
- install -m 0755 pigs $(DESTDIR)$(bindir)
- python2 setup.py install
- python3 setup.py install
- install -m 0755 -d $(DESTDIR)$(mandir)/man1
- install -m 0644 *.1 $(DESTDIR)$(mandir)/man1
- install -m 0755 -d $(DESTDIR)$(mandir)/man3
- install -m 0644 *.3 $(DESTDIR)$(mandir)/man3
-
-uninstall:
- rm -f $(DESTDIR)$(includedir)/pigpio.h
- rm -f $(DESTDIR)$(includedir)/pigpiod_if.h
- rm -f $(DESTDIR)$(includedir)/pigpiod_if2.h
- rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so
- rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so
- echo removing python2 files
- python2 setup.py install --record /tmp/pigpio >/dev/null
- xargs rm -f < /tmp/pigpio >/dev/null
- echo removing python3 files
- python3 setup.py install --record /tmp/pigpio >/dev/null
- xargs rm -f < /tmp/pigpio >/dev/null
- rm -f $(DESTDIR)$(bindir)/pigs
- rm -f $(DESTDIR)$(mandir)/man1/pig*.1
- rm -f $(DESTDIR)$(mandir)/man3/pig*.3
-
-LL1 = -L. -lpigpiod_if -pthread -lrt
-LL2 = -L. -lpigpiod_if2 -pthread -lrt
-
-LIB1 = libpigpiod_if.so
-OBJ1 = pigpiod_if.o command.o
-
-LIB2 = libpigpiod_if2.so
-OBJ2 = pigpiod_if2.o command.o
-
-$(LIB1): $(OBJ1)
- $(SHLIB) -o $(LIB1) $(OBJ1)
- $(STRIPLIB) $(LIB1)
- $(SIZE) $(LIB1)
-
-$(LIB2): $(OBJ2)
- $(SHLIB) -o $(LIB2) $(OBJ2)
- $(STRIPLIB) $(LIB2)
- $(SIZE) $(LIB2)
-
-# generated using gcc -MM *.c
-
-command.o: command.c pigpio.h command.h
-pigpiod.o: pigpiod.c pigpio.h
-pigpiod_if.o: pigpiod_if.c pigpio.h pigpiod_if.h command.h
-pigpiod_if2.o: pigpiod_if2.c pigpio.h pigpiod_if2.h command.h
-pigs.o: pigs.c pigpio.h command.h
-
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/Makefile b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/Makefile
deleted file mode 100644
index 846daf078..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/Makefile
+++ /dev/null
@@ -1,133 +0,0 @@
-#
-CC = gcc
-AR = ar
-RANLIB = ranlib
-SIZE = size
-SHLIB = gcc -shared
-STRIPLIB = strip --strip-unneeded
-
-CFLAGS += -O3 -Wall -pthread
-
-LIB1 = libpigpio.so
-OBJ1 = pigpio.o command.o
-
-LIB2 = libpigpiod_if.so
-OBJ2 = pigpiod_if.o command.o
-
-LIB3 = libpigpiod_if2.so
-OBJ3 = pigpiod_if2.o command.o
-
-LIB = $(LIB1) $(LIB2) $(LIB3)
-
-ALL = $(LIB) x_pigpio x_pigpiod_if x_pigpiod_if2 pig2vcd pigpiod pigs
-
-LL1 = -L. -lpigpio -pthread -lrt
-
-LL2 = -L. -lpigpiod_if -pthread -lrt
-
-LL3 = -L. -lpigpiod_if2 -pthread -lrt
-
-prefix = /usr/local
-exec_prefix = $(prefix)
-bindir = $(exec_prefix)/bin
-includedir = $(prefix)/include
-libdir = $(prefix)/lib
-mandir = $(prefix)/man
-
-all: $(ALL)
-
-pigpio.o: pigpio.c pigpio.h command.h custom.cext
- $(CC) $(CFLAGS) -fpic -c -o pigpio.o pigpio.c
-
-pigpiod_if.o: pigpiod_if.c pigpio.h command.h pigpiod_if.h
- $(CC) $(CFLAGS) -fpic -c -o pigpiod_if.o pigpiod_if.c
-
-pigpiod_if2.o: pigpiod_if2.c pigpio.h command.h pigpiod_if2.h
- $(CC) $(CFLAGS) -fpic -c -o pigpiod_if2.o pigpiod_if2.c
-
-command.o: command.c pigpio.h command.h
- $(CC) $(CFLAGS) -fpic -c -o command.o command.c
-
-x_pigpio: x_pigpio.o $(LIB1)
- $(CC) -o x_pigpio x_pigpio.o $(LL1)
-
-x_pigpiod_if: x_pigpiod_if.o $(LIB2)
- $(CC) -o x_pigpiod_if x_pigpiod_if.o $(LL2)
-
-x_pigpiod_if2: x_pigpiod_if2.o $(LIB3)
- $(CC) -o x_pigpiod_if2 x_pigpiod_if2.o $(LL3)
-
-pigpiod: pigpiod.o $(LIB1)
- $(CC) -o pigpiod pigpiod.o $(LL1)
-
-pigs: pigs.o command.o
- $(CC) -o pigs pigs.o command.o
-
-pig2vcd: pig2vcd.o
- $(CC) -o pig2vcd pig2vcd.o
-
-clean:
- rm -f *.o *.i *.s *~ $(ALL)
-
-install: $(ALL)
- install -m 0755 -d $(DESTDIR)/opt/pigpio/cgi
- install -m 0755 -d $(DESTDIR)$(includedir)
- install -m 0644 pigpio.h $(DESTDIR)$(includedir)
- install -m 0644 pigpiod_if.h $(DESTDIR)$(includedir)
- install -m 0644 pigpiod_if2.h $(DESTDIR)$(includedir)
- install -m 0755 -d $(DESTDIR)$(libdir)
- install -m 0755 libpigpio.so $(DESTDIR)$(libdir)
- install -m 0755 libpigpiod_if.so $(DESTDIR)$(libdir)
- install -m 0755 libpigpiod_if2.so $(DESTDIR)$(libdir)
- install -m 0755 -d $(DESTDIR)$(bindir)
- install -m 0755 -s pig2vcd $(DESTDIR)$(bindir)
- install -m 0755 -s pigpiod $(DESTDIR)$(bindir)
- install -m 0755 -s pigs $(DESTDIR)$(bindir)
- if which python2; then python2 setup.py install; fi
- if which python3; then python3 setup.py install; fi
- install -m 0755 -d $(DESTDIR)$(mandir)/man1
- install -m 0644 *.1 $(DESTDIR)$(mandir)/man1
- install -m 0755 -d $(DESTDIR)$(mandir)/man3
- install -m 0644 *.3 $(DESTDIR)$(mandir)/man3
- ldconfig
-
-uninstall:
- rm -f $(DESTDIR)$(includedir)/pigpio.h
- rm -f $(DESTDIR)$(includedir)/pigpiod_if.h
- rm -f $(DESTDIR)$(includedir)/pigpiod_if2.h
- rm -f $(DESTDIR)$(libdir)/libpigpio.so
- rm -f $(DESTDIR)$(libdir)/libpigpiod_if.so
- rm -f $(DESTDIR)$(libdir)/libpigpiod_if2.so
- rm -f $(DESTDIR)$(bindir)/pig2vcd
- rm -f $(DESTDIR)$(bindir)/pigpiod
- rm -f $(DESTDIR)$(bindir)/pigs
- if which python2; then python2 setup.py install --record /tmp/pigpio >/dev/null; xargs rm -f < /tmp/pigpio >/dev/null; fi
- if which python3; then python3 setup.py install --record /tmp/pigpio >/dev/null; xargs rm -f < /tmp/pigpio >/dev/null; fi
- rm -f $(DESTDIR)$(mandir)/man1/pig*.1
- rm -f $(DESTDIR)$(mandir)/man3/pig*.3
- ldconfig
-
-$(LIB1): $(OBJ1)
- $(SHLIB) -o $(LIB1) $(OBJ1)
- $(STRIPLIB) $(LIB1)
- $(SIZE) $(LIB1)
-
-$(LIB2): $(OBJ2)
- $(SHLIB) -o $(LIB2) $(OBJ2)
- $(STRIPLIB) $(LIB2)
- $(SIZE) $(LIB2)
-
-$(LIB3): $(OBJ3)
- $(SHLIB) -o $(LIB3) $(OBJ3)
- $(STRIPLIB) $(LIB3)
- $(SIZE) $(LIB3)
-
-# generated using gcc -MM *.c
-
-pig2vcd.o: pig2vcd.c pigpio.h
-pigpiod.o: pigpiod.c pigpio.h
-pigs.o: pigs.c pigpio.h command.h
-x_pigpio.o: x_pigpio.c pigpio.h
-x_pigpiod_if.o: x_pigpiod_if.c pigpiod_if.h pigpio.h
-x_pigpiod_if2.o: x_pigpiod_if2.c pigpiod_if2.h pigpio.h
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/README b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/README
deleted file mode 100644
index 3f3d7669d..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/README
+++ /dev/null
@@ -1,173 +0,0 @@
-NOTE
-
-The initial part of the make, the compilation of pigpio.c,
-takes 100 seconds on early model Pis. Be patient. The overall
-install takes just over 3 minutes.
-
-INSTALL
-
-Extract the archive to a directory.
-
-IN THAT DIRECTORY
-
-Enter the following two commands (in this order)
-
-make
-sudo make install
-
-This will install
-
-o the library (libpigpio.so) in /usr/local/lib
-o the library (libpigpiod_if.so) in /usr/local/lib
-o the library (libpigpiod_if2.so) in /usr/local/lib
-o the header file (pigpio.h) in /usr/local/include
-o the header file (pigpiod_if.h) in /usr/local/include
-o the header file (pigpiod_if2.h) in /usr/local/include
-o the daemon (pigpiod) in /usr/local/bin
-o the socket interface (pigs) in /usr/local/bin
-o the utility pig2vcd in /usr/local/bin
-o man pages in /usr/local/man/man1 and /usr/local/man/man3
-o the Python module pigpio.py for Python 2 and 3
-
-TEST (optional)
-
-*** WARNING ************************************************
-* *
-* All the tests make extensive use of gpio 4 (pin P1/J8-7).*
-* Ensure that either nothing or just a LED is connected to *
-* gpio 4 before running any of the tests. *
-* *
-* Some tests are statistical in nature and so may on *
-* occasion fail. Repeated failures on the same test or *
-* many failures in a group of tests indicate a problem. *
-************************************************************
-
-To test the library do
-
-sudo ./x_pigpio
-
-To test the pigpio daemon do
-
-sudo pigpiod
-
-./x_pigpiod_if # test the C I/F to the pigpio daemon
-./x_pigpiod_if2 # test the C I/F to the pigpio daemon
-./x_pigpio.py # test the Python I/F to the pigpio daemon
-./x_pigs # test the socket I/F to the pigpio daemon
-./x_pipe # test the pipe I/F to the pigpio daemon
-
-EXAMPLE CODE
-
-x_pigpio.c, pig2vcd.c, and pigpiod.c show examples of interfacing
-with the pigpio library.
-
-pigs.c, pigpio.py, x_pigpiod_if, x_pigpiod_if2.c, x_pigpio.py,
-x_pigs, and x_pipe show examples of interfacing with the pigpio
-daemon. x_pipe uses the pipe interface, the others use the
-socket interface.
-
-DAEMON
-
-To launch the daemon do
-
-sudo pigpiod (pigpiod -? for options)
-
-Once the daemon is launched the socket and pipe interfaces will be
-available.
-
-When the library starts it locks
-
-/var/run/pigpio.pid
-
-The file should be automatically deleted when the library terminates.
-
-SOCKET INTERFACE
-
-Use pigs for the socket interface (pigs help for help).
-
-PIPE INTERFACE
-
-The pipe interface accepts commands written to /dev/pigpio.
-
-Results are read from /dev/pigout.
-
-Errors are output on /dev/pigerr.
-
-To test the pipe interface perhaps do
-
-cat /dev/pigout &
-cat /dev/pigerr &
-
-echo "help" >/dev/pigpio
-
-PYTHON MODULE
-
-The Python pigpio module is installed to the default Python location
-for Python 2 and Python 3.
-
-You can install it for additional Python versions by
-
-pythonx.y setup.py install
-
-where x.y is the Python version.
-
-STOP DAEMON
-
-To stop the pigpiod daemon
-
-sudo killall pigpiod
-
-RUNNING ON NON Pi's
-
-You can access the pigpiod daemon running on the Pi from any machine which
-is connected to it over the network. This access is via the socket interface.
-
-In particular this allows you to use the following on non-Pi's.
-
-o pigs
-o the pigpio Python module
-o the C socket I/F using libpigpiod_if (header file pigpiod_if.h)
-o the C socket I/F using libpigpiod_if2 (header file pigpiod_if2.h)
-
-On a Linux machine
-
-make -f MakeRemote clean
-make -f MakeRemote
-make -f MakeRemote install
-
-This will install
-
-o the library (libpigpiod_if.so) in /usr/local/lib
-o the library (libpigpiod_if2.so) in /usr/local/lib
-o the header file (pigpio.h) in /usr/local/include
-o the header file (pigpiod_if.h) in /usr/local/include
-o the header file (pigpiod_if2.h) in /usr/local/include
-o the socket interface (pigs) in /usr/local/bin
-o man pages in /usr/local/man/man1 and /usr/local/man/man3
-o the Python module pigpio.py
-
-On Windows machines (and possibly Macs)
-
-The Python module should install with
-
-python setup.py install
-
-pigs, pigpiod_if, and pigpiod_if2 will need minor mods to
-reflect the Windows/Mac socket interface.
-
-DOCUMENTATION
-
-The most up to date should be http://abyz.co.uk/rpi/pigpio/
-
-On the Pi try
-
-man pigs
-man pigpiod
-man pig2vcd
-
-man pigpio
-man pigpiod_if
-man pigpiod_if2
-
-pydoc pigpio
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/UNLICENCE b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/UNLICENCE
deleted file mode 100644
index 471f09f4c..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/UNLICENCE
+++ /dev/null
@@ -1,25 +0,0 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.c b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.c
deleted file mode 100644
index 2a5d0dc51..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.c
+++ /dev/null
@@ -1,1388 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-/*
-This version is for pigpio version 56+
-*/
-
-#include
-#include
-#include
-#include
-#include
-
-#include "pigpio.h"
-#include "command.h"
-
-cmdInfo_t cmdInfo[]=
-{
- /* num str vfyt retv */
-
- {PI_CMD_BC1, "BC1", 111, 1}, // gpioWrite_Bits_0_31_Clear
- {PI_CMD_BC2, "BC2", 111, 1}, // gpioWrite_Bits_32_53_Clear
-
- {PI_CMD_BI2CC, "BI2CC", 112, 0}, // bbI2CClose
- {PI_CMD_BI2CO, "BI2CO", 131, 0}, // bbI2COpen
- {PI_CMD_BI2CZ, "BI2CZ", 193, 6}, // bbI2CZip
-
- {PI_CMD_BR1, "BR1", 101, 3}, // gpioRead_Bits_0_31
- {PI_CMD_BR2, "BR2", 101, 3}, // gpioRead_Bits_32_53
-
- {PI_CMD_BS1, "BS1", 111, 1}, // gpioWrite_Bits_0_31_Set
- {PI_CMD_BS2, "BS2", 111, 1}, // gpioWrite_Bits_32_53_Set
-
- {PI_CMD_BSPIC, "BSPIC", 112, 0}, // bbSPIClose
- {PI_CMD_BSPIO, "BSPIO", 134, 0}, // bbSPIOpen
- {PI_CMD_BSPIX, "BSPIX", 193, 6}, // bbSPIXfer
-
- {PI_CMD_CF1, "CF1", 195, 2}, // gpioCustom1
- {PI_CMD_CF2, "CF2", 195, 6}, // gpioCustom2
-
- {PI_CMD_CGI, "CGI", 101, 4}, // gpioCfgGetInternals
- {PI_CMD_CSI, "CSI", 111, 1}, // gpioCfgSetInternals
-
- {PI_CMD_FC, "FC", 112, 0}, // fileClose
-
- {PI_CMD_FG, "FG", 121, 0}, // gpioGlitchFilter
-
- {PI_CMD_FL, "FL", 127, 6}, // fileList
-
- {PI_CMD_FN, "FN", 131, 0}, // gpioNoiseFilter
-
- {PI_CMD_FO, "FO", 127, 2}, // fileOpen
- {PI_CMD_FR, "FR", 121, 6}, // fileRead
- {PI_CMD_FS, "FS", 133, 2}, // fileSeek
- {PI_CMD_FW, "FW", 193, 0}, // fileWrite
-
- {PI_CMD_GDC, "GDC", 112, 2}, // gpioGetPWMdutycycle
- {PI_CMD_GPW, "GPW", 112, 2}, // gpioGetServoPulsewidth
-
- {PI_CMD_HELP, "H", 101, 5}, // cmdUsage
- {PI_CMD_HELP, "HELP", 101, 5}, // cmdUsage
-
- {PI_CMD_HC, "HC", 121, 0}, // gpioHardwareClock
- {PI_CMD_HP, "HP", 131, 0}, // gpioHardwarePWM
-
- {PI_CMD_HWVER, "HWVER", 101, 4}, // gpioHardwareRevision
-
- {PI_CMD_I2CC, "I2CC", 112, 0}, // i2cClose
- {PI_CMD_I2CO, "I2CO", 131, 2}, // i2cOpen
-
- {PI_CMD_I2CPC, "I2CPC", 131, 2}, // i2cProcessCall
- {PI_CMD_I2CPK, "I2CPK", 194, 6}, // i2cBlockProcessCall
-
- {PI_CMD_I2CRB, "I2CRB", 121, 2}, // i2cReadByteData
- {PI_CMD_I2CRD, "I2CRD", 121, 6}, // i2cReadDevice
- {PI_CMD_I2CRI, "I2CRI", 131, 6}, // i2cReadI2CBlockData
- {PI_CMD_I2CRK, "I2CRK", 121, 6}, // i2cReadBlockData
- {PI_CMD_I2CRS, "I2CRS", 112, 2}, // i2cReadByte
- {PI_CMD_I2CRW, "I2CRW", 121, 2}, // i2cReadWordData
-
- {PI_CMD_I2CWB, "I2CWB", 131, 0}, // i2cWriteByteData
- {PI_CMD_I2CWD, "I2CWD", 193, 0}, // i2cWriteDevice
- {PI_CMD_I2CWI, "I2CWI", 194, 0}, // i2cWriteI2CBlockData
- {PI_CMD_I2CWK, "I2CWK", 194, 0}, // i2cWriteBlockData
- {PI_CMD_I2CWQ, "I2CWQ", 121, 0}, // i2cWriteQuick
- {PI_CMD_I2CWS, "I2CWS", 121, 0}, // i2cWriteByte
- {PI_CMD_I2CWW, "I2CWW", 131, 0}, // i2cWriteWordData
-
- {PI_CMD_I2CZ, "I2CZ", 193, 6}, // i2cZip
-
- {PI_CMD_MICS, "MICS", 112, 0}, // gpioDelay
- {PI_CMD_MILS, "MILS", 112, 0}, // gpioDelay
-
- {PI_CMD_MODEG, "MG" , 112, 2}, // gpioGetMode
- {PI_CMD_MODEG, "MODEG", 112, 2}, // gpioGetMode
-
- {PI_CMD_MODES, "M", 125, 0}, // gpioSetMode
- {PI_CMD_MODES, "MODES", 125, 0}, // gpioSetMode
-
- {PI_CMD_NB, "NB", 122, 0}, // gpioNotifyBegin
- {PI_CMD_NC, "NC", 112, 0}, // gpioNotifyClose
- {PI_CMD_NO, "NO", 101, 2}, // gpioNotifyOpen
- {PI_CMD_NP, "NP", 112, 0}, // gpioNotifyPause
-
- {PI_CMD_PADG, "PADG", 112, 2}, // gpioGetPad
- {PI_CMD_PADS, "PADS", 121, 0}, // gpioSetPad
-
- {PI_CMD_PARSE, "PARSE", 115, 0}, // cmdParseScript
-
- {PI_CMD_PFG, "PFG", 112, 2}, // gpioGetPWMfrequency
- {PI_CMD_PFS, "PFS", 121, 2}, // gpioSetPWMfrequency
-
- {PI_CMD_PIGPV, "PIGPV", 101, 4}, // gpioVersion
-
- {PI_CMD_PRG, "PRG", 112, 2}, // gpioGetPWMrange
-
- {PI_CMD_PROC, "PROC", 115, 2}, // gpioStoreScript
- {PI_CMD_PROCD, "PROCD", 112, 0}, // gpioDeleteScript
- {PI_CMD_PROCP, "PROCP", 112, 7}, // gpioScriptStatus
- {PI_CMD_PROCR, "PROCR", 191, 0}, // gpioRunScript
- {PI_CMD_PROCS, "PROCS", 112, 0}, // gpioStopScript
-
- {PI_CMD_PRRG, "PRRG", 112, 2}, // gpioGetPWMrealRange
- {PI_CMD_PRS, "PRS", 121, 2}, // gpioSetPWMrange
-
- {PI_CMD_PUD, "PUD", 126, 0}, // gpioSetPullUpDown
-
- {PI_CMD_PWM, "P", 121, 0}, // gpioPWM
- {PI_CMD_PWM, "PWM", 121, 0}, // gpioPWM
-
- {PI_CMD_READ, "R", 112, 2}, // gpioRead
- {PI_CMD_READ, "READ", 112, 2}, // gpioRead
-
- {PI_CMD_SERRB, "SERRB", 112, 2}, // serReadByte
- {PI_CMD_SERWB, "SERWB", 121, 0}, // serWriteByte
- {PI_CMD_SERC, "SERC", 112, 0}, // serClose
- {PI_CMD_SERDA, "SERDA", 112, 2}, // serDataAvailable
- {PI_CMD_SERO, "SERO", 132, 2}, // serOpen
- {PI_CMD_SERR, "SERR", 121, 6}, // serRead
- {PI_CMD_SERW, "SERW", 193, 0}, // serWrite
-
- {PI_CMD_SERVO, "S", 121, 0}, // gpioServo
- {PI_CMD_SERVO, "SERVO", 121, 0}, // gpioServo
-
- {PI_CMD_SHELL, "SHELL", 128, 2}, // shell
-
- {PI_CMD_SLR, "SLR", 121, 6}, // gpioSerialRead
- {PI_CMD_SLRC, "SLRC", 112, 0}, // gpioSerialReadClose
- {PI_CMD_SLRO, "SLRO", 131, 0}, // gpioSerialReadOpen
- {PI_CMD_SLRI, "SLRI", 121, 0}, // gpioSerialReadInvert
-
- {PI_CMD_SPIC, "SPIC", 112, 0}, // spiClose
- {PI_CMD_SPIO, "SPIO", 131, 2}, // spiOpen
- {PI_CMD_SPIR, "SPIR", 121, 6}, // spiRead
- {PI_CMD_SPIW, "SPIW", 193, 0}, // spiWrite
- {PI_CMD_SPIX, "SPIX", 193, 6}, // spiXfer
-
- {PI_CMD_TICK, "T", 101, 4}, // gpioTick
- {PI_CMD_TICK, "TICK", 101, 4}, // gpioTick
-
- {PI_CMD_TRIG, "TRIG", 131, 0}, // gpioTrigger
-
- {PI_CMD_WDOG, "WDOG", 121, 0}, // gpioSetWatchdog
-
- {PI_CMD_WRITE, "W", 121, 0}, // gpioWrite
- {PI_CMD_WRITE, "WRITE", 121, 0}, // gpioWrite
-
- {PI_CMD_WVAG, "WVAG", 192, 2}, // gpioWaveAddGeneric
- {PI_CMD_WVAS, "WVAS", 196, 2}, // gpioWaveAddSerial
- {PI_CMD_WVTAT, "WVTAT", 101, 2}, // gpioWaveTxAt
- {PI_CMD_WVBSY, "WVBSY", 101, 2}, // gpioWaveTxBusy
- {PI_CMD_WVCHA, "WVCHA", 197, 0}, // gpioWaveChain
- {PI_CMD_WVCLR, "WVCLR", 101, 0}, // gpioWaveClear
- {PI_CMD_WVCRE, "WVCRE", 101, 2}, // gpioWaveCreate
- {PI_CMD_WVDEL, "WVDEL", 112, 0}, // gpioWaveDelete
- {PI_CMD_WVGO, "WVGO" , 101, 2}, // gpioWaveTxStart
- {PI_CMD_WVGOR, "WVGOR", 101, 2}, // gpioWaveTxStart
- {PI_CMD_WVHLT, "WVHLT", 101, 0}, // gpioWaveTxStop
- {PI_CMD_WVNEW, "WVNEW", 101, 0}, // gpioWaveAddNew
- {PI_CMD_WVSC, "WVSC", 112, 2}, // gpioWaveGet*Cbs
- {PI_CMD_WVSM, "WVSM", 112, 2}, // gpioWaveGet*Micros
- {PI_CMD_WVSP, "WVSP", 112, 2}, // gpioWaveGet*Pulses
- {PI_CMD_WVTX, "WVTX", 112, 2}, // gpioWaveTxSend
- {PI_CMD_WVTXM, "WVTXM", 121, 2}, // gpioWaveTxSend
- {PI_CMD_WVTXR, "WVTXR", 112, 2}, // gpioWaveTxSend
-
- {PI_CMD_ADD , "ADD" , 111, 0},
- {PI_CMD_AND , "AND" , 111, 0},
- {PI_CMD_CALL , "CALL" , 114, 0},
- {PI_CMD_CMDR ,"CMDR" , 111, 0},
- {PI_CMD_CMDW , "CMDW" , 111, 0},
- {PI_CMD_CMP , "CMP" , 111, 0},
- {PI_CMD_DCR , "DCR" , 113, 0},
- {PI_CMD_DCRA , "DCRA" , 101, 0},
- {PI_CMD_DIV , "DIV" , 111, 0},
- {PI_CMD_HALT , "HALT" , 101, 0},
- {PI_CMD_INR , "INR" , 113, 0},
- {PI_CMD_INRA , "INRA" , 101, 0},
- {PI_CMD_JM , "JM" , 114, 0},
- {PI_CMD_JMP , "JMP" , 114, 0},
- {PI_CMD_JNZ , "JNZ" , 114, 0},
- {PI_CMD_JP , "JP" , 114, 0},
- {PI_CMD_JZ , "JZ" , 114, 0},
- {PI_CMD_LD , "LD" , 123, 0},
- {PI_CMD_LDA , "LDA" , 111, 0},
- {PI_CMD_LDAB , "LDAB" , 111, 0},
- {PI_CMD_MLT , "MLT" , 111, 0},
- {PI_CMD_MOD , "MOD" , 111, 0},
- {PI_CMD_NOP , "NOP" , 101, 0},
- {PI_CMD_OR , "OR" , 111, 0},
- {PI_CMD_POP , "POP" , 113, 0},
- {PI_CMD_POPA , "POPA" , 101, 0},
- {PI_CMD_PUSH , "PUSH" , 113, 0},
- {PI_CMD_PUSHA, "PUSHA", 101, 0},
- {PI_CMD_RET , "RET" , 101, 0},
- {PI_CMD_RL , "RL" , 123, 0},
- {PI_CMD_RLA , "RLA" , 111, 0},
- {PI_CMD_RR , "RR" , 123, 0},
- {PI_CMD_RRA , "RRA" , 111, 0},
- {PI_CMD_STA , "STA" , 113, 0},
- {PI_CMD_STAB , "STAB" , 111, 0},
- {PI_CMD_SUB , "SUB" , 111, 0},
- {PI_CMD_SYS , "SYS" , 116, 0},
- {PI_CMD_TAG , "TAG" , 114, 0},
- {PI_CMD_WAIT , "WAIT" , 111, 0},
- {PI_CMD_X , "X" , 124, 0},
- {PI_CMD_XA , "XA" , 113, 0},
- {PI_CMD_XOR , "XOR" , 111, 0},
-
-};
-
-
-char * cmdUsage = "\n\
-BC1 bits Clear GPIO in bank 1\n\
-BC2 bits Clear GPIO in bank 2\n\
-BI2CC sda Close bit bang I2C\n\
-BI2CO sda scl baud | Open bit bang I2C\n\
-BI2CZ sda ... I2C bit bang multiple transactions\n\
-\n\
-BSPIC cs Close bit bang SPI\n\
-BSPIO cs miso mosi sclk baud flag | Open bit bang SPI\n\
-BSPIX cs ... SPI bit bang transfer\n\
-\n\
-BR1 Read bank 1 GPIO\n\
-BR2 Read bank 2 GPIO\n\
-BS1 bits Set GPIO in bank 1\n\
-BS2 bits Set GPIO in bank 2\n\
-\n\
-CF1 ... Custom function 1\n\
-CF2 ... Custom function 2\n\
-\n\
-CGI Configuration get internals\n\
-CSI v Configuration set internals\n\
-\n\
-FC h Close file handle\n\
-FG g steady Set glitch filter on GPIO\n\
-FL pat n List files which match pattern\n\
-FN g steady active | Set noise filter on GPIO\n\
-FO file mode Open a file in mode\n\
-FR h n Read bytes from file handle\n\
-FS h n from Seek to file handle position\n\
-FW h ... Write bytes to file handle\n\
-\n\
-GDC g Get PWM dutycycle for GPIO\n\
-GPW g Get servo pulsewidth for GPIO\n\
-\n\
-H/HELP Display command help\n\
-HC g f Set hardware clock frequency\n\
-HP g f dc Set hardware PWM frequency and dutycycle\n\
-HWVER Get hardware version\n\
-\n\
-I2CC h Close I2C handle\n\
-I2CO bus device flags | Open I2C bus and device with flags\n\
-I2CPC h r word SMBus Process Call: exchange register with word\n\
-I2CPK h r ... SMBus Block Process Call: exchange data bytes with register\n\
-I2CRB h r SMBus Read Byte Data: read byte from register\n\
-I2CRD h n I2C Read bytes\n\
-I2CRI h r n SMBus Read I2C Block Data: read bytes from register\n\
-I2CRK h r SMBus Read Block Data: read data from register\n\
-I2CRS h SMBus Read Byte: read byte\n\
-I2CRW h r SMBus Read Word Data: read word from register\n\
-I2CWB h r byte SMBus Write Byte Data: write byte to register\n\
-I2CWD h ... I2C Write data\n\
-I2CWI h r ... SMBus Write I2C Block Data\n\
-I2CWK h r ... SMBus Write Block Data: write data to register\n\
-I2CWQ h b SMBus Write Quick: write bit\n\
-I2CWS h b SMBus Write Byte: write byte\n\
-I2CWW h r word SMBus Write Word Data: write word to register\n\
-I2CZ h ... I2C multiple transactions\n\
-\n\
-M/MODES g mode Set GPIO mode\n\
-MG/MODEG g Get GPIO mode\n\
-MICS n Delay for microseconds\n\
-MILS n Delay for milliseconds\n\
-\n\
-NB h bits Start notification\n\
-NC h Close notification\n\
-NO Request a notification\n\
-NP h Pause notification\n\
-\n\
-P/PWM g v Set GPIO PWM value\n\
-PADG pad Get pad drive strength\n\
-PADS pad v Set pad drive strength\n\
-PARSE text Validate script\n\
-PFG g Get GPIO PWM frequency\n\
-PFS g v Set GPIO PWM frequency\n\
-PIGPV Get pigpio library version\n\
-PRG g Get GPIO PWM range\n\
-PROC text Store script\n\
-PROCD sid Delete script\n\
-PROCP sid Get script status and parameters\n\
-PROCR sid ... Run script\n\
-PROCS sid Stop script\n\
-PRRG g Get GPIO PWM real range\n\
-PRS g v Set GPIO PWM range\n\
-PUD g pud Set GPIO pull up/down\n\
-\n\
-R/READ g Read GPIO level\n\
-\n\
-S/SERVO g v Set GPIO servo pulsewidth\n\
-SERC h Close serial handle\n\
-SERDA h Check for serial data ready to read\n\
-SERO text baud flags | Open serial device at baud with flags\n\
-SERR h n Read bytes from serial handle\n\
-SERRB h Read byte from serial handle\n\
-SERW h ... Write bytes to serial handle\n\
-SERWB h byte Write byte to serial handle\n\
-SHELL name str Execute a shell command\n\
-SLR g v Read bit bang serial data from GPIO\n\
-SLRC g Close GPIO for bit bang serial data\n\
-SLRO g baud bitlen | Open GPIO for bit bang serial data\n\
-SLRI g invert Invert serial logic (1 invert, 0 normal)\n\
-SPIC h SPI close handle\n\
-SPIO channel baud flags | SPI open channel at baud with flags\n\
-SPIR h v SPI read bytes from handle\n\
-SPIW h ... SPI write bytes to handle\n\
-SPIX h ... SPI transfer bytes to handle\n\
-\n\
-T/TICK Get current tick\n\
-TRIG g micros l Trigger level for micros on GPIO\n\
-\n\
-W/WRITE g l Write level to GPIO\n\
-WDOG g millis Set millisecond watchdog on GPIO\n\
-WVAG triplets Wave add generic pulses\n\
-WVAS g baud bitlen stopbits offset ... | Wave add serial data\n\
-WVBSY Check if wave busy\n\
-WVCHA Transmit a chain of waves\n\
-WVCLR Wave clear\n\
-WVCRE Create wave from added pulses\n\
-WVDEL wid Delete waves w and higher\n\
-WVGO Wave transmit (DEPRECATED)\n\
-WVGOR Wave transmit repeatedly (DEPRECATED)\n\
-WVHLT Wave stop\n\
-WVNEW Start a new empty wave\n\
-WVSC 0,1,2 Wave get DMA control block stats\n\
-WVSM 0,1,2 Wave get micros stats\n\
-WVSP 0,1,2 Wave get pulses stats\n\
-WVTAT Returns the current transmitting wave\n\
-WVTX wid Transmit wave as one-shot\n\
-WVTXM wid wmde Transmit wave using mode\n\
-WVTXR wid Transmit wave repeatedly\n\
-\n\
-Numbers may be entered as hex (prefix 0x), octal (prefix 0),\n\
-otherwise they are assumed to be decimal.\n\
-\n\
-Examples\n\
-\n\
-pigs w 4 1 # set GPIO 4 high\n\
-pigs r 5 # read GPIO 5\n\
-pigs t # get current tick\n\
-pigs i2co 1 0x20 0 # get handle to device 0x20 on I2C bus 1\n\
-\n\
-man pigs for full details.\n\
-\n";
-
-typedef struct
-{
- int error;
- char * str;
-} errInfo_t;
-
-static errInfo_t errInfo[]=
-{
- {PI_INIT_FAILED , "pigpio initialisation failed"},
- {PI_BAD_USER_GPIO , "GPIO not 0-31"},
- {PI_BAD_GPIO , "GPIO not 0-53"},
- {PI_BAD_MODE , "mode not 0-7"},
- {PI_BAD_LEVEL , "level not 0-1"},
- {PI_BAD_PUD , "pud not 0-2"},
- {PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"},
- {PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"},
- {PI_BAD_TIMER , "timer not 0-9"},
- {PI_BAD_MS , "ms not 10-60000"},
- {PI_BAD_TIMETYPE , "timetype not 0-1"},
- {PI_BAD_SECONDS , "seconds < 0"},
- {PI_BAD_MICROS , "micros not 0-999999"},
- {PI_TIMER_FAILED , "gpioSetTimerFunc failed"},
- {PI_BAD_WDOG_TIMEOUT , "timeout not 0-60000"},
- {PI_NO_ALERT_FUNC , "DEPRECATED"},
- {PI_BAD_CLK_PERIPH , "clock peripheral not 0-1"},
- {PI_BAD_CLK_SOURCE , "DEPRECATED"},
- {PI_BAD_CLK_MICROS , "clock micros not 1, 2, 4, 5, 8, or 10"},
- {PI_BAD_BUF_MILLIS , "buf millis not 100-10000"},
- {PI_BAD_DUTYRANGE , "dutycycle range not 25-40000"},
- {PI_BAD_SIGNUM , "signum not 0-63"},
- {PI_BAD_PATHNAME , "can't open pathname"},
- {PI_NO_HANDLE , "no handle available"},
- {PI_BAD_HANDLE , "unknown handle"},
- {PI_BAD_IF_FLAGS , "ifFlags > 3"},
- {PI_BAD_CHANNEL , "DMA channel not 0-14"},
- {PI_BAD_SOCKET_PORT , "socket port not 1024-30000"},
- {PI_BAD_FIFO_COMMAND , "unknown fifo command"},
- {PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"},
- {PI_NOT_INITIALISED , "function called before gpioInitialise"},
- {PI_INITIALISED , "function called after gpioInitialise"},
- {PI_BAD_WAVE_MODE , "waveform mode not 0-1"},
- {PI_BAD_CFG_INTERNAL , "bad parameter in gpioCfgInternals call"},
- {PI_BAD_WAVE_BAUD , "baud rate not 50-250K(RX)/50-1M(TX)"},
- {PI_TOO_MANY_PULSES , "waveform has too many pulses"},
- {PI_TOO_MANY_CHARS , "waveform has too many chars"},
- {PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"},
- {PI_BAD_SERIAL_STRUC , "bad (null) serial structure parameter"},
- {PI_BAD_SERIAL_BUF , "bad (null) serial buf parameter"},
- {PI_NOT_PERMITTED , "no permission to update GPIO"},
- {PI_SOME_PERMITTED , "no permission to update one or more GPIO"},
- {PI_BAD_WVSC_COMMND , "bad WVSC subcommand"},
- {PI_BAD_WVSM_COMMND , "bad WVSM subcommand"},
- {PI_BAD_WVSP_COMMND , "bad WVSP subcommand"},
- {PI_BAD_PULSELEN , "trigger pulse length not 1-100"},
- {PI_BAD_SCRIPT , "invalid script"},
- {PI_BAD_SCRIPT_ID , "unknown script id"},
- {PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"},
- {PI_GPIO_IN_USE , "GPIO already in use"},
- {PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"},
- {PI_BAD_PARAM_NUM , "script parameter id not 0-9"},
- {PI_DUP_TAG , "script has duplicate tag"},
- {PI_TOO_MANY_TAGS , "script has too many tags"},
- {PI_BAD_SCRIPT_CMD , "illegal script command"},
- {PI_BAD_VAR_NUM , "script variable id not 0-149"},
- {PI_NO_SCRIPT_ROOM , "no more room for scripts"},
- {PI_NO_MEMORY , "can't allocate temporary memory"},
- {PI_SOCK_READ_FAILED , "socket read failed"},
- {PI_SOCK_WRIT_FAILED , "socket write failed"},
- {PI_TOO_MANY_PARAM , "too many script parameters (> 10)"},
- {PI_SCRIPT_NOT_READY , "script initialising"},
- {PI_BAD_TAG , "script has unresolved tag"},
- {PI_BAD_MICS_DELAY , "bad MICS delay (too large)"},
- {PI_BAD_MILS_DELAY , "bad MILS delay (too large)"},
- {PI_BAD_WAVE_ID , "non existent wave id"},
- {PI_TOO_MANY_CBS , "No more CBs for waveform"},
- {PI_TOO_MANY_OOL , "No more OOL for waveform"},
- {PI_EMPTY_WAVEFORM , "attempt to create an empty waveform"},
- {PI_NO_WAVEFORM_ID , "no more waveform ids"},
- {PI_I2C_OPEN_FAILED , "can't open I2C device"},
- {PI_SER_OPEN_FAILED , "can't open serial device"},
- {PI_SPI_OPEN_FAILED , "can't open SPI device"},
- {PI_BAD_I2C_BUS , "bad I2C bus"},
- {PI_BAD_I2C_ADDR , "bad I2C address"},
- {PI_BAD_SPI_CHANNEL , "bad SPI channel"},
- {PI_BAD_FLAGS , "bad i2c/spi/ser open flags"},
- {PI_BAD_SPI_SPEED , "bad SPI speed"},
- {PI_BAD_SER_DEVICE , "bad serial device name"},
- {PI_BAD_SER_SPEED , "bad serial baud rate"},
- {PI_BAD_PARAM , "bad i2c/spi/ser parameter"},
- {PI_I2C_WRITE_FAILED , "I2C write failed"},
- {PI_I2C_READ_FAILED , "I2C read failed"},
- {PI_BAD_SPI_COUNT , "bad SPI count"},
- {PI_SER_WRITE_FAILED , "ser write failed"},
- {PI_SER_READ_FAILED , "ser read failed"},
- {PI_SER_READ_NO_DATA , "ser read no data available"},
- {PI_UNKNOWN_COMMAND , "unknown command"},
- {PI_SPI_XFER_FAILED , "spi xfer/read/write failed"},
- {PI_BAD_POINTER , "bad (NULL) pointer"},
- {PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"},
- {PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"},
- {PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"},
- {PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"},
- {PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"},
- {PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"},
- {PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"},
- {PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"},
- {PI_BAD_HCLK_PASS , "need password to use hardware clock 1"},
- {PI_HPWM_ILLEGAL , "illegal, PWM in use for main clock"},
- {PI_BAD_DATABITS , "serial data bits not 1-32"},
- {PI_BAD_STOPBITS , "serial (half) stop bits not 2-8"},
- {PI_MSG_TOOBIG , "socket/pipe message too big"},
- {PI_BAD_MALLOC_MODE , "bad memory allocation mode"},
- {PI_TOO_MANY_SEGS , "too many I2C transaction segments"},
- {PI_BAD_I2C_SEG , "an I2C transaction segment failed"},
- {PI_BAD_SMBUS_CMD , "SMBus command not supported by driver"},
- {PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"},
- {PI_BAD_I2C_WLEN , "bad I2C write length"},
- {PI_BAD_I2C_RLEN , "bad I2C read length"},
- {PI_BAD_I2C_CMD , "bad I2C command"},
- {PI_BAD_I2C_BAUD , "bad I2C baud rate, not 50-500k"},
- {PI_CHAIN_LOOP_CNT , "bad chain loop count"},
- {PI_BAD_CHAIN_LOOP , "empty chain loop"},
- {PI_CHAIN_COUNTER , "too many chain counters"},
- {PI_BAD_CHAIN_CMD , "bad chain command"},
- {PI_BAD_CHAIN_DELAY , "bad chain delay micros"},
- {PI_CHAIN_NESTING , "chain counters nested too deeply"},
- {PI_CHAIN_TOO_BIG , "chain is too long"},
- {PI_DEPRECATED , "deprecated function removed"},
- {PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"},
- {PI_BAD_EDGE , "bad ISR edge, not 1, 1, or 2"},
- {PI_BAD_ISR_INIT , "bad ISR initialisation"},
- {PI_BAD_FOREVER , "loop forever must be last chain command"},
- {PI_BAD_FILTER , "bad filter parameter"},
- {PI_BAD_PAD , "bad pad number"},
- {PI_BAD_STRENGTH , "bad pad drive strength"},
- {PI_FIL_OPEN_FAILED , "file open failed"},
- {PI_BAD_FILE_MODE , "bad file mode"},
- {PI_BAD_FILE_FLAG , "bad file flag"},
- {PI_BAD_FILE_READ , "bad file read"},
- {PI_BAD_FILE_WRITE , "bad file write"},
- {PI_FILE_NOT_ROPEN , "file not open for read"},
- {PI_FILE_NOT_WOPEN , "file not open for write"},
- {PI_BAD_FILE_SEEK , "bad file seek"},
- {PI_NO_FILE_MATCH , "no files match pattern"},
- {PI_NO_FILE_ACCESS , "no permission to access file"},
- {PI_FILE_IS_A_DIR , "file is a directory"},
- {PI_BAD_SHELL_STATUS , "bad shell return status"},
- {PI_BAD_SCRIPT_NAME , "bad script name"},
- {PI_BAD_SPI_BAUD , "bad SPI baud rate, not 50-500k"},
- {PI_NOT_SPI_GPIO , "no bit bang SPI in progress on GPIO"},
-
-};
-
-static char * fmtMdeStr="RW540123";
-static char * fmtPudStr="ODU";
-
-static int cmdMatch(char *str)
-{
- int i;
-
- for (i=0; i<(sizeof(cmdInfo)/sizeof(cmdInfo_t)); i++)
- {
- if (strcasecmp(str, cmdInfo[i].name) == 0) return i;
- }
- return CMD_UNKNOWN_CMD;
-}
-
-static int getNum(char *str, uint32_t *val, int8_t *opt)
-{
- int f, n;
- intmax_t v;
-
- *opt = 0;
-
- f = sscanf(str, " %ji %n", &v, &n);
-
- if (f == 1)
- {
- *val = v;
- *opt = CMD_NUMERIC;
- return n;
- }
-
- f = sscanf(str, " v%ji %n", &v, &n);
-
- if (f == 1)
- {
- *val = v;
- if (v < PI_MAX_SCRIPT_VARS) *opt = CMD_VAR;
- else *opt = -CMD_VAR;
- return n;
- }
-
- f = sscanf(str, " p%ji %n", &v, &n);
-
- if (f == 1)
- {
- *val = v;
- if (v < PI_MAX_SCRIPT_PARAMS) *opt = CMD_PAR;
- else *opt = -CMD_PAR;
- return n;
- }
-
- return 0;
-}
-
-static char intCmdStr[32];
-
-char *cmdStr(void)
-{
- return intCmdStr;
-}
-
-int cmdParse(
- char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl)
-{
- int f, valid, idx, val, pp, pars, n, n2;
- char *p8;
- int32_t *p32;
- char c;
- uint32_t tp1=0, tp2=0, tp3=0, tp4=0, tp5=0;
- int8_t to1, to2, to3, to4, to5;
- int eaten;
-
- /* Check that ext is big enough for the largest message. */
- if (ext_len < (4 * CMD_MAX_PARAM)) return CMD_EXT_TOO_SMALL;
-
- bzero(&ctl->opt, sizeof(ctl->opt));
-
- sscanf(buf+ctl->eaten, " %31s %n", intCmdStr, &pp);
-
- ctl->eaten += pp;
-
- p[0] = -1;
-
- idx = cmdMatch(intCmdStr);
-
- if (idx < 0) return idx;
-
- valid = 0;
-
- p[0] = cmdInfo[idx].cmd;
- p[1] = 0;
- p[2] = 0;
- p[3] = 0;
-
- switch (cmdInfo[idx].vt)
- {
- case 101: /* BR1 BR2 CGI H HELP HWVER
- DCRA HALT INRA NO
- PIGPV POPA PUSHA RET T TICK WVBSY WVCLR
- WVCRE WVGO WVGOR WVHLT WVNEW
-
- No parameters, always valid.
- */
- valid = 1;
-
- break;
-
- case 111: /* ADD AND BC1 BC2 BS1 BS2
- CMP CSI DIV LDA LDAB MLT
- MOD OR RLA RRA STAB SUB WAIT XOR
-
- One parameter, any value.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if (ctl->opt[1] > 0) valid = 1;
-
- break;
-
- case 112: /* BI2CC FC GDC GPW I2CC I2CRB
- MG MICS MILS MODEG NC NP PADG PFG PRG
- PROCD PROCP PROCS PRRG R READ SLRC SPIC
- WVDEL WVSC WVSM WVSP WVTX WVTXR BSPIC
-
- One positive parameter.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0)) valid = 1;
-
- break;
-
- case 113: /* DCR INR POP PUSH STA XA
-
- One register parameter.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if ((ctl->opt[1] > 0) && (p[1] < PI_MAX_SCRIPT_VARS)) valid = 1;
-
- break;
-
- case 114: /* CALL JM JMP JNZ JP JZ TAG
-
- One numeric parameter, any value.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- if (ctl->opt[1] == CMD_NUMERIC) valid = 1;
-
- break;
-
- case 115: /* PARSE PROC
-
- One parameter, string (rest of input).
- */
- p[3] = strlen(buf+ctl->eaten);
- memcpy(ext, buf+ctl->eaten, p[3]);
- ctl->eaten += p[3];
- valid = 1;
-
- break;
-
- case 116: /* SYS
-
- One parameter, a string.
- */
- f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
- if ((f >= 0) && n)
- {
- p[3] = n;
- ctl->opt[3] = CMD_NUMERIC;
- memcpy(ext, buf+ctl->eaten, n);
- ctl->eaten += n2;
- valid = 1;
- }
-
- break;
-
- case 121: /* HC FR I2CRD I2CRR I2CRW I2CWB I2CWQ P
- PADS PFS PRS PWM S SERVO SLR SLRI W
- WDOG WRITE WVTXM
-
- Two positive parameters.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (ctl->opt[2] > 0) && ((int)p[2] >= 0)) valid = 1;
-
- break;
-
- case 122: /* NB
-
- Two parameters, first positive, second any value.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (ctl->opt[2] > 0)) valid = 1;
-
- break;
-
- case 123: /* LD RL RR
-
- Two parameters, first register, second any value.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] > 0) &&
- (p[1] < PI_MAX_SCRIPT_VARS) &&
- (ctl->opt[2] > 0)) valid = 1;
-
- break;
-
- case 124: /* X
-
- Two register parameters.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] > 0) && (p[1] < PI_MAX_SCRIPT_VARS) &&
- (ctl->opt[2] > 0) && (p[2] < PI_MAX_SCRIPT_VARS)) valid = 1;
-
- break;
-
- case 125: /* M MODES
-
- Two parameters, first positive, second in 'RW540123'.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- f = sscanf(buf+ctl->eaten, " %c %n", &c, &n);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && (f >= 1))
- {
- ctl->eaten += n;
- val = toupper(c);
- p8 = strchr(fmtMdeStr, val);
-
- if (p8 != NULL)
- {
- val = p8 - fmtMdeStr;
- p[2] = val;
- valid = 1;
- }
- }
-
- break;
-
- case 126: /* PUD
-
- Two parameters, first positive, second in 'ODU'.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- f = sscanf(buf+ctl->eaten, " %c %n", &c, &n);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) && (f >= 1))
- {
- ctl->eaten += n;
- val = toupper(c);
- p8 = strchr(fmtPudStr, val);
- if (p8 != NULL)
- {
- val = p8 - fmtPudStr;
- p[2] = val;
- valid = 1;
- }
- }
-
- break;
-
- case 127: /* FL FO
-
- Two parameters, first a string, other positive.
- */
- f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
- if ((f >= 0) && n)
- {
- p[3] = n;
- ctl->opt[2] = CMD_NUMERIC;
- memcpy(ext, buf+ctl->eaten, n);
- ctl->eaten += n2;
-
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0))
- valid = 1;
- }
-
- break;
-
- case 128: /* SHELL
-
- Two string parameters, the first space teminated.
- The second arbitrary.
- */
- f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
-
- if ((f >= 0) && n)
- {
- valid = 1;
-
- p[1] = n;
- memcpy(ext, buf+ctl->eaten, n);
- ctl->eaten += n;
- ext[n] = 0; /* terminate first string */
-
- n2 = strlen(buf+ctl->eaten+1);
- memcpy(ext+n+1, buf+ctl->eaten+1, n2);
- ctl->eaten += n2;
- ctl->eaten ++;
- p[3] = p[1] + n2 + 1;
- }
-
- break;
-
- case 131: /* BI2CO HP I2CO I2CPC I2CRI I2CWB I2CWW
- SLRO SPIO TRIG
-
- Three positive parameters.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (ctl->opt[2] > 0) && ((int)p[2] >= 0) &&
- (to1 == CMD_NUMERIC) && ((int)tp1 >= 0))
- {
- p[3] = 4;
- memcpy(ext, &tp1, 4);
- valid = 1;
- }
-
- break;
-
- case 132: /* SERO
-
- Three parameters, first a string, rest >=0
- */
- f = sscanf(buf+ctl->eaten, " %*s%n %n", &n, &n2);
- if ((f >= 0) && n)
- {
- p[3] = n;
- ctl->opt[2] = CMD_NUMERIC;
- memcpy(ext, buf+ctl->eaten, n);
- ctl->eaten += n2;
-
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (ctl->opt[2] > 0) && ((int)p[2] >= 0))
- valid = 1;
- }
-
- break;
-
- case 133: /* FS
-
- Three parameters. First and third positive.
- Second may be negative when interpreted as an int.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (ctl->opt[2] > 0) &&
- (to1 == CMD_NUMERIC) && ((int)tp1 >= 0))
- {
- p[3] = 4;
- memcpy(ext, &tp1, 4);
- valid = 1;
- }
-
- break;
-
- case 134: /* BSPIO
-
- Six parameters. First to Fifth positive.
- Sixth may be negative when interpreted as an int.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
- ctl->eaten += getNum(buf+ctl->eaten, &tp2, &to2);
- ctl->eaten += getNum(buf+ctl->eaten, &tp3, &to3);
- ctl->eaten += getNum(buf+ctl->eaten, &tp4, &to4);
- ctl->eaten += getNum(buf+ctl->eaten, &tp5, &to5);
-
- if ((ctl->opt[1] > 0) && ((int)p[1] >= 0) &&
- (to1 == CMD_NUMERIC) && ((int)tp1 >= 0) &&
- (to2 == CMD_NUMERIC) && ((int)tp2 >= 0) &&
- (to3 == CMD_NUMERIC) && ((int)tp3 >= 0) &&
- (to4 == CMD_NUMERIC) && ((int)tp4 >= 0) &&
- (to5 == CMD_NUMERIC))
- {
- p[3] = 5 * 4;
- memcpy(ext+ 0, &tp1, 4);
- memcpy(ext+ 4, &tp2, 4);
- memcpy(ext+ 8, &tp3, 4);
- memcpy(ext+12, &tp4, 4);
- memcpy(ext+16, &tp5, 4);
- valid = 1;
- }
-
- break;
-
- case 191: /* PROCR
-
- One to 11 parameters, first positive,
- optional remainder, any value.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0))
- {
- pars = 0;
- p32 = (int32_t *)ext;
-
- while (pars < PI_MAX_SCRIPT_PARAMS)
- {
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- pars++;
- *p32++ = tp1;
- }
- else break;
- }
-
- p[3] = pars * 4;
-
- valid = 1;
- }
-
- break;
-
- case 192: /* WVAG
-
- One or more triplets (gpios on, gpios off, delay),
- any value.
- */
-
- pars = 0;
- p32 = (int32_t *)ext;
-
- while (pars < CMD_MAX_PARAM)
- {
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- pars++;
- *p32++ = tp1;
- }
- else break;
- }
-
- p[3] = pars * 4;
-
- if (pars && ((pars % 3) == 0)) valid = 1;
-
- break;
-
- case 193: /* BI2CZ FW I2CWD I2CZ SERW SPIW SPIX
- BSPIX
-
- Two or more parameters, first >=0, rest 0-255.
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0))
- {
- pars = 0;
- p8 = ext;
-
- while (pars < CMD_MAX_PARAM)
- {
- eaten = getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- if (((int)tp1>=0) && ((int)tp1<=255))
- {
- pars++;
- *p8++ = tp1;
- ctl->eaten += eaten;
- }
- else break; /* invalid number, end of command */
- }
- else break;
- }
-
- p[3] = pars;
-
- if (pars) valid = 1;
- }
-
- break;
-
- case 194: /* I2CPK I2CWI I2CWK
-
- Three to 34 parameters, all 0-255.
- */
-
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if ((ctl->opt[1] == CMD_NUMERIC) &&
- (ctl->opt[2] == CMD_NUMERIC) &&
- ((int)p[1]>=0) && ((int)p[2]>=0) && ((int)p[2]<=255))
- {
- pars = 0;
- p8 = ext;
-
- while (pars < 32)
- {
- eaten = getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- if (((int)tp1>=0) && ((int)tp1<=255))
- {
- pars++;
- *p8++ = tp1;
- ctl->eaten += eaten;
- }
- else break; /* invalid number, end of command */
- }
- else break;
- }
-
- p[3] = pars;
-
- if (pars > 0) valid = 1;
- }
-
- break;
-
- case 195: /* CF1 CF2
-
- Zero or more parameters, first two >=0, rest 0-255.
- */
- valid = 1;
-
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
-
- if (ctl->opt[1] == CMD_NUMERIC)
- {
- if ((int)p[1] >= 0)
- {
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
-
- if (ctl->opt[2] == CMD_NUMERIC)
- {
- if ((int)p[2] >= 0)
- {
- pars = 0;
- p8 = ext;
-
- while (pars < CMD_MAX_PARAM)
- {
- eaten = getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- if (((int)tp1>=0) && ((int)tp1<=255))
- {
- pars++;
- *p8++ = tp1;
- ctl->eaten += eaten;
- }
- else break;
- }
- else break;
- }
-
- p[3] = pars;
- }
- else valid = 0;
- }
- }
- else valid = 0;
- }
-
- break;
-
- case 196: /* WVAS
-
- gpio baud offset char...
-
- p1 gpio
- p2 baud
- p3 len + 4
- ---------
- uint32_t databits
- uint32_t stophalfbits
- uint32_t offset
- uint8_t[len]
- */
- ctl->eaten += getNum(buf+ctl->eaten, &p[1], &ctl->opt[1]);
- ctl->eaten += getNum(buf+ctl->eaten, &p[2], &ctl->opt[2]);
- ctl->eaten += getNum(buf+ctl->eaten, &tp1, &to1);
- ctl->eaten += getNum(buf+ctl->eaten, &tp2, &to2);
- ctl->eaten += getNum(buf+ctl->eaten, &tp3, &to3);
-
- if ((ctl->opt[1] == CMD_NUMERIC) && ((int)p[1] >= 0) &&
- (ctl->opt[2] == CMD_NUMERIC) && ((int)p[2] > 0) &&
- (to1 == CMD_NUMERIC) &&
- (to2 == CMD_NUMERIC) &&
- (to3 == CMD_NUMERIC))
- {
- pars = 0;
-
- memcpy(ext, &tp1, 4);
- memcpy(ext+4, &tp2, 4);
- memcpy(ext+8, &tp3, 4);
- p8 = ext + 12;
- while (pars < CMD_MAX_PARAM)
- {
- eaten = getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- if (((int)tp1>=0) && ((int)tp1<=255))
- {
- *p8++ = tp1;
- pars++;
- ctl->eaten += eaten;
- }
- else break; /* invalid number, end of command */
- }
- else break;
- }
-
- p[3] = pars + 12;
-
- if (pars > 0) valid = 1;
- }
-
- break;
-
- case 197: /* WVCHA
-
- One or more parameters, all 0-255.
- */
- pars = 0;
- p8 = ext;
-
- while (pars < CMD_MAX_PARAM)
- {
- eaten = getNum(buf+ctl->eaten, &tp1, &to1);
- if (to1 == CMD_NUMERIC)
- {
- if (((int)tp1>=0) && ((int)tp1<=255))
- {
- pars++;
- *p8++ = tp1;
- ctl->eaten += eaten;
- }
- else break; /* invalid number, end of command */
- }
- else break;
- }
-
- p[3] = pars;
-
- if (pars) valid = 1;
-
- break;
-
-
- }
-
- if (valid) return idx; else return CMD_BAD_PARAMETER;
-}
-
-char * cmdErrStr(int error)
-{
- int i;
-
- for (i=0; i<(sizeof(errInfo)/sizeof(errInfo_t)); i++)
- {
- if (errInfo[i].error == error) return errInfo[i].str;
- }
- return "unknown error";
-}
-
-int cmdParseScript(char *script, cmdScript_t *s, int diags)
-{
- int idx, len, b, i, j, tags, resolved;
- int status;
- uint32_t p[10];
- cmdInstr_t instr;
- cmdCtlParse_t ctl;
- char v[CMD_MAX_EXTENSION];
-
- ctl.eaten = 0;
-
- status = 0;
-
- cmdTagStep_t tag_step[PI_MAX_SCRIPT_TAGS];
-
- len = strlen(script);
-
- /* calloc space for PARAMS, VARS, CMDS, and STRINGS */
-
- b = (sizeof(int) * (PI_MAX_SCRIPT_PARAMS + PI_MAX_SCRIPT_VARS)) +
- (sizeof(cmdInstr_t) * (len + 2) / 2) + len;
-
- s->par = calloc(1, b);
-
- if (s->par == NULL) return -1;
-
- s->var = s->par + PI_MAX_SCRIPT_PARAMS;
-
- s->instr = (cmdInstr_t *)(s->var + PI_MAX_SCRIPT_VARS);
-
- s->str_area = (char *)(s->instr + ((len + 2) / 2));
-
- s->str_area_len = len;
- s->str_area_pos = 0;
-
- s->instrs = 0;
-
- tags = 0;
-
- idx = 0;
-
- while (ctl.eaten= 0)
- {
- if (p[3])
- {
- memcpy(s->str_area + s->str_area_pos, v, p[3]);
- s->str_area[s->str_area_pos + p[3]] = 0;
- p[4] = (intptr_t) s->str_area + s->str_area_pos;
- s->str_area_pos += (p[3] + 1);
- }
-
- memcpy(&instr.p, p, sizeof(instr.p));
-
- if (instr.p[0] == PI_CMD_TAG)
- {
- if (tags < PI_MAX_SCRIPT_TAGS)
- {
- /* check tag not already used */
- for (j=0; jinstrs;
- tags++;
- }
- else
- {
- if (diags)
- {
- fprintf(stderr, "Too many tags: %d\n", instr.p[1]);
- }
- if (!status) status = PI_TOO_MANY_TAGS;
- idx = -1;
- }
- }
- }
- else
- {
- if (diags)
- {
- if (idx == CMD_UNKNOWN_CMD)
- fprintf(stderr, "Unknown command: %s\n", cmdStr());
- else
- fprintf(stderr, "Bad parameter to %s\n", cmdStr());
- }
- if (!status) status = PI_BAD_SCRIPT_CMD;
- }
-
- if (idx >= 0)
- {
- if (instr.p[0] != PI_CMD_TAG)
- {
- memcpy(instr.opt, &ctl.opt, sizeof(instr.opt));
- s->instr[s->instrs++] = instr;
- }
- }
- }
-
- for (i=0; iinstrs; i++)
- {
- instr = s->instr[i];
-
- /* resolve jumps */
-
- if ((instr.p[0] == PI_CMD_JMP) || (instr.p[0] == PI_CMD_CALL) ||
- (instr.p[0] == PI_CMD_JZ) || (instr.p[0] == PI_CMD_JNZ) ||
- (instr.p[0] == PI_CMD_JM) || (instr.p[0] == PI_CMD_JP))
- {
- resolved = 0;
-
- for (j=0; jinstr[i].p[1] = tag_step[j].step;
- resolved = 1;
- break;
- }
- }
-
- if (!resolved)
- {
- if (diags)
- {
- fprintf(stderr, "Can't resolve tag %d\n", instr.p[1]);
- }
- if (!status) status = PI_BAD_TAG;
- }
- }
- }
- return status;
-}
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.h b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.h
deleted file mode 100644
index c27d64f05..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-/*
-This version is for pigpio version 56+
-*/
-
-#ifndef COMMAND_H
-#define COMMAND_H
-
-#include
-#include
-
-#include "pigpio.h"
-
-#define CMD_MAX_PARAM 512
-#define CMD_MAX_EXTENSION (1<<16)
-
-#define CMD_UNKNOWN_CMD -1
-#define CMD_BAD_PARAMETER -2
-#define CMD_EXT_TOO_SMALL -3
-
-#define CMD_P_ARR 10
-#define CMD_V_ARR 10
-
-#define CMD_NUMERIC 1
-#define CMD_VAR 2
-#define CMD_PAR 3
-
-typedef struct
-{
- uint32_t cmd;
- uint32_t p1;
- uint32_t p2;
- union
- {
- uint32_t p3;
- uint32_t ext_len;
- uint32_t res;
- };
-} cmdCmd_t;
-
-typedef struct
-{
- int eaten;
- int8_t opt[4];
-} cmdCtlParse_t;
-
-typedef struct
-{
- int cmd; /* command number */
- char *name; /* command name */
- int vt; /* command verification type */
- int rv; /* command return value type */
-} cmdInfo_t;
-
-typedef struct
-{
- uint32_t tag;
- int step;
-} cmdTagStep_t;
-
-typedef struct
-{
- uint32_t p[5];
- int8_t opt[4];
-} cmdInstr_t;
-
-typedef struct
-{
- /*
- +-----------+---------+---------+----------------+
- | PARAMS... | VARS... | CMDS... | STRING AREA... |
- +-----------+---------+---------+----------------+
- */
- int *par;
- int *var;
- cmdInstr_t *instr;
- int instrs;
- char *str_area;
- int str_area_len;
- int str_area_pos;
-} cmdScript_t;
-
-extern cmdInfo_t cmdInfo[];
-
-extern char *cmdUsage;
-
-int cmdParse(char *buf, uint32_t *p, unsigned ext_len, char *ext, cmdCtlParse_t *ctl);
-
-int cmdParseScript(char *script, cmdScript_t *s, int diags);
-
-char *cmdErrStr(int error);
-
-char *cmdStr(void);
-
-#endif
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.o b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.o
deleted file mode 100644
index 091bae1fd..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/command.o and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/custom.cext b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/custom.cext
deleted file mode 100644
index 905884d43..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/custom.cext
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-This version is for pigpio version 26+
-
-If you want customised functions replace this file with your own
-definitions for gpioCustom1 and gpioCustom2.
-*/
-
-#include "pigpio.h"
-
-int gpioCustom1(unsigned arg1, unsigned arg2, char *argx, unsigned count)
-{
- int i;
- unsigned max;
-
- DBG(DBG_USER, "arg1=%d arg2=%d count=%d [%s]",
- arg1, arg2, count, myBuf2Str(count, argx));
-
- CHECK_INITED;
-
- /* for dummy just return max parameter */
-
- if (arg1 > arg2) max = arg1; else max = arg2;
-
- for (i=0; i max) max = argx[i];
-
- return max;
-}
-
-
-int gpioCustom2(unsigned arg1, char *argx, unsigned count,
- char *retBuf, unsigned retMax)
-{
- int i, j, t;
-
- DBG(DBG_USER, "arg1=%d count=%d [%s] retMax=%d",
- arg1, count, myBuf2Str(count, argx), retMax);
-
- CHECK_INITED;
-
- /* for dummy just return argx reversed */
-
- if (count > retMax) count = retMax;
-
- for (i=0, j=count-1; i<=j; i++, j--)
- {
- /* t used as argx and retBuf may be the same buffer */
- t = argx[i];
- retBuf[i] = argx[j];
- retBuf[j] = t;
- }
-
- return count;
-}
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpio.so b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpio.so
deleted file mode 100644
index 0c6d19e71..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpio.so and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if.so b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if.so
deleted file mode 100644
index 80ba13279..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if.so and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if2.so b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if2.so
deleted file mode 100644
index 88c077ef9..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/libpigpiod_if2.so and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pig2vcd.1 b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pig2vcd.1
deleted file mode 100644
index 24b5a6cd9..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pig2vcd.1
+++ /dev/null
@@ -1,246 +0,0 @@
-
-." Process this file with
-." groff -man -Tascii pig2vcd.1
-."
-.TH pig2vcd 1 2012-2015 Linux "pigpio archive"
-.SH NAME
-pig2vd - A utility to convert pigpio notifications to VCD.
-
-.SH SYNOPSIS
-
-pig2vcd file.VCD
-.SH DESCRIPTION
-
-
-.ad l
-
-.nh
-pig2vcd is a utility which reads notifications on stdin and writes the
-output as a Value Change Dump (VCD) file on stdout.
-
-.br
-
-.br
-The VCD file can be viewed using GTKWave.
-
-.br
-
-.br
-.SS Notifications
-.br
-
-.br
-Notifications consist of 12 bytes with the following binary format.
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t seqno;
-.br
- uint16_t flags;
-.br
- uint32_t tick;
-.br
- uint32_t level;
-.br
-} gpioReport_t;
-.br
-
-.EE
-
-.br
-
-.br
-seqno: starts at 0 each time the handle is opened and then increments by one for each report.
-
-.br
-
-.br
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE. If bit 5 is set (PI_NTFY_FLAGS_WDOG) then bits 0-4 of the flags indicate a gpio which has had a watchdog timeout; if bit 6 is set (PI_NTFY_FLAGS_ALIVE) this indicates a keep alive signal on the pipe/socket and is sent once a minute in the absence of other notification activity.
-
-.br
-
-.br
-tick: the number of microseconds since system boot. It wraps around after 1h12m.
-
-.br
-
-.br
-level: indicates the level of each gpio. If bit 1<
-*/
-
-/*
-This version is for pigpio version 3+
-*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "pigpio.h"
-
-/*
-This software converts pigpio notification reports
-into a VCD format understood by GTKWave.
-*/
-
-#define RS (sizeof(gpioReport_t))
-
-static char * timeStamp()
-{
- static char buf[32];
-
- struct timeval now;
- struct tm tmp;
-
- gettimeofday(&now, NULL);
-
- localtime_r(&now.tv_sec, &tmp);
- strftime(buf, sizeof(buf), "%F %T", &tmp);
-
- return buf;
-}
-
-int symbol(int bit)
-{
- if (bit < 26) return ('A' + bit);
- else return ('a' + bit - 26);
-}
-
-int main(int argc, char * argv[])
-{
- int b, r, v;
- uint32_t t0;
- uint32_t lastLevel, changed;
-
- gpioReport_t report;
-
- r=read(STDIN_FILENO, &report, RS);
-
- if (r != RS) exit(-1);
-
- printf("$date %s $end\n", timeStamp());
- printf("$version pig2vcd V1 $end\n");
- printf("$timescale 1 us $end\n");
- printf("$scope module top $end\n");
-
- for (b=0; b<32; b++)
- printf("$var wire 1 %c %d $end\n", symbol(b), b);
-
- printf("$upscope $end\n");
- printf("$enddefinitions $end\n");
-
- t0 = report.tick;
- lastLevel =0;
-
- while ((r=read(STDIN_FILENO, &report, RS)) == RS)
- {
- if (report.level != lastLevel)
- {
- printf("#%u\n", report.tick - t0);
-
- changed = report.level ^ lastLevel;
-
- lastLevel = report.level;
-
- for (b=0; b<32; b++)
- {
- if (changed & (1<
-
-
-gcc -Wall -pthread -o prog prog.c -lpigpio -lrt
-
-sudo ./prog
-.SH DESCRIPTION
-
-
-.ad l
-
-.nh
-
-.br
-
-.br
-pigpio is a C library for the Raspberry which allows control of the GPIO.
-
-.br
-
-.br
-.SS Features
-.br
-
-.br
-o hardware timed PWM on any of GPIO 0-31
-
-.br
-
-.br
-o hardware timed servo pulses on any of GPIO 0-31
-
-.br
-
-.br
-o callbacks when any of GPIO 0-31 change state
-
-.br
-
-.br
-o callbacks at timed intervals
-
-.br
-
-.br
-o reading/writing all of the GPIO in a bank as one operation
-
-.br
-
-.br
-o individually setting GPIO modes, reading and writing
-
-.br
-
-.br
-o notifications when any of GPIO 0-31 change state
-
-.br
-
-.br
-o the construction of output waveforms with microsecond timing
-
-.br
-
-.br
-o rudimentary permission control over GPIO
-
-.br
-
-.br
-o a simple interface to start and stop new threads
-
-.br
-
-.br
-o I2C, SPI, and serial link wrappers
-
-.br
-
-.br
-o creating and running scripts
-
-.br
-
-.br
-.SS GPIO
-.br
-
-.br
-ALL GPIO are identified by their Broadcom number.
-
-.br
-
-.br
-.SS Credits
-.br
-
-.br
-The PWM and servo pulses are timed using the DMA and PWM peripherals.
-
-.br
-
-.br
-This use was inspired by Richard Hirst's servoblaster kernel module.
-
-.br
-
-.br
-See \fBhttps://github.com/richardghirst/PiBits/tree/master/ServoBlaster\fP
-
-.br
-
-.br
-.SS Usage
-.br
-
-.br
-Include in your source files.
-
-.br
-
-.br
-Assuming your source is in prog.c use the following command to build and
-run the executable.
-
-.br
-
-.br
-
-.EX
-gcc -Wall -pthread -o prog prog.c -lpigpio -lrt
-.br
-sudo ./prog
-.br
-
-.EE
-
-.br
-
-.br
-For examples of usage see the C programs within the pigpio archive file.
-
-.br
-
-.br
-.SS Notes
-.br
-
-.br
-All the functions which return an int return < 0 on error.
-
-.br
-
-.br
-\fBgpioInitialise\fP must be called before all other library functions
-with the following exceptions:
-
-.br
-
-.br
-
-.EX
-\fBgpioCfg*\fP
-.br
-\fBgpioVersion\fP
-.br
-\fBgpioHardwareRevision\fP
-.br
-
-.EE
-
-.br
-
-.br
-If the library is not initialised all but the \fBgpioCfg*\fP,
-\fBgpioVersion\fP, and \fBgpioHardwareRevision\fP functions will
-return error PI_NOT_INITIALISED.
-
-.br
-
-.br
-If the library is initialised the \fBgpioCfg*\fP functions will return
-error PI_INITIALISED.
-
-.br
-
-.br
-.SH FUNCTIONS
-
-.IP "\fBint gpioInitialise(void)\fP"
-.IP "" 4
-Initialises the library.
-
-.br
-
-.br
-Returns the pigpio version number if OK, otherwise PI_INIT_FAILED.
-
-.br
-
-.br
-gpioInitialise must be called before using the other library functions
-with the following exceptions:
-
-.br
-
-.br
-
-.EX
-\fBgpioCfg*\fP
-.br
-\fBgpioVersion\fP
-.br
-\fBgpioHardwareRevision\fP
-.br
-
-.EE
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-if (gpioInitialise() < 0)
-.br
-{
-.br
- // pigpio initialisation failed.
-.br
-}
-.br
-else
-.br
-{
-.br
- // pigpio initialised okay.
-.br
-}
-.br
-
-.EE
-
-.IP "\fBvoid gpioTerminate(void)\fP"
-.IP "" 4
-Terminates the library.
-
-.br
-
-.br
-Returns nothing.
-
-.br
-
-.br
-Call before program exit.
-
-.br
-
-.br
-This function resets the used DMA channels, releases memory, and
-terminates any running threads.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioTerminate();
-.br
-
-.EE
-
-.IP "\fBint gpioSetMode(unsigned gpio, unsigned mode)\fP"
-.IP "" 4
-Sets the GPIO mode, typically input or output.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53
-.br
-mode: 0-7
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE.
-
-.br
-
-.br
-Arduino style: pinMode.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSetMode(17, PI_INPUT); // Set GPIO17 as input.
-.br
-
-.br
-gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output.
-.br
-
-.br
-gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0.
-.br
-
-.EE
-
-.IP "\fBint gpioGetMode(unsigned gpio)\fP"
-.IP "" 4
-Gets the GPIO mode.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-if (gpioGetMode(17) != PI_ALT0)
-.br
-{
-.br
- gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint gpioSetPullUpDown(unsigned gpio, unsigned pud)\fP"
-.IP "" 4
-Sets or clears resistor pull ups or downs on the GPIO.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53
-.br
- pud: 0-2
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_PUD.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSetPullUpDown(17, PI_PUD_UP); // Sets a pull-up.
-.br
-
-.br
-gpioSetPullUpDown(18, PI_PUD_DOWN); // Sets a pull-down.
-.br
-
-.br
-gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs.
-.br
-
-.EE
-
-.IP "\fBint gpioRead(unsigned gpio)\fP"
-.IP "" 4
-Reads the GPIO level, on or off.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-
-.br
-
-.br
-Arduino style: digitalRead.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-printf("GPIO24 is level %d", gpioRead(24));
-.br
-
-.EE
-
-.IP "\fBint gpioWrite(unsigned gpio, unsigned level)\fP"
-.IP "" 4
-Sets the GPIO level, on or off.
-
-.br
-
-.br
-
-.EX
- gpio: 0-53
-.br
-level: 0-1
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
-
-.br
-
-.br
-If PWM or servo pulses are active on the GPIO they are switched off.
-
-.br
-
-.br
-Arduino style: digitalWrite
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioWrite(24, 1); // Set GPIO24 high.
-.br
-
-.EE
-
-.IP "\fBint gpioPWM(unsigned user_gpio, unsigned dutycycle)\fP"
-.IP "" 4
-Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
-Range defaults to 255.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-dutycycle: 0-range
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYCYCLE.
-
-.br
-
-.br
-Arduino style: analogWrite
-
-.br
-
-.br
-This and the servo functionality use the DMA and PWM or PCM peripherals
-to control and schedule the pulse lengths and dutycycles.
-
-.br
-
-.br
-The \fBgpioSetPWMrange\fP function may be used to change the default
-range of 255.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioPWM(17, 255); // Sets GPIO17 full on.
-.br
-
-.br
-gpioPWM(18, 128); // Sets GPIO18 half on.
-.br
-
-.br
-gpioPWM(23, 0); // Sets GPIO23 full off.
-.br
-
-.EE
-
-.IP "\fBint gpioGetPWMdutycycle(unsigned user_gpio)\fP"
-.IP "" 4
-Returns the PWM dutycycle setting for the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-
-.EE
-
-.br
-
-.br
-Returns between 0 (off) and range (fully on) if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-.br
-
-.br
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see \fBgpioGetPWMrange\fP).
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-
-.br
-
-.br
-Normal PWM range defaults to 255.
-
-.IP "\fBint gpioSetPWMrange(unsigned user_gpio, unsigned range)\fP"
-.IP "" 4
-Selects the dutycycle range to be used for the GPIO. Subsequent calls
-to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- range: 25-40000
-.br
-
-.EE
-
-.br
-
-.br
-Returns the real range for the given GPIO's frequency if OK,
-otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
-
-.br
-
-.br
-If PWM is currently active on the GPIO its dutycycle will be scaled
-to reflect the new range.
-
-.br
-
-.br
-The real range, the number of steps between fully off and fully
-on for each frequency, is given in the following table.
-
-.br
-
-.br
-
-.EX
- 25, 50, 100, 125, 200, 250, 400, 500, 625,
-.br
- 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000
-.br
-
-.EE
-
-.br
-
-.br
-The real value set by \fBgpioPWM\fP is (dutycycle * real range) / range.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSetPWMrange(24, 2000); // Now 2000 is fully on
-.br
- // 1000 is half on
-.br
- // 500 is quarter on, etc.
-.br
-
-.EE
-
-.IP "\fBint gpioGetPWMrange(unsigned user_gpio)\fP"
-.IP "" 4
-Returns the dutycycle range used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-
-.EE
-
-.br
-
-.br
-If a hardware clock or hardware PWM is active on the GPIO
-the reported range will be 1000000 (1M).
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-r = gpioGetPWMrange(23);
-.br
-
-.EE
-
-.IP "\fBint gpioGetPWMrealRange(unsigned user_gpio)\fP"
-.IP "" 4
-Returns the real range used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-
-.EE
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported real
-range will be 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-rr = gpioGetPWMrealRange(17);
-.br
-
-.EE
-
-.IP "\fBint gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency)\fP"
-.IP "" 4
-Sets the frequency in hertz to be used for the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-frequency: >=0
-.br
-
-.EE
-
-.br
-
-.br
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO.
-
-.br
-
-.br
-If PWM is currently active on the GPIO it will be
-switched off and then back on at the new frequency.
-
-.br
-
-.br
-Each GPIO can be independently set to one of 18 different PWM
-frequencies.
-
-.br
-
-.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
-
-.br
-
-.br
-The frequencies for each sample rate are:
-
-.br
-
-.br
-
-.EX
- Hertz
-.br
-
-.br
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
-.br
- 1250 1000 800 500 400 250 200 100 50
-.br
-
-.br
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
-.br
- 625 500 400 250 200 125 100 50 25
-.br
-
-.br
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
-.br
- 313 250 200 125 100 63 50 25 13
-.br
-sample
-.br
- rate
-.br
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
-.br
- 250 200 160 100 80 50 40 20 10
-.br
-
-.br
- 8: 5000 2500 1250 1000 625 500 313 250 200
-.br
- 156 125 100 63 50 31 25 13 6
-.br
-
-.br
- 10: 4000 2000 1000 800 500 400 250 200 160
-.br
- 125 100 80 50 40 25 20 10 5
-.br
-
-.EE
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency.
-.br
-
-.br
-gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz.
-.br
-
-.br
-gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency.
-.br
-
-.EE
-
-.IP "\fBint gpioGetPWMfrequency(unsigned user_gpio)\fP"
-.IP "" 4
-Returns the frequency (in hertz) used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-
-.EE
-
-.br
-
-.br
-For normal PWM the frequency will be that defined for the GPIO by
-\fBgpioSetPWMfrequency\fP.
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by \fBgpioHardwareClock\fP.
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by \fBgpioHardwarePWM\fP.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23.
-.br
-
-.EE
-
-.IP "\fBint gpioServo(unsigned user_gpio, unsigned pulsewidth)\fP"
-.IP "" 4
-Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
-2500 (most clockwise).
-
-.br
-
-.br
-
-.EX
- user_gpio: 0-31
-.br
-pulsewidth: 0, 500-2500
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_PULSEWIDTH.
-
-.br
-
-.br
-The range supported by servos varies and should probably be determined
-by experiment. A value of 1500 should always be safe and represents
-the mid-point of rotation. You can DAMAGE a servo if you command it
-to move beyond its limits.
-
-.br
-
-.br
-The following causes an on pulse of 1500 microseconds duration to be
-transmitted on GPIO 17 at a rate of 50 times per second. This will
-command a servo connected to GPIO 17 to rotate to its mid-point.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioServo(17, 1000); // Move servo to safe position anti-clockwise.
-.br
-
-.br
-gpioServo(23, 1500); // Move servo to centre position.
-.br
-
-.br
-gpioServo(25, 2000); // Move servo to safe position clockwise.
-.br
-
-.EE
-
-.br
-
-.br
-OTHER UPDATE RATES:
-
-.br
-
-.br
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-.br
-
-.br
-
-.EX
-PWM Hz 50 100 200 400 500
-.br
-1E6/Hz 20000 10000 5000 2500 2000
-.br
-
-.EE
-
-.br
-
-.br
-Firstly set the desired PWM frequency using \fBgpioSetPWMfrequency\fP.
-
-.br
-
-.br
-Then set the PWM range using \fBgpioSetPWMrange\fP to 1E6/frequency.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-.br
-
-.br
-E.g. If you want to update a servo connected to GPIO25 at 400Hz
-
-.br
-
-.br
-
-.EX
-gpioSetPWMfrequency(25, 400);
-.br
-
-.br
-gpioSetPWMrange(25, 2500);
-.br
-
-.EE
-
-.br
-
-.br
-Thereafter use the PWM command to move the servo,
-e.g. gpioPWM(25, 1500) will set a 1500 us pulse.
-
-.IP "\fBint gpioGetServoPulsewidth(unsigned user_gpio)\fP"
-.IP "" 4
-Returns the servo pulsewidth setting for the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
-if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-
-.IP "\fBint gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f)\fP"
-.IP "" 4
-Registers a function to be called (a callback) when the specified
-GPIO changes state.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- f: the callback function
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-One function may be registered per GPIO.
-
-.br
-
-.br
-The function is passed the GPIO, the new level, and the tick.
-
-.br
-
-.br
-The alert may be cancelled by passing NULL as the function.
-
-.br
-
-.br
-The GPIO are sampled at a rate set when the library is started.
-
-.br
-
-.br
-If a value isn't specifically set the default of 5 us is used.
-
-.br
-
-.br
-The number of samples per second is given in the following table.
-
-.br
-
-.br
-
-.EX
- samples
-.br
- per sec
-.br
-
-.br
- 1 1,000,000
-.br
- 2 500,000
-.br
-sample 4 250,000
-.br
-rate 5 200,000
-.br
-(us) 8 125,000
-.br
- 10 100,000
-.br
-
-.EE
-
-.br
-
-.br
-Level changes shorter than the sample rate may be missed.
-
-.br
-
-.br
-The thread which calls the alert functions is triggered nominally
-1000 times per second. The active alert functions will be called
-once per level change since the last time the thread was activated.
-i.e. The active alert functions will get all level changes but there
-will be a latency.
-
-.br
-
-.br
-The tick value is the time stamp of the sample in microseconds, see
-\fBgpioTick\fP for more details.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-void aFunction(int gpio, int level, uint32_t tick)
-.br
-{
-.br
- printf("GPIO %d became %d at %d", gpio, level, tick);
-.br
-}
-.br
-
-.br
-// call aFunction whenever GPIO 4 changes state
-.br
-
-.br
-gpioSetAlertFunc(4, aFunction);
-.br
-
-.EE
-
-.IP "\fBint gpioSetAlertFuncEx(unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-Registers a function to be called (a callback) when the specified
-GPIO changes state.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- f: the callback function
-.br
- userdata: pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-One function may be registered per GPIO.
-
-.br
-
-.br
-The function is passed the GPIO, the new level, the tick, and
-the userdata pointer.
-
-.br
-
-.br
-Only one of \fBgpioSetAlertFunc\fP or \fBgpioSetAlertFuncEx\fP can be
-registered per GPIO.
-
-.br
-
-.br
-See \fBgpioSetAlertFunc\fP for further details.
-
-.IP "\fBint gpioSetISRFunc(unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f)\fP"
-.IP "" 4
-Registers a function to be called (a callback) whenever the specified
-GPIO interrupt occurs.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE
-.br
- timeout: interrupt timeout in milliseconds (<=0 to cancel)
-.br
- f: the callback function
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
-or PI_BAD_ISR_INIT.
-
-.br
-
-.br
-One function may be registered per GPIO.
-
-.br
-
-.br
-The function is passed the GPIO, the current level, and the
-current tick. The level will be PI_TIMEOUT if the optional
-interrupt timeout expires.
-
-.br
-
-.br
-The underlying Linux sysfs GPIO interface is used to provide
-the interrupt services.
-
-.br
-
-.br
-The first time the function is called, with a non-NULL f, the
-GPIO is exported, set to be an input, and set to interrupt
-on the given edge and timeout.
-
-.br
-
-.br
-Subsequent calls, with a non-NULL f, can vary one or more of the
-edge, timeout, or function.
-
-.br
-
-.br
-The ISR may be cancelled by passing a NULL f, in which case the
-GPIO is unexported.
-
-.br
-
-.br
-The tick is that read at the time the process was informed of
-the interrupt. This will be a variable number of microseconds
-after the interrupt occurred. Typically the latency will be of
-the order of 50 microseconds. The latency is not guaranteed
-and will vary with system load.
-
-.br
-
-.br
-The level is that read at the time the process was informed of
-the interrupt, or PI_TIMEOUT if the optional interrupt timeout
-expired. It may not be the same as the expected edge as
-interrupts happening in rapid succession may be missed by the
-kernel (i.e. this mechanism can not be used to capture several
-interrupts only a few microseconds apart).
-
-.IP "\fBint gpioSetISRFuncEx(unsigned user_gpio, unsigned edge, int timeout, gpioISRFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-Registers a function to be called (a callback) whenever the specified
-GPIO interrupt occurs.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE
-.br
- timeout: interrupt timeout in milliseconds (<=0 to cancel)
-.br
- f: the callback function
-.br
- userdata: pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
-or PI_BAD_ISR_INIT.
-
-.br
-
-.br
-The function is passed the GPIO, the current level, the
-current tick, and the userdata pointer.
-
-.br
-
-.br
-Only one of \fBgpioSetISRFunc\fP or \fBgpioSetISRFuncEx\fP can be
-registered per GPIO.
-
-.br
-
-.br
-See \fBgpioSetISRFunc\fP for further details.
-
-.IP "\fBint gpioNotifyOpen(void)\fP"
-.IP "" 4
-This function requests a free notification handle.
-
-.br
-
-.br
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-.br
-
-.br
-A notification is a method for being notified of GPIO state changes
-via a pipe or socket.
-
-.br
-
-.br
-Pipe notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number). E.g. if the
-function returns 15 then the notifications must be read
-from /dev/pigpio15.
-
-.br
-
-.br
-Socket notifications are returned to the socket which requested the
-handle.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-h = gpioNotifyOpen();
-.br
-
-.br
-if (h >= 0)
-.br
-{
-.br
- sprintf(str, "/dev/pigpio%d", h);
-.br
-
-.br
- fd = open(str, O_RDONLY);
-.br
-
-.br
- if (fd >= 0)
-.br
- {
-.br
- // Okay.
-.br
- }
-.br
- else
-.br
- {
-.br
- // Error.
-.br
- }
-.br
-}
-.br
-else
-.br
-{
-.br
- // Error.
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint gpioNotifyOpenWithSize(int bufSize)\fP"
-.IP "" 4
-This function requests a free notification handle.
-
-.br
-
-.br
-It differs from \fBgpioNotifyOpen\fP in that the pipe size may be
-specified, whereas \fBgpioNotifyOpen\fP uses the default pipe size.
-
-.br
-
-.br
-See \fBgpioNotifyOpen\fP for further details.
-
-.IP "\fBint gpioNotifyBegin(unsigned handle, uint32_t bits)\fP"
-.IP "" 4
-This function starts notifications on a previously opened handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by \fBgpioNotifyOpen\fP
-.br
- bits: a bit mask indicating the GPIO of interest
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-The notification sends state changes for each GPIO whose corresponding
-bit in bits is set.
-
-.br
-
-.br
-Each notification occupies 12 bytes in the fifo and has the
-following structure.
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t seqno;
-.br
- uint16_t flags;
-.br
- uint32_t tick;
-.br
- uint32_t level;
-.br
-} gpioReport_t;
-.br
-
-.EE
-
-.br
-
-.br
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-.br
-
-.br
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-.br
-
-.br
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-.br
-
-.br
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-.br
-
-.br
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-.br
-
-.br
-level: indicates the level of each GPIO. If bit 1<=0, as returned by \fBgpioNotifyOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-Notifications for the handle are suspended until \fBgpioNotifyBegin\fP
-is called again.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioNotifyPause(h);
-.br
-
-.EE
-
-.IP "\fBint gpioNotifyClose(unsigned handle)\fP"
-.IP "" 4
-This function stops notifications on a previously opened handle
-and releases the handle for reuse.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by \fBgpioNotifyOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioNotifyClose(h);
-.br
-
-.EE
-
-.IP "\fBint gpioWaveClear(void)\fP"
-.IP "" 4
-This function clears all waveforms and any data added by calls to the
-\fBgpioWaveAdd*\fP functions.
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioWaveClear();
-.br
-
-.EE
-
-.IP "\fBint gpioWaveAddNew(void)\fP"
-.IP "" 4
-This function starts a new empty waveform.
-
-.br
-
-.br
-You wouldn't normally need to call this function as it is automatically
-called after a waveform is created with the \fBgpioWaveCreate\fP function.
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioWaveAddNew();
-.br
-
-.EE
-
-.IP "\fBint gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)\fP"
-.IP "" 4
-This function adds a number of pulses to the current waveform.
-
-.br
-
-.br
-
-.EX
-numPulses: the number of pulses
-.br
- pulses: an array of pulses
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-.br
-
-.br
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-.br
-
-.br
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist of a delay.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// Construct and send a 30 microsecond square wave.
-.br
-
-.br
-gpioSetMode(gpio, PI_OUTPUT);
-.br
-
-.br
-pulse[0].gpioOn = (1<= 0)
-.br
-{
-.br
- gpioWaveTxSend(wave_id, PI_WAVE_MODE_REPEAT);
-.br
-
-.br
- // Transmit for 30 seconds.
-.br
-
-.br
- sleep(30);
-.br
-
-.br
- gpioWaveTxStop();
-.br
-}
-.br
-else
-.br
-{
-.br
- // Wave create failed.
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint gpioWaveAddSerial(unsigned user_gpio, unsigned baud, unsigned data_bits, unsigned stop_bits, unsigned offset, unsigned numBytes, char *str)\fP"
-.IP "" 4
-This function adds a waveform representing serial data to the
-existing waveform (if any). The serial data starts offset
-microseconds from the start of the waveform.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- baud: 50-1000000
-.br
-data_bits: 1-32
-.br
-stop_bits: 2-8
-.br
- offset: >=0
-.br
- numBytes: >=1
-.br
- str: an array of chars (which may contain nulls)
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOPBITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-NOTES:
-
-.br
-
-.br
-The serial data is formatted as one start bit, data_bits data bits, and
-stop_bits/2 stop bits.
-
-.br
-
-.br
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-.br
-
-.br
-numBytes is the number of bytes of data in str.
-
-.br
-
-.br
-The bytes required for each character depend upon data_bits.
-
-.br
-
-.br
-For data_bits 1-8 there will be one byte per character.
-.br
-For data_bits 9-16 there will be two bytes per character.
-.br
-For data_bits 17-32 there will be four bytes per character.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#define MSG_LEN 8
-.br
-
-.br
-int i;
-.br
-char *str;
-.br
-char data[MSG_LEN];
-.br
-
-.br
-str = "Hello world!";
-.br
-
-.br
-gpioWaveAddSerial(4, 9600, 8, 2, 0, strlen(str), str);
-.br
-
-.br
-for (i=0; i=0, as returned by \fBgpioWaveCreate\fP
-.br
-
-.EE
-
-.br
-
-.br
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-
-.IP "\fBint gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)\fP"
-.IP "" 4
-This function transmits the waveform with id wave_id. The mode
-determines whether the waveform is sent once or cycles endlessly.
-The SYNC variants wait for the current waveform to reach the
-end of a cycle or finish before starting the new waveform.
-
-.br
-
-.br
-WARNING: bad things may happen if you delete the previous
-waveform before it has been synced to the new waveform.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBgpioHardwarePWM\fP will be cancelled.
-
-.br
-
-.br
-
-.EX
- wave_id: >=0, as returned by \fBgpioWaveCreate\fP
-.br
-wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
-.br
- PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint gpioWaveChain(char *buf, unsigned bufSize)\fP"
-.IP "" 4
-This function transmits a chain of waveforms.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBgpioHardwarePWM\fP will be cancelled.
-
-.br
-
-.br
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of \fBwave_id\fPs and optional command
-codes and related data.
-
-.br
-
-.br
-
-.EX
- buf: pointer to the wave_ids and optional command codes
-.br
-bufSize: the number of bytes in buf
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-.br
-
-.br
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-.br
-
-.br
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-.br
-
-.br
-Delays between waves may be added with the delay command.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-Loop Start 255 0 Identify start of a wave block
-.br
-Loop Repeat 255 1 x y loop x + y*256 times
-.br
-Delay 255 2 x y delay x + y*256 microseconds
-.br
-Loop Forever 255 3 loop forever
-.br
-
-.br
-
-.br
-If present Loop Forever must be the last entry in the chain.
-
-.br
-
-.br
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-#define WAVES 5
-.br
-#define GPIO 4
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int i, wid[WAVES];
-.br
-
-.br
- if (gpioInitialise()<0) return -1;
-.br
-
-.br
- gpioSetMode(GPIO, PI_OUTPUT);
-.br
-
-.br
- printf("start piscope, press return"); getchar();
-.br
-
-.br
- for (i=0; i=0
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
-or PI_NOT_SERIAL_GPIO.
-
-.br
-
-.br
-The bytes returned for each character depend upon the number of
-data bits \fBdata_bits\fP specified in the \fBgpioSerialReadOpen\fP command.
-
-.br
-
-.br
-For \fBdata_bits\fP 1-8 there will be one byte per character.
-.br
-For \fBdata_bits\fP 9-16 there will be two bytes per character.
-.br
-For \fBdata_bits\fP 17-32 there will be four bytes per character.
-
-.IP "\fBint gpioSerialReadClose(unsigned user_gpio)\fP"
-.IP "" 4
-This function closes a GPIO for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31, previously opened with \fBgpioSerialReadOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
-
-.IP "\fBint i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)\fP"
-.IP "" 4
-This returns a handle for the device at the address on the I2C bus.
-
-.br
-
-.br
-
-.EX
- i2cBus: >=0
-.br
- i2cAddr: 0-0x7F
-.br
-i2cFlags: 0
-.br
-
-.EE
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.br
-
-.br
-Physically buses 0 and 1 are available on the Pi. Higher numbered buses
-will be available if a kernel supported bus multiplexor is being used.
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
-PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
-
-.br
-
-.br
-For the SMBus commands the low level transactions are shown at the end
-of the function description. The following abbreviations are used.
-
-.br
-
-.br
-
-.EX
-S (1 bit) : Start bit
-.br
-P (1 bit) : Stop bit
-.br
-Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
-.br
-A, NA (1 bit) : Accept and not accept bit.
-.br
-.br
-.br
-Addr (7 bits): I2C 7 bit address.
-.br
-i2cReg (8 bits): Command byte, a byte which often selects a register.
-.br
-Data (8 bits): A data byte.
-.br
-Count (8 bits): A byte defining the length of a block operation.
-.br
-
-.br
-[..]: Data sent by the device.
-.br
-
-.EE
-
-.IP "\fBint i2cClose(unsigned handle)\fP"
-.IP "" 4
-This closes the I2C device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint i2cWriteQuick(unsigned handle, unsigned bit)\fP"
-.IP "" 4
-This sends a single bit (in the Rd/Wr bit) to the device associated
-with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- bit: 0-1, the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Quick command. SMBus 2.0 5.5.1
-
-.EX
-S Addr bit [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteByte(unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This sends a single byte to the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- bVal: 0-0xFF, the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Send byte. SMBus 2.0 5.5.2
-
-.EX
-S Addr Wr [A] bVal [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cReadByte(unsigned handle)\fP"
-.IP "" 4
-This reads a single byte from the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Receive byte. SMBus 2.0 5.5.3
-
-.EX
-S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteByteData(unsigned handle, unsigned i2cReg, unsigned bVal)\fP"
-.IP "" 4
-This writes a single byte to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write
-.br
- bVal: 0-0xFF, the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write byte. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] i2cReg [A] bVal [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteWordData(unsigned handle, unsigned i2cReg, unsigned wVal)\fP"
-.IP "" 4
-This writes a single 16 bit word to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write
-.br
- wVal: 0-0xFFFF, the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write word. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cReadByteData(unsigned handle, unsigned i2cReg)\fP"
-.IP "" 4
-This reads a single byte from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read byte. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] i2cReg [A] S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cReadWordData(unsigned handle, unsigned i2cReg)\fP"
-.IP "" 4
-This reads a single 16 bit word from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read word. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] i2cReg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal)\fP"
-.IP "" 4
-This writes 16 bits of data to the specified register of the device
-associated with handle and reads 16 bits of data in return.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write/read
-.br
- wVal: 0-0xFFFF, the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Process call. SMBus 2.0 5.5.6
-
-.EX
-S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A]
-.br
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes up to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write
-.br
- buf: an array with the data to send
-.br
- count: 1-32, the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Block write. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] i2cReg [A] count [A]
-.br
- buf0 [A] buf1 [A] ... [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cReadBlockData(unsigned handle, unsigned i2cReg, char *buf)\fP"
-.IP "" 4
-This reads a block of up to 32 bytes from the specified register of
-the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to read
-.br
- buf: an array to receive the read data
-.br
-
-.EE
-
-.br
-
-.br
-The amount of returned data is set by the device.
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Block read. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] i2cReg [A]
-.br
- S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cBlockProcessCall(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes data bytes to the specified register of the device
-associated with handle and reads a device specified number
-of bytes of data in return.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write/read
-.br
- buf: an array with the data to send and to receive the read data
-.br
- count: 1-32, the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-The SMBus 2.0 documentation states that a minimum of 1 byte may be
-sent and a minimum of 1 byte may be received. The total number of
-bytes sent/received must be 32 or less.
-
-.br
-
-.br
-Block write-block read. SMBus 2.0 5.5.8
-
-.EX
-S Addr Wr [A] i2cReg [A] count [A] buf0 [A] ... bufn [A]
-.br
- S Addr Rd [A] [Count] A [buf0] A ... [bufn] A P
-.br
-
-.EE
-
-.IP "\fBint i2cReadI2CBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the specified register of the device
-associated with handle . The count may be 1-32.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to read
-.br
- buf: an array to receive the read data
-.br
- count: 1-32, the number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] i2cReg [A]
-.br
- S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteI2CBlockData(unsigned handle, unsigned i2cReg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes 1 to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
-i2cReg: 0-255, the register to write
-.br
- buf: the data to write
-.br
- count: 1-32, the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] i2cReg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBint i2cReadDevice(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the raw device into buf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- buf: an array to receive the read data bytes
-.br
- count: >0, the number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_READ_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2cWriteDevice(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes count bytes from buf to the raw device.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- buf: an array containing the data bytes to write
-.br
- count: >0, the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBvoid i2cSwitchCombined(int setting)\fP"
-.IP "" 4
-This sets the I2C (i2c-bcm2708) module "use combined transactions"
-parameter on or off.
-
-.br
-
-.br
-
-.EX
-setting: 0 to set the parameter off, non-zero to set it on
-.br
-
-.EE
-
-.br
-
-.br
-
-.br
-
-.br
-NOTE: when the flag is on a write followed by a read to the same
-slave address will use a repeated start (rather than a stop/start).
-
-.IP "\fBint i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs)\fP"
-.IP "" 4
-This function executes multiple I2C segments in one transaction by
-calling the I2C_RDWR ioctl.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- segs: an array of I2C segments
-.br
-numSegs: >0, the number of I2C segments
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of segments if OK, otherwise PI_BAD_I2C_SEG.
-
-.IP "\fBint i2cZip(unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN.
-PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-On 2 Switch combined flag on
-.br
-Off 3 Switch combined flag off
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address defaults to that associated with the handle.
-The flags default to 0. The address and flags maintain their
-previous value until updated.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53, write 0x32, read 6 bytes
-.br
-Set address 0x1E, write 0x03, read 6 bytes
-.br
-Set address 0x68, write 0x1B, read 8 bytes
-.br
-End
-.br
-
-.br
-0x04 0x53 0x07 0x01 0x32 0x06 0x06
-.br
-0x04 0x1E 0x07 0x01 0x03 0x06 0x06
-.br
-0x04 0x68 0x07 0x01 0x1B 0x06 0x08
-.br
-0x00
-.br
-
-.EE
-
-.IP "\fBint bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud)\fP"
-.IP "" 4
-This function selects a pair of GPIO for bit banging I2C at a
-specified baud rate.
-
-.br
-
-.br
-Bit banging I2C allows for certain operations which are not possible
-with the standard I2C driver.
-
-.br
-
-.br
-o baud rates as low as 50
-.br
-o repeated starts
-.br
-o clock stretching
-.br
-o I2C on any pair of spare GPIO
-
-.br
-
-.br
-
-.EX
- SDA: 0-31
-.br
- SCL: 0-31
-.br
-baud: 50-500000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
-PI_GPIO_IN_USE.
-
-.br
-
-.br
-NOTE:
-
-.br
-
-.br
-The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
-a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-
-.IP "\fBint bbI2CClose(unsigned SDA)\fP"
-.IP "" 4
-This function stops bit banging I2C on a pair of GPIO previously
-opened with \fBbbI2COpen\fP.
-
-.br
-
-.br
-
-.EX
-SDA: 0-31, the SDA GPIO used in a prior call to \fBbbI2COpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-
-.IP "\fBint bbI2CZip(unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of bit banged I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
- SDA: 0-31 (as used in a prior call to \fBbbI2COpen\fP)
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER,
-PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN,
-PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-Start 2 Start condition
-.br
-Stop 3 Stop condition
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address and flags default to 0. The address and flags maintain
-their previous value until updated.
-
-.br
-
-.br
-No flags are currently defined.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53
-.br
-start, write 0x32, (re)start, read 6 bytes, stop
-.br
-Set address 0x1E
-.br
-start, write 0x03, (re)start, read 6 bytes, stop
-.br
-Set address 0x68
-.br
-start, write 0x1B, (re)start, read 8 bytes, stop
-.br
-End
-.br
-
-.br
-0x04 0x53
-.br
-0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x1E
-.br
-0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x68
-.br
-0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-.br
-
-.br
-0x00
-.br
-
-.EE
-
-.IP "\fBint bbSPIOpen(unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, unsigned baud, unsigned spiFlags)\fP"
-.IP "" 4
-This function selects a set of GPIO for bit banging SPI with
-a specified baud rate and mode.
-
-.br
-
-.br
-
-.EX
- CS: 0-31
-.br
- MISO: 0-31
-.br
- MOSI: 0-31
-.br
- SCLK: 0-31
-.br
- baud: 50-250000
-.br
-spiFlags: see below
-.br
-
-.EE
-
-.br
-
-.br
-spiFlags consists of the least significant 22 bits.
-
-.br
-
-.br
-
-.EX
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-.br
- 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
-.br
-
-.EE
-
-.br
-
-.br
-mm defines the SPI mode, defaults to 0
-
-.br
-
-.br
-
-.EX
-Mode CPOL CPHA
-.br
- 0 0 0
-.br
- 1 0 1
-.br
- 2 1 0
-.br
- 3 1 1
-.br
-
-.EE
-
-.br
-
-.br
-p is 0 if CS is active low (default) and 1 for active high.
-
-.br
-
-.br
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first.
-
-.br
-
-.br
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first.
-
-.br
-
-.br
-The other bits in flags should be set to zero.
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or
-PI_GPIO_IN_USE.
-
-.br
-
-.br
-If more than one device is connected to the SPI bus (defined by
-SCLK, MOSI, and MISO) each must have its own CS.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-bbSPIOpen(10, MISO, MOSI, SCLK, 10000, 0); // device 1
-.br
-bbSPIOpen(11, MISO, MOSI, SCLK, 20000, 3); // device 2
-.br
-
-.EE
-
-.IP "\fBint bbSPIClose(unsigned CS)\fP"
-.IP "" 4
-This function stops bit banging SPI on a set of GPIO
-opened with \fBbbSPIOpen\fP.
-
-.br
-
-.br
-
-.EX
-CS: 0-31, the CS GPIO used in a prior call to \fBbbSPIOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO.
-
-.IP "\fBint bbSPIXfer(unsigned CS, char *inBuf, char *outBuf, unsigned count)\fP"
-.IP "" 4
-This function executes a bit banged SPI transfer.
-
-.br
-
-.br
-
-.EX
- CS: 0-31 (as used in a prior call to \fBbbSPIOpen\fP)
-.br
- inBuf: pointer to buffer to hold data to be sent
-.br
-outBuf: pointer to buffer to hold returned data
-.br
- count: size of data transfer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// gcc -Wall -pthread -o bbSPIx_test bbSPIx_test.c -lpigpio
-.br
-// sudo ./bbSPIx_test
-.br
-
-.br
-
-.br
-#include
-.br
-
-.br
-#include "pigpio.h"
-.br
-
-.br
-#define CE0 5
-.br
-#define CE1 6
-.br
-#define MISO 13
-.br
-#define MOSI 19
-.br
-#define SCLK 12
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int i, count, set_val, read_val;
-.br
- unsigned char inBuf[3];
-.br
- char cmd1[] = {0, 0};
-.br
- char cmd2[] = {12, 0};
-.br
- char cmd3[] = {1, 128, 0};
-.br
-
-.br
- if (gpioInitialise() < 0)
-.br
- {
-.br
- fprintf(stderr, "pigpio initialisation failed.\n");
-.br
- return 1;
-.br
- }
-.br
-
-.br
- bbSPIOpen(CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC
-.br
- bbSPIOpen(CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC
-.br
-
-.br
- for (i=0; i<256; i++)
-.br
- {
-.br
- cmd1[1] = i;
-.br
-
-.br
- count = bbSPIXfer(CE0, cmd1, (char *)inBuf, 2); // > DAC
-.br
-
-.br
- if (count == 2)
-.br
- {
-.br
- count = bbSPIXfer(CE0, cmd2, (char *)inBuf, 2); // < DAC
-.br
-
-.br
- if (count == 2)
-.br
- {
-.br
- set_val = inBuf[1];
-.br
-
-.br
- count = bbSPIXfer(CE1, cmd3, (char *)inBuf, 3); // < ADC
-.br
-
-.br
- if (count == 3)
-.br
- {
-.br
- read_val = ((inBuf[1]&3)<<8) | inBuf[2];
-.br
- printf("%d %d\n", set_val, read_val);
-.br
- }
-.br
- }
-.br
- }
-.br
- }
-.br
-
-.br
- bbSPIClose(CE0);
-.br
- bbSPIClose(CE1);
-.br
-
-.br
- gpioTerminate();
-.br
-
-.br
- return 0;
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags)\fP"
-.IP "" 4
-This function returns a handle for the SPI device on the channel.
-Data will be transferred at baud bits per second. The flags may
-be used to modify the default behaviour of 4-wire operation, mode 0,
-active low chip select.
-
-.br
-
-.br
-An auxiliary SPI device is available on all models but the
-A and B and may be selected by setting the A bit in the flags.
-The auxiliary device has 3 chip selects and a selectable word
-size in bits.
-
-.br
-
-.br
-
-.EX
- spiChan: 0-1 (0-2 for the auxiliary SPI device)
-.br
- baud: 32K-125M (values above 30M are unlikely to work)
-.br
-spiFlags: see below
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
-PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
-
-.br
-
-.br
-spiFlags consists of the least significant 22 bits.
-
-.br
-
-.br
-
-.EX
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-.br
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
-.br
-
-.EE
-
-.br
-
-.br
-mm defines the SPI mode.
-
-.br
-
-.br
-Warning: modes 1 and 3 do not appear to work on the auxiliary device.
-
-.br
-
-.br
-
-.EX
-Mode POL PHA
-.br
- 0 0 0
-.br
- 1 0 1
-.br
- 2 1 0
-.br
- 3 1 1
-.br
-
-.EE
-
-.br
-
-.br
-px is 0 if CEx is active low (default) and 1 for active high.
-
-.br
-
-.br
-ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-
-.br
-
-.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
-.br
-
-.br
-W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
-SPI device only.
-
-.br
-
-.br
-nnnn defines the number of bytes (0-15) to write before switching
-the MOSI line to MISO to read data. This field is ignored
-if W is not set. Standard SPI device only.
-
-.br
-
-.br
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-bbbbbb defines the word size in bits (0-32). The default (0)
-sets 8 bits per word. Auxiliary SPI device only.
-
-.br
-
-.br
-The \fBspiRead\fP, \fBspiWrite\fP, and \fBspiXfer\fP functions
-transfer data packed into 1, 2, or 4 bytes according to
-the word size in bits.
-
-.br
-
-.br
-For bits 1-8 there will be one byte per character.
-.br
-For bits 9-16 there will be two bytes per character.
-.br
-For bits 17-32 there will be four bytes per character.
-
-.br
-
-.br
-E.g. to transfer 32 12-bit words buf should contain 64 bytes
-and count should be 64.
-
-.br
-
-.br
-The other bits in flags should be set to zero.
-
-.IP "\fBint spiClose(unsigned handle)\fP"
-.IP "" 4
-This functions closes the SPI device identified by the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspiOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint spiRead(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads count bytes of data from the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspiOpen\fP
-.br
- buf: an array to receive the read data bytes
-.br
- count: the number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spiWrite(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes of data from buf to the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspiOpen\fP
-.br
- buf: the data bytes to write
-.br
- count: the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP"
-.IP "" 4
-This function transfers count bytes of data from txBuf to the SPI
-device associated with the handle. Simultaneously count bytes of
-data are read from the device and placed in rxBuf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspiOpen\fP
-.br
- txBuf: the data bytes to write
-.br
- rxBuf: the received data bytes
-.br
- count: the number of bytes to transfer
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint serOpen(char *sertty, unsigned baud, unsigned serFlags)\fP"
-.IP "" 4
-This function opens a serial device at a specified baud rate
-and with specified flags. The device name must start with
-/dev/tty or /dev/serial.
-
-.br
-
-.br
-
-.EX
- sertty: the serial device to open
-.br
- baud: the baud rate in bits per second, see below
-.br
-serFlags: 0
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
-PI_SER_OPEN_FAILED.
-
-.br
-
-.br
-The baud rate must be one of 50, 75, 110, 134, 150,
-200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
-38400, 57600, 115200, or 230400.
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.IP "\fBint serClose(unsigned handle)\fP"
-.IP "" 4
-This function closes the serial device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint serWriteByte(unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This function writes bVal to the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serReadByte(unsigned handle)\fP"
-.IP "" 4
-This function reads a byte from the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
-
-.IP "\fBint serWrite(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes from buf to the the serial port
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
- buf: the array of bytes to write
-.br
- count: the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serRead(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads up count bytes from the the serial port
-associated with handle and writes them to buf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
- buf: an array to receive the read data
-.br
- count: the maximum number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_SER_READ_NO_DATA.
-
-.IP "\fBint serDataAvailable(unsigned handle)\fP"
-.IP "" 4
-This function returns the number of bytes available
-to be read from the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes of data available (>=0) if OK,
-otherwise PI_BAD_HANDLE.
-
-.IP "\fBint gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
-.IP "" 4
-This function sends a trigger pulse to a GPIO. The GPIO is set to
-level for pulseLen microseconds and then reset to not level.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- pulseLen: 1-100
-.br
- level: 0,1
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL,
-or PI_BAD_PULSELEN.
-
-.IP "\fBint gpioSetWatchdog(unsigned user_gpio, unsigned timeout)\fP"
-.IP "" 4
-Sets a watchdog for a GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- timeout: 0-60000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT.
-
-.br
-
-.br
-The watchdog is nominally in milliseconds.
-
-.br
-
-.br
-One watchdog may be registered per GPIO.
-
-.br
-
-.br
-The watchdog may be cancelled by setting timeout to 0.
-
-.br
-
-.br
-If no level change has been detected for the GPIO for timeout
-milliseconds:-
-
-.br
-
-.br
-1) any registered alert function for the GPIO is called with
- the level set to PI_TIMEOUT.
-.br
-2) any notification for the GPIO has a report written to the
- fifo with the flags set to indicate a watchdog timeout.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-void aFunction(int gpio, int level, uint32_t tick)
-.br
-{
-.br
- printf("GPIO %d became %d at %d", gpio, level, tick);
-.br
-}
-.br
-
-.br
-// call aFunction whenever GPIO 4 changes state
-.br
-gpioSetAlertFunc(4, aFunction);
-.br
-
-.br
-// or approximately every 5 millis
-.br
-gpioSetWatchdog(4, 5);
-.br
-
-.EE
-
-.IP "\fBint gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active)\fP"
-.IP "" 4
-Sets a noise filter on a GPIO.
-
-.br
-
-.br
-Level changes on the GPIO are ignored until a level which has
-been stable for \fBsteady\fP microseconds is detected. Level changes
-on the GPIO are then reported for \fBactive\fP microseconds after
-which the process repeats.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- steady: 0-300000
-.br
- active: 0-1000000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-.br
-
-.br
-Note, level changes before and after the active period may
-be reported. Your software must be designed to cope with
-such reports.
-
-.IP "\fBint gpioGlitchFilter(unsigned user_gpio, unsigned steady)\fP"
-.IP "" 4
-Sets a glitch filter on a GPIO.
-
-.br
-
-.br
-Level changes on the GPIO are not reported unless the level
-has been stable for at least \fBsteady\fP microseconds. The
-level is then reported. Level changes of less than \fBsteady\fP
-microseconds are ignored.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31
-.br
- steady: 0-300000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-.br
-
-.br
-Note, each (stable) edge will be timestamped \fBsteady\fP microseconds
-after it was first detected.
-
-.IP "\fBint gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits)\fP"
-.IP "" 4
-Registers a function to be called (a callback) every millisecond
-with the latest GPIO samples.
-
-.br
-
-.br
-
-.EX
- f: the function to call
-.br
-bits: the GPIO of interest
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-The function is passed a pointer to the samples (an array of
-\fBgpioSample_t\fP), and the number of samples.
-
-.br
-
-.br
-Only one function can be registered.
-
-.br
-
-.br
-The callback may be cancelled by passing NULL as the function.
-
-.br
-
-.br
-The samples returned will be the union of bits, plus any active alerts,
-plus any active notifications.
-
-.br
-
-.br
-e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
-7, 8, 9, 10, 17, 23, and 24 will be reported.
-
-.IP "\fBint gpioSetGetSamplesFuncEx(gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata)\fP"
-.IP "" 4
-Registers a function to be called (a callback) every millisecond
-with the latest GPIO samples.
-
-.br
-
-.br
-
-.EX
- f: the function to call
-.br
- bits: the GPIO of interest
-.br
-userdata: a pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-The function is passed a pointer to the samples (an array of
-\fBgpioSample_t\fP), the number of samples, and the userdata pointer.
-
-.br
-
-.br
-Only one of \fBgpioGetSamplesFunc\fP or \fBgpioGetSamplesFuncEx\fP can be
-registered.
-
-.br
-
-.br
-See \fBgpioSetGetSamplesFunc\fP for further details.
-
-.IP "\fBint gpioSetTimerFunc(unsigned timer, unsigned millis, gpioTimerFunc_t f)\fP"
-.IP "" 4
-Registers a function to be called (a callback) every millis milliseconds.
-
-.br
-
-.br
-
-.EX
- timer: 0-9
-.br
-millis: 10-60000
-.br
- f: the function to call
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
-
-.br
-
-.br
-10 timers are supported numbered 0 to 9.
-
-.br
-
-.br
-One function may be registered per timer.
-
-.br
-
-.br
-The timer may be cancelled by passing NULL as the function.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-void bFunction(void)
-.br
-{
-.br
- printf("two seconds have elapsed");
-.br
-}
-.br
-
-.br
-// call bFunction every 2000 milliseconds
-.br
-gpioSetTimerFunc(0, 2000, bFunction);
-.br
-
-.EE
-
-.IP "\fBint gpioSetTimerFuncEx(unsigned timer, unsigned millis, gpioTimerFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-Registers a function to be called (a callback) every millis milliseconds.
-
-.br
-
-.br
-
-.EX
- timer: 0-9.
-.br
- millis: 10-60000
-.br
- f: the function to call
-.br
-userdata: a pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
-
-.br
-
-.br
-The function is passed the userdata pointer.
-
-.br
-
-.br
-Only one of \fBgpioSetTimerFunc\fP or \fBgpioSetTimerFuncEx\fP can be
-registered per timer.
-
-.br
-
-.br
-See \fBgpioSetTimerFunc\fP for further details.
-
-.IP "\fBpthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata)\fP"
-.IP "" 4
-Starts a new thread of execution with f as the main routine.
-
-.br
-
-.br
-
-.EX
- f: the main function for the new thread
-.br
-userdata: a pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-.br
-
-.br
-The function is passed the single argument arg.
-
-.br
-
-.br
-The thread can be cancelled by passing the pointer to pthread_t to
-\fBgpioStopThread\fP.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-void *myfunc(void *arg)
-.br
-{
-.br
- while (1)
-.br
- {
-.br
- printf("%s", arg);
-.br
- sleep(1);
-.br
- }
-.br
-}
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- pthread_t *p1, *p2, *p3;
-.br
-
-.br
- if (gpioInitialise() < 0) return 1;
-.br
-
-.br
- p1 = gpioStartThread(myfunc, "thread 1"); sleep(3);
-.br
-
-.br
- p2 = gpioStartThread(myfunc, "thread 2"); sleep(3);
-.br
-
-.br
- p3 = gpioStartThread(myfunc, "thread 3"); sleep(3);
-.br
-
-.br
- gpioStopThread(p3); sleep(3);
-.br
-
-.br
- gpioStopThread(p2); sleep(3);
-.br
-
-.br
- gpioStopThread(p1); sleep(3);
-.br
-
-.br
- gpioTerminate();
-.br
-}
-.br
-
-.EE
-
-.IP "\fBvoid gpioStopThread(pthread_t *pth)\fP"
-.IP "" 4
-Cancels the thread pointed at by pth.
-
-.br
-
-.br
-
-.EX
-pth: a thread pointer returned by \fBgpioStartThread\fP
-.br
-
-.EE
-
-.br
-
-.br
-No value is returned.
-
-.br
-
-.br
-The thread to be stopped should have been started with \fBgpioStartThread\fP.
-
-.IP "\fBint gpioStoreScript(char *script)\fP"
-.IP "" 4
-This function stores a null terminated script for later execution.
-
-.br
-
-.br
-See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
-
-.br
-
-.br
-
-.EX
-script: the text of the script
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a script id if the script is valid,
-otherwise PI_BAD_SCRIPT.
-
-.IP "\fBint gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param)\fP"
-.IP "" 4
-This function runs a stored script.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBgpioStoreScript\fP
-.br
- numPar: 0-10, the number of parameters
-.br
- param: an array of parameters
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
-PI_TOO_MANY_PARAM.
-
-.br
-
-.br
-param is an array of up to 10 parameters which may be referenced in
-the script as p0 to p9.
-
-.IP "\fBint gpioScriptStatus(unsigned script_id, uint32_t *param)\fP"
-.IP "" 4
-This function returns the run status of a stored script as well as
-the current values of parameters 0 to 9.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBgpioStoreScript\fP
-.br
- param: an array to hold the returned 10 parameters
-.br
-
-.EE
-
-.br
-
-.br
-The function returns greater than or equal to 0 if OK,
-otherwise PI_BAD_SCRIPT_ID.
-
-.br
-
-.br
-The run status may be
-
-.br
-
-.br
-
-.EX
-PI_SCRIPT_INITING
-.br
-PI_SCRIPT_HALTED
-.br
-PI_SCRIPT_RUNNING
-.br
-PI_SCRIPT_WAITING
-.br
-PI_SCRIPT_FAILED
-.br
-
-.EE
-
-.br
-
-.br
-The current value of script parameters 0 to 9 are returned in param.
-
-.IP "\fBint gpioStopScript(unsigned script_id)\fP"
-.IP "" 4
-This function stops a running script.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBgpioStoreScript\fP
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint gpioDeleteScript(unsigned script_id)\fP"
-.IP "" 4
-This function deletes a stored script.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBgpioStoreScript\fP
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f)\fP"
-.IP "" 4
-Registers a function to be called (a callback) when a signal occurs.
-
-.br
-
-.br
-
-.EX
-signum: 0-63
-.br
- f: the callback function
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_SIGNUM.
-
-.br
-
-.br
-The function is passed the signal number.
-
-.br
-
-.br
-One function may be registered per signal.
-
-.br
-
-.br
-The callback may be cancelled by passing NULL.
-
-.br
-
-.br
-By default all signals are treated as fatal and cause the library
-to call gpioTerminate and then exit.
-
-.IP "\fBint gpioSetSignalFuncEx(unsigned signum, gpioSignalFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-Registers a function to be called (a callback) when a signal occurs.
-
-.br
-
-.br
-
-.EX
- signum: 0-63
-.br
- f: the callback function
-.br
-userdata: a pointer to arbitrary user data
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_SIGNUM.
-
-.br
-
-.br
-The function is passed the signal number and the userdata pointer.
-
-.br
-
-.br
-Only one of gpioSetSignalFunc or gpioSetSignalFuncEx can be
-registered per signal.
-
-.br
-
-.br
-See gpioSetSignalFunc for further details.
-
-.IP "\fBuint32_t gpioRead_Bits_0_31(void)\fP"
-.IP "" 4
-Returns the current level of GPIO 0-31.
-
-.IP "\fBuint32_t gpioRead_Bits_32_53(void)\fP"
-.IP "" 4
-Returns the current level of GPIO 32-53.
-
-.IP "\fBint gpioWrite_Bits_0_31_Clear(uint32_t bits)\fP"
-.IP "" 4
-Clears GPIO 0-31 if the corresponding bit in bits is set.
-
-.br
-
-.br
-
-.EX
-bits: a bit mask of GPIO to clear
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// To clear (set to 0) GPIO 4, 7, and 15
-.br
-gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
-.br
-
-.EE
-
-.IP "\fBint gpioWrite_Bits_32_53_Clear(uint32_t bits)\fP"
-.IP "" 4
-Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-.br
-
-.br
-
-.EX
-bits: a bit mask of GPIO to clear
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.IP "\fBint gpioWrite_Bits_0_31_Set(uint32_t bits)\fP"
-.IP "" 4
-Sets GPIO 0-31 if the corresponding bit in bits is set.
-
-.br
-
-.br
-
-.EX
-bits: a bit mask of GPIO to set
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.IP "\fBint gpioWrite_Bits_32_53_Set(uint32_t bits)\fP"
-.IP "" 4
-Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-.br
-
-.br
-
-.EX
-bits: a bit mask of GPIO to set
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// To set (set to 1) GPIO 32, 40, and 53
-.br
-gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
-.br
-
-.EE
-
-.IP "\fBint gpioHardwareClock(unsigned gpio, unsigned clkfreq)\fP"
-.IP "" 4
-Starts a hardware clock on a GPIO at the specified frequency.
-Frequencies above 30MHz are unlikely to work.
-
-.br
-
-.br
-
-.EX
- gpio: see description
-.br
-clkfreq: 0 (off) or 4689-250000000 (250M)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
-PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-
-.br
-
-.br
-The same clock is available on multiple GPIO. The latest
-frequency setting will be used by all GPIO which share a clock.
-
-.br
-
-.br
-The GPIO must be one of the following.
-
-.br
-
-.br
-
-.EX
-4 clock 0 All models
-.br
-5 clock 1 All models but A and B (reserved for system use)
-.br
-6 clock 2 All models but A and B
-.br
-20 clock 0 All models but A and B
-.br
-21 clock 1 All models but A and Rev.2 B (reserved for system use)
-.br
-
-.br
-32 clock 0 Compute module only
-.br
-34 clock 0 Compute module only
-.br
-42 clock 1 Compute module only (reserved for system use)
-.br
-43 clock 2 Compute module only
-.br
-44 clock 1 Compute module only (reserved for system use)
-.br
-
-.EE
-
-.br
-
-.br
-Access to clock 1 is protected by a password as its use will likely
-crash the Pi. The password is given by or'ing 0x5A000000 with the
-GPIO number.
-
-.IP "\fBint gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty)\fP"
-.IP "" 4
-Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
-Frequencies above 30MHz are unlikely to work.
-
-.br
-
-.br
-NOTE: Any waveform started by \fBgpioWaveTxSend\fP, or
-\fBgpioWaveChain\fP will be cancelled.
-
-.br
-
-.br
-This function is only valid if the pigpio main clock is PCM. The
-main clock defaults to PCM but may be overridden by a call to
-\fBgpioCfgClock\fP.
-
-.br
-
-.br
-
-.EX
- gpio: see description
-.br
-PWMfreq: 0 (off) or 1-125000000 (125M)
-.br
-PWMduty: 0 (off) to 1000000 (1M)(fully on)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO,
-PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
-
-.br
-
-.br
-The same PWM channel is available on multiple GPIO. The latest
-frequency and dutycycle setting will be used by all GPIO which
-share a PWM channel.
-
-.br
-
-.br
-The GPIO must be one of the following.
-
-.br
-
-.br
-
-.EX
-12 PWM channel 0 All models but A and B
-.br
-13 PWM channel 1 All models but A and B
-.br
-18 PWM channel 0 All models
-.br
-19 PWM channel 1 All models but A and B
-.br
-
-.br
-40 PWM channel 0 Compute module only
-.br
-41 PWM channel 1 Compute module only
-.br
-45 PWM channel 1 Compute module only
-.br
-52 PWM channel 0 Compute module only
-.br
-53 PWM channel 1 Compute module only
-.br
-
-.EE
-
-.br
-
-.br
-The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
-
-.br
-
-.br
-The actual frequency set is 250 million / steps.
-
-.br
-
-.br
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
-frequencies will have fewer steps. PWMduty is
-automatically scaled to take this into account.
-
-.IP "\fBint gpioTime(unsigned timetype, int *seconds, int *micros)\fP"
-.IP "" 4
-Updates the seconds and micros variables with the current time.
-
-.br
-
-.br
-
-.EX
-timetype: 0 (relative), 1 (absolute)
-.br
- seconds: a pointer to an int to hold seconds
-.br
- micros: a pointer to an int to hold microseconds
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_TIMETYPE.
-
-.br
-
-.br
-If timetype is PI_TIME_ABSOLUTE updates seconds and micros with the
-number of seconds and microseconds since the epoch (1st January 1970).
-
-.br
-
-.br
-If timetype is PI_TIME_RELATIVE updates seconds and micros with the
-number of seconds and microseconds since the library was initialised.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-int secs, mics;
-.br
-
-.br
-// print the number of seconds since the library was started
-.br
-gpioTime(PI_TIME_RELATIVE, &secs, &mics);
-.br
-printf("library started %d.%03d seconds ago", secs, mics/1000);
-.br
-
-.EE
-
-.IP "\fBint gpioSleep(unsigned timetype, int seconds, int micros)\fP"
-.IP "" 4
-Sleeps for the number of seconds and microseconds specified by seconds
-and micros.
-
-.br
-
-.br
-
-.EX
-timetype: 0 (relative), 1 (absolute)
-.br
- seconds: seconds to sleep
-.br
- micros: microseconds to sleep
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_TIMETYPE, PI_BAD_SECONDS,
-or PI_BAD_MICROS.
-
-.br
-
-.br
-If timetype is PI_TIME_ABSOLUTE the sleep ends when the number of seconds
-and microseconds since the epoch (1st January 1970) has elapsed. System
-clock changes are taken into account.
-
-.br
-
-.br
-If timetype is PI_TIME_RELATIVE the sleep is for the specified number
-of seconds and microseconds. System clock changes do not effect the
-sleep length.
-
-.br
-
-.br
-For short delays (say, 50 microseonds or less) use \fBgpioDelay\fP.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSleep(PI_TIME_RELATIVE, 2, 500000); // sleep for 2.5 seconds
-.br
-
-.br
-gpioSleep(PI_TIME_RELATIVE, 0, 100000); // sleep for 0.1 seconds
-.br
-
-.br
-gpioSleep(PI_TIME_RELATIVE, 60, 0); // sleep for one minute
-.br
-
-.EE
-
-.IP "\fBuint32_t gpioDelay(uint32_t micros)\fP"
-.IP "" 4
-Delays for at least the number of microseconds specified by micros.
-
-.br
-
-.br
-
-.EX
-micros: the number of microseconds to sleep
-.br
-
-.EE
-
-.br
-
-.br
-Returns the actual length of the delay in microseconds.
-
-.br
-
-.br
-Delays of 100 microseconds or less use busy waits.
-
-.IP "\fBuint32_t gpioTick(void)\fP"
-.IP "" 4
-Returns the current system tick.
-
-.br
-
-.br
-Tick is the number of microseconds since system boot.
-
-.br
-
-.br
-As tick is an unsigned 32 bit quantity it wraps around after
-2^32 microseconds, which is approximately 1 hour 12 minutes.
-
-.br
-
-.br
-You don't need to worry about the wrap around as long as you
-take a tick (uint32_t) from another tick, i.e. the following
-code will always provide the correct difference.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-uint32_t startTick, endTick;
-.br
-int diffTick;
-.br
-
-.br
-startTick = gpioTick();
-.br
-
-.br
-// do some processing
-.br
-
-.br
-endTick = gpioTick();
-.br
-
-.br
-diffTick = endTick - startTick;
-.br
-
-.br
-printf("some processing took %d microseconds", diffTick);
-.br
-
-.EE
-
-.IP "\fBunsigned gpioHardwareRevision(void)\fP"
-.IP "" 4
-Returns the hardware revision.
-
-.br
-
-.br
-If the hardware revision can not be found or is not a valid hexadecimal
-number the function returns 0.
-
-.br
-
-.br
-The hardware revision is the last few characters on the Revision line of
-/proc/cpuinfo.
-
-.br
-
-.br
-The revision number can be used to determine the assignment of GPIO
-to pins (see \fBgpio\fP).
-
-.br
-
-.br
-There are at least three types of board.
-
-.br
-
-.br
-Type 1 boards have hardware revision numbers of 2 and 3.
-
-.br
-
-.br
-Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
-
-.br
-
-.br
-Type 3 boards have hardware revision numbers of 16 or greater.
-
-.br
-
-.br
-for "Revision : 0002" the function returns 2.
-.br
-for "Revision : 000f" the function returns 15.
-.br
-for "Revision : 000g" the function returns 0.
-
-.IP "\fBunsigned gpioVersion(void)\fP"
-.IP "" 4
-Returns the pigpio version.
-
-.IP "\fBint gpioGetPad(unsigned pad)\fP"
-.IP "" 4
-This function returns the pad drive strength in mA.
-
-.br
-
-.br
-
-.EX
-pad: 0-2, the pad to get
-.br
-
-.EE
-
-.br
-
-.br
-Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-strength = gpioGetPad(1); // get pad 1 strength
-.br
-
-.EE
-
-.IP "\fBint gpioSetPad(unsigned pad, unsigned padStrength)\fP"
-.IP "" 4
-This function sets the pad drive strength in mA.
-
-.br
-
-.br
-
-.EX
- pad: 0-2, the pad to set
-.br
-padStrength: 1-16 mA
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-gpioSetPad(0, 16); // set pad 0 strength to 16 mA
-.br
-
-.EE
-
-.IP "\fBint shell(char *scriptName, char *scriptString)\fP"
-.IP "" 4
-This function uses the system call to execute a shell script
-with the given string as its parameter.
-
-.br
-
-.br
-
-.EX
- scriptName: the name of the script, only alphanumeric characters,
-.br
- '-' and '_' are allowed in the name
-.br
-scriptString: the string to pass to the script
-.br
-
-.EE
-
-.br
-
-.br
-The exit status of the system call is returned if OK, otherwise
-PI_BAD_SHELL_STATUS.
-
-.br
-
-.br
-scriptName must exist in /opt/pigpio/cgi and must be executable.
-
-.br
-
-.br
-The returned exit status is normally 256 times that set by the
-shell script exit function. If the script can't be found 32512 will
-be returned.
-
-.br
-
-.br
-The following table gives some example returned statuses.
-
-.br
-
-.br
-Script exit status Returned system call status
-.br
-1 256
-.br
-5 1280
-.br
-10 2560
-.br
-200 51200
-.br
-script not found 32512
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// pass two parameters, hello and world
-.br
-status = shell("scr1", "hello world");
-.br
-
-.br
-// pass three parameters, hello, string with spaces, and world
-.br
-status = shell("scr1", "hello 'string with spaces' world");
-.br
-
-.br
-// pass one parameter, hello string with spaces world
-.br
-status = shell("scr1", "\"hello string with spaces world\"");
-.br
-
-.EE
-
-.IP "\fBint fileOpen(char *file, unsigned mode)\fP"
-.IP "" 4
-This function returns a handle to a file opened in a specified mode.
-
-.br
-
-.br
-
-.EX
-file: the file to open
-.br
-mode: the file open mode
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
-PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
-
-.br
-
-.br
-File
-
-.br
-
-.br
-A file may only be opened if permission is granted by an entry in
-/opt/pigpio/access. This is intended to allow remote access to files
-in a more or less controlled manner.
-
-.br
-
-.br
-Each entry in /opt/pigpio/access takes the form of a file path
-which may contain wildcards followed by a single letter permission.
-The permission may be R for read, W for write, U for read/write,
-and N for no access.
-
-.br
-
-.br
-Where more than one entry matches a file the most specific rule
-applies. If no entry matches a file then access is denied.
-
-.br
-
-.br
-Suppose /opt/pigpio/access contains the following entries
-
-.br
-
-.br
-
-.EX
-/home/* n
-.br
-/home/pi/shared/dir_1/* w
-.br
-/home/pi/shared/dir_2/* r
-.br
-/home/pi/shared/dir_3/* u
-.br
-/home/pi/shared/dir_1/file.txt n
-.br
-
-.EE
-
-.br
-
-.br
-Files may be written in directory dir_1 with the exception
-of file.txt.
-
-.br
-
-.br
-Files may be read in directory dir_2.
-
-.br
-
-.br
-Files may be read and written in directory dir_3.
-
-.br
-
-.br
-If a directory allows read, write, or read/write access then files may
-be created in that directory.
-
-.br
-
-.br
-In an attempt to prevent risky permissions the following paths are
-ignored in /opt/pigpio/access.
-
-.br
-
-.br
-
-.EX
-a path containing ..
-.br
-a path containing only wildcards (*?)
-.br
-a path containing less than two non-wildcard parts
-.br
-
-.EE
-
-.br
-
-.br
-Mode
-
-.br
-
-.br
-The mode may have the following values.
-
-.br
-
-.br
-Macro Value Meaning
-.br
-PI_FILE_READ 1 open file for reading
-.br
-PI_FILE_WRITE 2 open file for writing
-.br
-PI_FILE_RW 3 open file for reading and writing
-.br
-
-.br
-
-.br
-The following values may be or'd into the mode.
-
-.br
-
-.br
-Macro Value Meaning
-.br
-PI_FILE_APPEND 4 Writes append data to the end of the file
-.br
-PI_FILE_CREATE 8 The file is created if it doesn't exist
-.br
-PI_FILE_TRUNC 16 The file is truncated
-.br
-
-.br
-
-.br
-Newly created files are owned by root with permissions owner read and write.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int handle, c;
-.br
- char buf[60000];
-.br
-
-.br
- if (gpioInitialise() < 0) return 1;
-.br
-
-.br
- // assumes /opt/pigpio/access contains the following line
-.br
- // /ram/*.c r
-.br
-
-.br
- handle = fileOpen("/ram/pigpio.c", PI_FILE_READ);
-.br
-
-.br
- if (handle >= 0)
-.br
- {
-.br
- while ((c=fileRead(handle, buf, sizeof(buf)-1)))
-.br
- {
-.br
- buf[c] = 0;
-.br
- printf("%s", buf);
-.br
- }
-.br
-
-.br
- fileClose(handle);
-.br
- }
-.br
-
-.br
- gpioTerminate();
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint fileClose(unsigned handle)\fP"
-.IP "" 4
-This function closes the file associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBfileOpen\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-fileClose(h);
-.br
-
-.EE
-
-.IP "\fBint fileWrite(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes from buf to the the file
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBfileOpen\fP
-.br
- buf: the array of bytes to write
-.br
- count: the number of bytes to write
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
-PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-status = fileWrite(h, buf, count);
-.br
-if (status == 0)
-.br
-{
-.br
- // okay
-.br
-}
-.br
-else
-.br
-{
-.br
- // error
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint fileRead(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads up to count bytes from the the file
-associated with handle and writes them to buf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBfileOpen\fP
-.br
- buf: an array to receive the read data
-.br
- count: the maximum number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-if (fileRead(h, buf, sizeof(buf)) > 0)
-.br
-{
-.br
- // process read data
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint fileSeek(unsigned handle, int32_t seekOffset, int seekFrom)\fP"
-.IP "" 4
-This function seeks to a position within the file associated
-with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBfileOpen\fP
-.br
-seekOffset: the number of bytes to move. Positive offsets
-.br
- move forward, negative offsets backwards.
-.br
- seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
-.br
- or PI_FROM_END (2)
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20
-.br
-
-.br
-size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size
-.br
-
-.br
-pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position
-.br
-
-.EE
-
-.IP "\fBint fileList(char *fpat, char *buf, unsigned count)\fP"
-.IP "" 4
-This function returns a list of files which match a pattern. The
-pattern may contain wildcards.
-
-.br
-
-.br
-
-.EX
- fpat: file pattern to match
-.br
- buf: an array to receive the matching file names
-.br
-count: the maximum number of bytes to read
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
-or PI_NO_FILE_MATCH.
-
-.br
-
-.br
-The pattern must match an entry in /opt/pigpio/access. The pattern
-may contain wildcards. See \fBfileOpen\fP.
-
-.br
-
-.br
-NOTE
-
-.br
-
-.br
-The returned value is not the number of files, it is the number
-of bytes in the buffer. The file names are separated by newline
-characters.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int c;
-.br
- char buf[1000];
-.br
-
-.br
- if (gpioInitialise() < 0) return 1;
-.br
-
-.br
- // assumes /opt/pigpio/access contains the following line
-.br
- // /ram/*.c r
-.br
-
-.br
- c = fileList("/ram/p*.c", buf, sizeof(buf));
-.br
-
-.br
- if (c >= 0)
-.br
- {
-.br
- // terminate string
-.br
- buf[c] = 0;
-.br
- printf("%s", buf);
-.br
- }
-.br
-
-.br
- gpioTerminate();
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint gpioCfgBufferSize(unsigned cfgMillis)\fP"
-.IP "" 4
-Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
-
-.br
-
-.br
-This function is only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-
-.EX
-cfgMillis: 100-10000
-.br
-
-.EE
-
-.br
-
-.br
-The default setting is 120 milliseconds.
-
-.br
-
-.br
-The intention is to allow for bursts of data and protection against
-other processes hogging cpu time.
-
-.br
-
-.br
-I haven't seen a process locked out for more than 100 milliseconds.
-
-.br
-
-.br
-Making the buffer bigger uses a LOT of memory at the more frequent
-sampling rates as shown in the following table in MBs.
-
-.br
-
-.br
-
-.EX
- buffer milliseconds
-.br
- 120 250 500 1sec 2sec 4sec 8sec
-.br
-
-.br
- 1 16 31 55 107 --- --- ---
-.br
- 2 10 18 31 55 107 --- ---
-.br
-sample 4 8 12 18 31 55 107 ---
-.br
- rate 5 8 10 14 24 45 87 ---
-.br
- (us) 8 6 8 12 18 31 55 107
-.br
- 10 6 8 10 14 24 45 87
-.br
-
-.EE
-
-.IP "\fBint gpioCfgClock(unsigned cfgMicros, unsigned cfgPeripheral, unsigned cfgSource)\fP"
-.IP "" 4
-Configures pigpio to use a particular sample rate timed by a specified
-peripheral.
-
-.br
-
-.br
-This function is only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-
-.EX
- cfgMicros: 1, 2, 4, 5, 8, 10
-.br
-cfgPeripheral: 0 (PWM), 1 (PCM)
-.br
- cfgSource: deprecated, value is ignored
-.br
-
-.EE
-
-.br
-
-.br
-The timings are provided by the specified peripheral (PWM or PCM).
-
-.br
-
-.br
-The default setting is 5 microseconds using the PCM peripheral.
-
-.br
-
-.br
-The approximate CPU percentage used for each sample rate is:
-
-.br
-
-.br
-
-.EX
-sample cpu
-.br
- rate %
-.br
-
-.br
- 1 25
-.br
- 2 16
-.br
- 4 11
-.br
- 5 10
-.br
- 8 15
-.br
- 10 14
-.br
-
-.EE
-
-.br
-
-.br
-A sample rate of 5 microseconds seeems to be the sweet spot.
-
-.IP "\fBint gpioCfgDMAchannel(unsigned DMAchannel)\fP"
-.IP "" 4
-Configures pigpio to use the specified DMA channel.
-
-.br
-
-.br
-This function is only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-
-.EX
-DMAchannel: 0-14
-.br
-
-.EE
-
-.br
-
-.br
-The default setting is to use channel 14.
-
-.IP "\fBint gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel)\fP"
-.IP "" 4
-Configures pigpio to use the specified DMA channels.
-
-.br
-
-.br
-This function is only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-
-.EX
- primaryChannel: 0-14
-.br
-secondaryChannel: 0-14
-.br
-
-.EE
-
-.br
-
-.br
-The default setting is to use channel 14 for the primary channel and
-channel 6 for the secondary channel.
-
-.br
-
-.br
-The secondary channel is only used for the transmission of waves.
-
-.br
-
-.br
-If possible use one of channels 0 to 6 for the secondary channel
-(a full channel).
-
-.br
-
-.br
-A full channel only requires one DMA control block regardless of the
-length of a pulse delay. Channels 7 to 14 (lite channels) require
-one DMA control block for each 16383 microseconds of delay. I.e.
-a 10 second pulse delay requires one control block on a full channel
-and 611 control blocks on a lite channel.
-
-.IP "\fBint gpioCfgPermissions(uint64_t updateMask)\fP"
-.IP "" 4
-Configures pigpio to only allow updates (writes or mode changes) for the
-GPIO specified by the mask.
-
-.br
-
-.br
-This function is only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-
-.EX
-updateMask: bit (1<=0
-.br
-arg2: >=0
-.br
-argx: extra (byte) arguments
-.br
-argc: number of extra arguments
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.IP "\fBint gpioCustom2(unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP"
-.IP "" 4
-This function is available for user customisation.
-
-.br
-
-.br
-It differs from gpioCustom1 in that it returns an array of bytes
-rather than just an integer.
-
-.br
-
-.br
-The returned value is an integer indicating the number of returned bytes.
-
-.EX
- arg1: >=0
-.br
- argx: extra (byte) arguments
-.br
- argc: number of extra arguments
-.br
-retBuf: buffer for returned bytes
-.br
-retMax: maximum number of bytes to return
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.br
-
-.br
-The number of returned bytes must be retMax or less.
-
-.IP "\fBint rawWaveAddSPI(rawSPI_t *spi, unsigned offset, unsigned spiSS, char *buf, unsigned spiTxBits, unsigned spiBitFirst, unsigned spiBitLast, unsigned spiBits)\fP"
-.IP "" 4
-This function adds a waveform representing SPI data to the
-existing waveform (if any).
-
-.br
-
-.br
-
-.EX
- spi: a pointer to a spi object
-.br
- offset: microseconds from the start of the waveform
-.br
- spiSS: the slave select GPIO
-.br
- buf: the bits to transmit, most significant bit first
-.br
- spiTxBits: the number of bits to write
-.br
-spiBitFirst: the first bit to read
-.br
- spiBitLast: the last bit to read
-.br
- spiBits: the number of bits to transfer
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_SER_OFFSET, or PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBint rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses)\fP"
-.IP "" 4
-This function adds a number of pulses to the current waveform.
-
-.br
-
-.br
-
-.EX
-numPulses: the number of pulses
-.br
- pulses: the array containing the pulses
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-The advantage of this function over gpioWaveAddGeneric is that it
-allows the setting of the flags field.
-
-.br
-
-.br
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-.br
-
-.br
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-.br
-
-.br
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist of a delay.
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBunsigned rawWaveCB(void)\fP"
-.IP "" 4
-Returns the number of the cb being currently output.
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBrawCbs_t *rawWaveCBAdr(int cbNum)\fP"
-.IP "" 4
-Return the (Linux) address of contol block cbNum.
-
-.br
-
-.br
-
-.EX
-cbNum: the cb of interest
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBuint32_t rawWaveGetOOL(int pos)\fP"
-.IP "" 4
-Gets the OOL parameter stored at pos.
-
-.br
-
-.br
-
-.EX
-pos: the position of interest.
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBvoid rawWaveSetOOL(int pos, uint32_t lVal)\fP"
-.IP "" 4
-Sets the OOL parameter stored at pos to value.
-
-.br
-
-.br
-
-.EX
- pos: the position of interest
-.br
-lVal: the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBuint32_t rawWaveGetOut(int pos)\fP"
-.IP "" 4
-Gets the wave output parameter stored at pos.
-
-.br
-
-.br
-DEPRECATED: use rawWaveGetOOL instead.
-
-.br
-
-.br
-
-.EX
-pos: the position of interest.
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBvoid rawWaveSetOut(int pos, uint32_t lVal)\fP"
-.IP "" 4
-Sets the wave output parameter stored at pos to value.
-
-.br
-
-.br
-DEPRECATED: use rawWaveSetOOL instead.
-
-.br
-
-.br
-
-.EX
- pos: the position of interest
-.br
-lVal: the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBuint32_t rawWaveGetIn(int pos)\fP"
-.IP "" 4
-Gets the wave input value parameter stored at pos.
-
-.br
-
-.br
-DEPRECATED: use rawWaveGetOOL instead.
-
-.br
-
-.br
-
-.EX
-pos: the position of interest
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBvoid rawWaveSetIn(int pos, uint32_t lVal)\fP"
-.IP "" 4
-Sets the wave input value stored at pos to value.
-
-.br
-
-.br
-DEPRECATED: use rawWaveSetOOL instead.
-
-.br
-
-.br
-
-.EX
- pos: the position of interest
-.br
-lVal: the value to write
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBrawWaveInfo_t rawWaveInfo(int wave_id)\fP"
-.IP "" 4
-Gets details about the wave with id wave_id.
-
-.br
-
-.br
-
-.EX
-wave_id: the wave of interest
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBint getBitInBytes(int bitPos, char *buf, int numBits)\fP"
-.IP "" 4
-Returns the value of the bit bitPos bits from the start of buf. Returns
-0 if bitPos is greater than or equal to numBits.
-
-.br
-
-.br
-
-.EX
- bitPos: bit index from the start of buf
-.br
- buf: array of bits
-.br
-numBits: number of valid bits in buf
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBvoid putBitInBytes(int bitPos, char *buf, int bit)\fP"
-.IP "" 4
-Sets the bit bitPos bits from the start of buf to bit.
-
-.br
-
-.br
-
-.EX
-bitPos: bit index from the start of buf
-.br
- buf: array of bits
-.br
- bit: 0-1, value to set
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBdouble time_time(void)\fP"
-.IP "" 4
-Return the current time in seconds since the Epoch.
-
-.IP "\fBvoid time_sleep(double seconds)\fP"
-.IP "" 4
-Delay execution for a given number of seconds
-
-.br
-
-.br
-
-.EX
-seconds: the number of seconds to sleep
-.br
-
-.EE
-
-.IP "\fBvoid rawDumpWave(void)\fP"
-.IP "" 4
-Used to print a readable version of the current waveform to stderr.
-
-.br
-
-.br
-Not intended for general use.
-
-.IP "\fBvoid rawDumpScript(unsigned script_id)\fP"
-.IP "" 4
-Used to print a readable version of a script to stderr.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, a script_id returned by \fBgpioStoreScript\fP
-.br
-
-.EE
-
-.br
-
-.br
-Not intended for general use.
-.SH PARAMETERS
-
-.br
-
-.br
-
-.IP "\fBactive\fP: 0-1000000" 0
-
-.br
-
-.br
-The number of microseconds level changes are reported for once
-a noise filter has been triggered (by \fBsteady\fP microseconds of
-a stable level).
-
-.br
-
-.br
-
-.IP "\fBarg1\fP" 0
-
-.br
-
-.br
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBarg2\fP" 0
-
-.br
-
-.br
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBargc\fP" 0
-The count of bytes passed to a user customised function.
-
-.br
-
-.br
-
-.IP "\fB*argx\fP" 0
-A pointer to an array of bytes passed to a user customised function.
-Its meaning and content is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBbaud\fP" 0
-The speed of serial communication (I2C, SPI, serial link, waves) in
-bits per second.
-
-.br
-
-.br
-
-.IP "\fBbit\fP" 0
-A value of 0 or 1.
-
-.br
-
-.br
-
-.IP "\fBbitPos\fP" 0
-A bit position within a byte or word. The least significant bit is
-position 0.
-
-.br
-
-.br
-
-.IP "\fBbits\fP" 0
-A value used to select GPIO. If bit n of bits is set then GPIO n is
-selected.
-
-.br
-
-.br
-A convenient way to set bit n is to or in (1<=0" 0
-
-.br
-
-.br
-The number of times a GPIO is swiched on and off per second. This
-can be set per GPIO and may be as little as 5Hz or as much as
-40KHz. The GPIO will be on for a proportion of the time as defined
-by its dutycycle.
-
-.br
-
-.br
-
-.IP "\fBgpio\fP" 0
-
-.br
-
-.br
-A Broadcom numbered GPIO, in the range 0-53.
-
-.br
-
-.br
-There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
-GPIO53.
-
-.br
-
-.br
-They are split into two banks. Bank 1 consists of GPIO0 through
-GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-
-.br
-
-.br
-All the GPIO which are safe for the user to read and write are in
-bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
-have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
-.br
-
-.br
-See \fBgpioHardwareRevision\fP.
-
-.br
-
-.br
-The user GPIO are marked with an X in the following table.
-
-.br
-
-.br
-
-.EX
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-.br
-Type 1 X X - - X - - X X X X X - - X X
-.br
-Type 2 - - X X X - - X X X X X - - X X
-.br
-Type 3 X X X X X X X X X X X X X X
-.br
-
-.br
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
-.br
-Type 1 - X X - - X X X X X - - - - - -
-.br
-Type 2 - X X - - - X X X X - X X X X X
-.br
-Type 3 X X X X X X X X X X X X - - - -
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioAlertFunc_t\fP" 0
-
-.EX
-typedef void (*gpioAlertFunc_t) (int gpio, int level, uint32_t tick);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioAlertFuncEx_t\fP" 0
-
-.EX
-typedef void (*gpioAlertFuncEx_t)
-.br
- (int gpio, int level, uint32_t tick, void *userdata);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioCfg*\fP" 0
-
-.br
-
-.br
-These functions are only effective if called before \fBgpioInitialise\fP.
-
-.br
-
-.br
-\fBgpioCfgBufferSize\fP
-.br
-\fBgpioCfgClock\fP
-.br
-\fBgpioCfgDMAchannel\fP
-.br
-\fBgpioCfgDMAchannels\fP
-.br
-\fBgpioCfgPermissions\fP
-.br
-\fBgpioCfgInterfaces\fP
-.br
-\fBgpioCfgSocketPort\fP
-.br
-\fBgpioCfgMemAlloc\fP
-
-.br
-
-.br
-
-.IP "\fBgpioGetSamplesFunc_t\fP" 0
-
-.EX
-typedef void (*gpioGetSamplesFunc_t)
-.br
- (const gpioSample_t *samples, int numSamples);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioGetSamplesFuncEx_t\fP" 0
-
-.EX
-typedef void (*gpioGetSamplesFuncEx_t)
-.br
- (const gpioSample_t *samples, int numSamples, void *userdata);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioISRFunc_t\fP" 0
-
-.EX
-typedef void (*gpioISRFunc_t)
-.br
- (int gpio, int level, uint32_t tick);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioISRFuncEx_t\fP" 0
-
-.EX
-typedef void (*gpioISRFuncEx_t)
-.br
- (int gpio, int level, uint32_t tick, void *userdata);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioPulse_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- uint32_t gpioOn;
-.br
- uint32_t gpioOff;
-.br
- uint32_t usDelay;
-.br
-} gpioPulse_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioSample_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- uint32_t tick;
-.br
- uint32_t level;
-.br
-} gpioSample_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioSignalFunc_t\fP" 0
-
-.EX
-typedef void (*gpioSignalFunc_t) (int signum);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioSignalFuncEx_t\fP" 0
-
-.EX
-typedef void (*gpioSignalFuncEx_t) (int signum, void *userdata);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioThreadFunc_t\fP" 0
-
-.EX
-typedef void *(gpioThreadFunc_t) (void *);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioTimerFunc_t\fP" 0
-
-.EX
-typedef void (*gpioTimerFunc_t) (void);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioTimerFuncEx_t\fP" 0
-
-.EX
-typedef void (*gpioTimerFuncEx_t) (void *userdata);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioWaveAdd*\fP" 0
-
-.br
-
-.br
-One of
-
-.br
-
-.br
-\fBgpioWaveAddNew\fP
-.br
-\fBgpioWaveAddGeneric\fP
-.br
-\fBgpioWaveAddSerial\fP
-
-.br
-
-.br
-
-.IP "\fBhandle\fP: >=0" 0
-
-.br
-
-.br
-A number referencing an object opened by one of \fBfileOpen\fP,
-\fBgpioNotifyOpen\fP, \fBi2cOpen\fP, \fBserOpen\fP, \fBspiOpen\fP.
-
-.br
-
-.br
-
-.IP "\fBi2cAddr\fP: 0-0x7F" 0
-The address of a device on the I2C bus.
-
-.br
-
-.br
-
-.IP "\fBi2cBus\fP: >=0" 0
-
-.br
-
-.br
-An I2C bus number.
-
-.br
-
-.br
-
-.IP "\fBi2cFlags\fP: 0" 0
-
-.br
-
-.br
-Flags which modify an I2C open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fBi2cReg\fP: 0-255" 0
-
-.br
-
-.br
-A register of an I2C device.
-
-.br
-
-.br
-
-.IP "\fBifFlags\fP: 0-3" 0
-
-.EX
-PI_DISABLE_FIFO_IF 1
-.br
-PI_DISABLE_SOCK_IF 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*inBuf\fP" 0
-A buffer used to pass data to a function.
-
-.br
-
-.br
-
-.IP "\fBinLen\fP" 0
-The number of bytes of data in a buffer.
-
-.br
-
-.br
-
-.IP "\fBint\fP" 0
-A whole number, negative or positive.
-
-.br
-
-.br
-
-.IP "\fBint32_t\fP" 0
-A 32-bit signed value.
-
-.br
-
-.br
-
-.IP "\fBinvert\fP" 0
-A flag used to set normal or inverted bit bang serial data level logic.
-
-.br
-
-.br
-
-.IP "\fBlevel\fP" 0
-The level of a GPIO. Low or High.
-
-.br
-
-.br
-
-.EX
-PI_OFF 0
-.br
-PI_ON 1
-.br
-
-.br
-PI_CLEAR 0
-.br
-PI_SET 1
-.br
-
-.br
-PI_LOW 0
-.br
-PI_HIGH 1
-.br
-
-.EE
-
-.br
-
-.br
-There is one exception. If a watchdog expires on a GPIO the level will be
-reported as PI_TIMEOUT. See \fBgpioSetWatchdog\fP.
-
-.br
-
-.br
-
-.EX
-PI_TIMEOUT 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fBlVal\fP: 0-4294967295 (Hex 0x0-0xFFFFFFFF, Octal 0-37777777777)" 0
-
-.br
-
-.br
-A 32-bit word value.
-
-.br
-
-.br
-
-.IP "\fBmemAllocMode\fP: 0-2" 0
-
-.br
-
-.br
-The DMA memory allocation mode.
-
-.br
-
-.br
-
-.EX
-PI_MEM_ALLOC_AUTO 0
-.br
-PI_MEM_ALLOC_PAGEMAP 1
-.br
-PI_MEM_ALLOC_MAILBOX 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*micros\fP" 0
-
-.br
-
-.br
-A value representing microseconds.
-
-.br
-
-.br
-
-.IP "\fBmicros\fP" 0
-
-.br
-
-.br
-A value representing microseconds.
-
-.br
-
-.br
-
-.IP "\fBmillis\fP" 0
-
-.br
-
-.br
-A value representing milliseconds.
-
-.br
-
-.br
-
-.IP "\fBMISO\fP" 0
-The GPIO used for the MISO signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fBmode\fP" 0
-
-.br
-
-.br
-1. The operational mode of a GPIO, normally INPUT or OUTPUT.
-
-.br
-
-.br
-
-.EX
-PI_INPUT 0
-.br
-PI_OUTPUT 1
-.br
-PI_ALT0 4
-.br
-PI_ALT1 5
-.br
-PI_ALT2 6
-.br
-PI_ALT3 7
-.br
-PI_ALT4 3
-.br
-PI_ALT5 2
-.br
-
-.EE
-
-.br
-
-.br
-2. A file open mode.
-
-.br
-
-.br
-
-.EX
-PI_FILE_READ 1
-.br
-PI_FILE_WRITE 2
-.br
-PI_FILE_RW 3
-.br
-
-.EE
-
-.br
-
-.br
-The following values can be or'd into the mode.
-
-.br
-
-.br
-
-.EX
-PI_FILE_APPEND 4
-.br
-PI_FILE_CREATE 8
-.br
-PI_FILE_TRUNC 16
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBMOSI\fP" 0
-The GPIO used for the MOSI signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fBnumBits\fP" 0
-
-.br
-
-.br
-The number of bits stored in a buffer.
-
-.br
-
-.br
-
-.IP "\fBnumBytes\fP" 0
-The number of bytes used to store characters in a string. Depending
-on the number of bits per character there may be 1, 2, or 4 bytes
-per character.
-
-.br
-
-.br
-
-.IP "\fBnumPar\fP: 0-10" 0
-The number of parameters passed to a script.
-
-.br
-
-.br
-
-.IP "\fBnumPulses\fP" 0
-The number of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBnumSegs\fP" 0
-The number of segments in a combined I2C transaction.
-
-.br
-
-.br
-
-.IP "\fBnumSockAddr\fP" 0
-The number of network addresses allowed to use the socket interface.
-
-.br
-
-.br
-0 means all addresses allowed.
-
-.br
-
-.br
-
-.IP "\fBoffset\fP" 0
-The associated data starts this number of microseconds from the start of
-the waveform.
-
-.br
-
-.br
-
-.IP "\fB*outBuf\fP" 0
-A buffer used to return data from a function.
-
-.br
-
-.br
-
-.IP "\fBoutLen\fP" 0
-The size in bytes of an output buffer.
-
-.br
-
-.br
-
-.IP "\fBpad\fP: 0-2" 0
-A set of GPIO which share common drivers.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-
-.IP "\fBpadStrength\fP: 1-16" 0
-The mA which may be drawn from each GPIO whilst still guaranteeing the
-high and low levels.
-
-.br
-
-.br
-
-.IP "\fB*param\fP" 0
-An array of script parameters.
-
-.br
-
-.br
-
-.IP "\fBpi_i2c_msg_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t addr; // slave address
-.br
- uint16_t flags;
-.br
- uint16_t len; // msg length
-.br
- uint8_t *buf; // pointer to msg data
-.br
-} pi_i2c_msg_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBport\fP: 1024-32000" 0
-The port used to bind to the pigpio socket. Defaults to 8888.
-
-.br
-
-.br
-
-.IP "\fBpos\fP" 0
-The position of an item.
-
-.br
-
-.br
-
-.IP "\fBprimaryChannel\fP: 0-14" 0
-The DMA channel used to time the sampling of GPIO and to time servo and
-PWM pulses.
-
-.br
-
-.br
-
-.IP "\fB*pth\fP" 0
-
-.br
-
-.br
-A thread identifier, returned by \fBgpioStartThread\fP.
-
-.br
-
-.br
-
-.IP "\fBpthread_t\fP" 0
-
-.br
-
-.br
-A thread identifier.
-
-.br
-
-.br
-
-.IP "\fBpud\fP: 0-2" 0
-
-.br
-
-.br
-The setting of the pull up/down resistor for a GPIO, which may be off,
-pull-up, or pull-down.
-
-.EX
-PI_PUD_OFF 0
-.br
-PI_PUD_DOWN 1
-.br
-PI_PUD_UP 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBpulseLen\fP" 0
-
-.br
-
-.br
-1-100, the length of a trigger pulse in microseconds.
-
-.br
-
-.br
-
-.IP "\fB*pulses\fP" 0
-
-.br
-
-.br
-An array of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBpulsewidth\fP: 0, 500-2500" 0
-
-.EX
-PI_SERVO_OFF 0
-.br
-PI_MIN_SERVO_PULSEWIDTH 500
-.br
-PI_MAX_SERVO_PULSEWIDTH 2500
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0
-The hardware PWM dutycycle.
-
-.br
-
-.br
-
-.EX
-PI_HW_PWM_RANGE 1000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMfreq\fP: 5-250K" 0
-The hardware PWM frequency.
-
-.br
-
-.br
-
-.EX
-PI_HW_PWM_MIN_FREQ 1
-.br
-PI_HW_PWM_MAX_FREQ 125000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrange\fP: 25-40000" 0
-
-.EX
-PI_MIN_DUTYCYCLE_RANGE 25
-.br
-PI_MAX_DUTYCYCLE_RANGE 40000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrawCbs_t\fP" 0
-
-.EX
-typedef struct // linux/arch/arm/mach-bcm2708/include/mach/dma.h
-.br
-{
-.br
- unsigned long info;
-.br
- unsigned long src;
-.br
- unsigned long dst;
-.br
- unsigned long length;
-.br
- unsigned long stride;
-.br
- unsigned long next;
-.br
- unsigned long pad[2];
-.br
-} rawCbs_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrawSPI_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- int clk; // GPIO for clock
-.br
- int mosi; // GPIO for MOSI
-.br
- int miso; // GPIO for MISO
-.br
- int ss_pol; // slave select off state
-.br
- int ss_us; // delay after slave select
-.br
- int clk_pol; // clock off state
-.br
- int clk_pha; // clock phase
-.br
- int clk_us; // clock micros
-.br
-} rawSPI_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrawWave_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- uint32_t gpioOn;
-.br
- uint32_t gpioOff;
-.br
- uint32_t usDelay;
-.br
- uint32_t flags;
-.br
-} rawWave_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrawWaveInfo_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t botCB; // first CB used by wave
-.br
- uint16_t topCB; // last CB used by wave
-.br
- uint16_t botOOL; // last OOL used by wave
-.br
- uint16_t topOOL; // first OOL used by wave
-.br
- uint16_t deleted;
-.br
- uint16_t numCB;
-.br
- uint16_t numBOOL;
-.br
- uint16_t numTOOL;
-.br
-} rawWaveInfo_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*retBuf\fP" 0
-
-.br
-
-.br
-A buffer to hold a number of bytes returned to a used customised function,
-
-.br
-
-.br
-
-.IP "\fBretMax\fP" 0
-
-.br
-
-.br
-The maximum number of bytes a user customised function should return.
-
-.br
-
-.br
-
-.IP "\fB*rxBuf\fP" 0
-
-.br
-
-.br
-A pointer to a buffer to receive data.
-
-.br
-
-.br
-
-.IP "\fBSCL\fP" 0
-The user GPIO to use for the clock when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fBSCLK\fP" 0
-The GPIO used for the SCLK signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fB*script\fP" 0
-A pointer to the text of a script.
-
-.br
-
-.br
-
-.IP "\fBscript_id\fP" 0
-An id of a stored script as returned by \fBgpioStoreScript\fP.
-
-.br
-
-.br
-
-.IP "\fB*scriptName\fP" 0
-The name of a \fBshell\fP script to be executed. The script must be present in
-/opt/pigpio/cgi and must have execute permission.
-
-.br
-
-.br
-
-.IP "\fB*scriptString\fP" 0
-The string to be passed to a \fBshell\fP script to be executed.
-
-.br
-
-.br
-
-.IP "\fBSDA\fP" 0
-The user GPIO to use for data when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fBsecondaryChannel\fP: 0-6" 0
-
-.br
-
-.br
-The DMA channel used to time output waveforms.
-
-.br
-
-.br
-
-.IP "\fB*seconds\fP" 0
-
-.br
-
-.br
-A pointer to a uint32_t to store the second component of
-a returned time.
-
-.br
-
-.br
-
-.IP "\fBseconds\fP" 0
-The number of seconds.
-
-.br
-
-.br
-
-.IP "\fBseekFrom\fP" 0
-
-.br
-
-.br
-
-.EX
-PI_FROM_START 0
-.br
-PI_FROM_CURRENT 1
-.br
-PI_FROM_END 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBseekOffset\fP" 0
-The number of bytes to move forward (positive) or backwards (negative)
-from the seek position (start, current, or end of file).
-
-.br
-
-.br
-
-.IP "\fB*segs\fP" 0
-An array of segments which make up a combined I2C transaction.
-
-.br
-
-.br
-
-.IP "\fBserFlags\fP" 0
-Flags which modify a serial open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fB*sertty\fP" 0
-The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
-
-.br
-
-.br
-
-.IP "\fBsetting\fP" 0
-A value used to set a flag, 0 for false, non-zero for true.
-
-.br
-
-.br
-
-.IP "\fBsignum\fP: 0-63" 0
-
-.EX
-PI_MIN_SIGNUM 0
-.br
-PI_MAX_SIGNUM 63
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBsize_t\fP" 0
-
-.br
-
-.br
-A standard type used to indicate the size of an object in bytes.
-
-.br
-
-.br
-
-.IP "\fB*sockAddr\fP" 0
-An array of network addresses allowed to use the socket interface encoded
-as 32 bit numbers.
-
-.br
-
-.br
-E.g. address 192.168.1.66 would be encoded as 0x4201a8c0.
-
-.br
-
-.br
-
-.IP "\fB*spi\fP" 0
-A pointer to a \fBrawSPI_t\fP structure.
-
-.br
-
-.br
-
-.IP "\fBspiBitFirst\fP" 0
-GPIO reads are made from spiBitFirst to spiBitLast.
-
-.br
-
-.br
-
-.IP "\fBspiBitLast\fP" 0
-
-.br
-
-.br
-GPIO reads are made from spiBitFirst to spiBitLast.
-
-.br
-
-.br
-
-.IP "\fBspiBits\fP" 0
-The number of bits to transfer in a raw SPI transaction.
-
-.br
-
-.br
-
-.IP "\fBspiChan\fP" 0
-A SPI channel, 0-2.
-
-.br
-
-.br
-
-.IP "\fBspiFlags\fP" 0
-See \fBspiOpen\fP and \fBbbSPIOpen\fP.
-
-.br
-
-.br
-
-.IP "\fBspiSS\fP" 0
-The SPI slave select GPIO in a raw SPI transaction.
-
-.br
-
-.br
-
-.IP "\fBspiTxBits\fP" 0
-The number of bits to transfer dring a raw SPI transaction
-
-.br
-
-.br
-
-.IP "\fBsteady\fP: 0-300000" 0
-
-.br
-
-.br
-The number of microseconds level changes must be stable for
-before reporting the level changed (\fBgpioGlitchFilter\fP) or triggering
-the active part of a noise filter (\fBgpioNoiseFilter\fP).
-
-.br
-
-.br
-
-.IP "\fBstop_bits\fP: 2-8" 0
-The number of (half) stop bits to be used when adding serial data
-to a waveform.
-
-.br
-
-.br
-
-.EX
-PI_MIN_WAVE_HALFSTOPBITS 2
-.br
-PI_MAX_WAVE_HALFSTOPBITS 8
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*str\fP" 0
-An array of characters.
-
-.br
-
-.br
-
-.IP "\fBtimeout\fP" 0
-A GPIO level change timeout in milliseconds.
-
-.br
-
-.br
-\fBgpioSetWatchdog\fP
-
-.EX
-PI_MIN_WDOG_TIMEOUT 0
-.br
-PI_MAX_WDOG_TIMEOUT 60000
-.br
-
-.EE
-
-.br
-
-.br
-\fBgpioSetISRFunc\fP and \fBgpioSetISRFuncEx\fP
-
-.EX
-<=0 cancel timeout
-.br
->0 timeout after specified milliseconds
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBtimer\fP" 0
-
-.EX
-PI_MIN_TIMER 0
-.br
-PI_MAX_TIMER 9
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBtimetype\fP" 0
-
-.EX
-PI_TIME_RELATIVE 0
-.br
-PI_TIME_ABSOLUTE 1
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*txBuf\fP" 0
-
-.br
-
-.br
-An array of bytes to transmit.
-
-.br
-
-.br
-
-.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0
-
-.br
-
-.br
-A 32-bit unsigned value.
-
-.br
-
-.br
-
-.IP "\fBuint64_t\fP: 0-(2^64)-1" 0
-
-.br
-
-.br
-A 64-bit unsigned value.
-
-.br
-
-.br
-
-.IP "\fBunsigned\fP" 0
-
-.br
-
-.br
-A whole number >= 0.
-
-.br
-
-.br
-
-.IP "\fBupdateMask\fP" 0
-
-.br
-
-.br
-A 64 bit mask indicating which GPIO may be written to by the user.
-
-.br
-
-.br
-If GPIO#n may be written then bit (1< 3
-.br
-#define PI_BAD_CHANNEL -27 // DMA channel not 0-14
-.br
-#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-14
-.br
-#define PI_BAD_SOCKET_PORT -28 // socket port not 1024-32000
-.br
-#define PI_BAD_FIFO_COMMAND -29 // unrecognized fifo command
-.br
-#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
-.br
-#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
-.br
-#define PI_INITIALISED -32 // function called after gpioInitialise
-.br
-#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
-.br
-#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
-.br
-#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
-.br
-#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
-.br
-#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
-.br
-#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read on GPIO
-.br
-#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
-.br
-#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
-.br
-#define PI_NOT_PERMITTED -41 // GPIO operation not permitted
-.br
-#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted
-.br
-#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand
-.br
-#define PI_BAD_WVSM_COMMND -44 // bad WVSM subcommand
-.br
-#define PI_BAD_WVSP_COMMND -45 // bad WVSP subcommand
-.br
-#define PI_BAD_PULSELEN -46 // trigger pulse length not 1-100
-.br
-#define PI_BAD_SCRIPT -47 // invalid script
-.br
-#define PI_BAD_SCRIPT_ID -48 // unknown script id
-.br
-#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes
-.br
-#define PI_GPIO_IN_USE -50 // GPIO already in use
-.br
-#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
-.br
-#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9
-.br
-#define PI_DUP_TAG -53 // script has duplicate tag
-.br
-#define PI_TOO_MANY_TAGS -54 // script has too many tags
-.br
-#define PI_BAD_SCRIPT_CMD -55 // illegal script command
-.br
-#define PI_BAD_VAR_NUM -56 // script variable id not 0-149
-.br
-#define PI_NO_SCRIPT_ROOM -57 // no more room for scripts
-.br
-#define PI_NO_MEMORY -58 // can't allocate temporary memory
-.br
-#define PI_SOCK_READ_FAILED -59 // socket read failed
-.br
-#define PI_SOCK_WRIT_FAILED -60 // socket write failed
-.br
-#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10)
-.br
-#define PI_NOT_HALTED -62 // DEPRECATED
-.br
-#define PI_SCRIPT_NOT_READY -62 // script initialising
-.br
-#define PI_BAD_TAG -63 // script has unresolved tag
-.br
-#define PI_BAD_MICS_DELAY -64 // bad MICS delay (too large)
-.br
-#define PI_BAD_MILS_DELAY -65 // bad MILS delay (too large)
-.br
-#define PI_BAD_WAVE_ID -66 // non existent wave id
-.br
-#define PI_TOO_MANY_CBS -67 // No more CBs for waveform
-.br
-#define PI_TOO_MANY_OOL -68 // No more OOL for waveform
-.br
-#define PI_EMPTY_WAVEFORM -69 // attempt to create an empty waveform
-.br
-#define PI_NO_WAVEFORM_ID -70 // no more waveforms
-.br
-#define PI_I2C_OPEN_FAILED -71 // can't open I2C device
-.br
-#define PI_SER_OPEN_FAILED -72 // can't open serial device
-.br
-#define PI_SPI_OPEN_FAILED -73 // can't open SPI device
-.br
-#define PI_BAD_I2C_BUS -74 // bad I2C bus
-.br
-#define PI_BAD_I2C_ADDR -75 // bad I2C address
-.br
-#define PI_BAD_SPI_CHANNEL -76 // bad SPI channel
-.br
-#define PI_BAD_FLAGS -77 // bad i2c/spi/ser open flags
-.br
-#define PI_BAD_SPI_SPEED -78 // bad SPI speed
-.br
-#define PI_BAD_SER_DEVICE -79 // bad serial device name
-.br
-#define PI_BAD_SER_SPEED -80 // bad serial baud rate
-.br
-#define PI_BAD_PARAM -81 // bad i2c/spi/ser parameter
-.br
-#define PI_I2C_WRITE_FAILED -82 // i2c write failed
-.br
-#define PI_I2C_READ_FAILED -83 // i2c read failed
-.br
-#define PI_BAD_SPI_COUNT -84 // bad SPI count
-.br
-#define PI_SER_WRITE_FAILED -85 // ser write failed
-.br
-#define PI_SER_READ_FAILED -86 // ser read failed
-.br
-#define PI_SER_READ_NO_DATA -87 // ser read no data available
-.br
-#define PI_UNKNOWN_COMMAND -88 // unknown command
-.br
-#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed
-.br
-#define PI_BAD_POINTER -90 // bad (NULL) pointer
-.br
-#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
-.br
-#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
-.br
-#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
-.br
-#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
-.br
-#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
-.br
-#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
-.br
-#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
-.br
-#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
-.br
-#define PI_BAD_HCLK_PASS -99 // need password to use hardware clock 1
-.br
-#define PI_HPWM_ILLEGAL -100 // illegal, PWM in use for main clock
-.br
-#define PI_BAD_DATABITS -101 // serial data bits not 1-32
-.br
-#define PI_BAD_STOPBITS -102 // serial (half) stop bits not 2-8
-.br
-#define PI_MSG_TOOBIG -103 // socket/pipe message too big
-.br
-#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode
-.br
-#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments
-.br
-#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed
-.br
-#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
-.br
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
-.br
-#define PI_BAD_I2C_WLEN -109 // bad I2C write length
-.br
-#define PI_BAD_I2C_RLEN -110 // bad I2C read length
-.br
-#define PI_BAD_I2C_CMD -111 // bad I2C command
-.br
-#define PI_BAD_I2C_BAUD -112 // bad I2C baud rate, not 50-500k
-.br
-#define PI_CHAIN_LOOP_CNT -113 // bad chain loop count
-.br
-#define PI_BAD_CHAIN_LOOP -114 // empty chain loop
-.br
-#define PI_CHAIN_COUNTER -115 // too many chain counters
-.br
-#define PI_BAD_CHAIN_CMD -116 // bad chain command
-.br
-#define PI_BAD_CHAIN_DELAY -117 // bad chain delay micros
-.br
-#define PI_CHAIN_NESTING -118 // chain counters nested too deeply
-.br
-#define PI_CHAIN_TOO_BIG -119 // chain is too long
-.br
-#define PI_DEPRECATED -120 // deprecated function removed
-.br
-#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
-.br
-#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2
-.br
-#define PI_BAD_ISR_INIT -123 // bad ISR initialisation
-.br
-#define PI_BAD_FOREVER -124 // loop forever must be last command
-.br
-#define PI_BAD_FILTER -125 // bad filter parameter
-.br
-#define PI_BAD_PAD -126 // bad pad number
-.br
-#define PI_BAD_STRENGTH -127 // bad pad drive strength
-.br
-#define PI_FIL_OPEN_FAILED -128 // file open failed
-.br
-#define PI_BAD_FILE_MODE -129 // bad file mode
-.br
-#define PI_BAD_FILE_FLAG -130 // bad file flag
-.br
-#define PI_BAD_FILE_READ -131 // bad file read
-.br
-#define PI_BAD_FILE_WRITE -132 // bad file write
-.br
-#define PI_FILE_NOT_ROPEN -133 // file not open for read
-.br
-#define PI_FILE_NOT_WOPEN -134 // file not open for write
-.br
-#define PI_BAD_FILE_SEEK -135 // bad file seek
-.br
-#define PI_NO_FILE_MATCH -136 // no files match pattern
-.br
-#define PI_NO_FILE_ACCESS -137 // no permission to access file
-.br
-#define PI_FILE_IS_A_DIR -138 // file is a directory
-.br
-#define PI_BAD_SHELL_STATUS -139 // bad shell return status
-.br
-#define PI_BAD_SCRIPT_NAME -140 // bad script name
-.br
-#define PI_BAD_SPI_BAUD -141 // bad SPI baud rate, not 50-500k
-.br
-#define PI_NOT_SPI_GPIO -142 // no bit bang SPI in progress on GPIO
-.br
-
-.br
-#define PI_PIGIF_ERR_0 -2000
-.br
-#define PI_PIGIF_ERR_99 -2099
-.br
-
-.br
-#define PI_CUSTOM_ERR_0 -3000
-.br
-#define PI_CUSTOM_ERR_999 -3999
-.br
-
-.br
-
-.EE
-.SH Defaults
-
-.EX
-
-.br
-#define PI_DEFAULT_BUFFER_MILLIS 120
-.br
-#define PI_DEFAULT_CLK_MICROS 5
-.br
-#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
-.br
-#define PI_DEFAULT_IF_FLAGS 0
-.br
-#define PI_DEFAULT_DMA_CHANNEL 14
-.br
-#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
-.br
-#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
-.br
-#define PI_DEFAULT_SOCKET_PORT 8888
-.br
-#define PI_DEFAULT_SOCKET_PORT_STR "8888"
-.br
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
-.br
-#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
-.br
-#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
-.br
-#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
-.br
-#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
-.br
-#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
-.br
-#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
-.br
-#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
-.br
-#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
-.br
-#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
-.br
-
-.br
-#define PI_DEFAULT_CFG_INTERNALS 0
-.br
-
-.br
-
-.EE
-
-.SH SEE ALSO
-
-pigpiod(1), pig2vcd(1), pigs(1), pigpiod_if(3), pigpiod_if2(3)
-.SH AUTHOR
-
-joan@abyz.co.uk
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.c b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.c
deleted file mode 100644
index 4ad429b4d..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.c
+++ /dev/null
@@ -1,12934 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-/* pigpio version 56 */
-
-/* include ------------------------------------------------------- */
-
-#define _GNU_SOURCE
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "pigpio.h"
-
-#include "command.h"
-
-
-/* --------------------------------------------------------------- */
-
-/*
- 0 GPFSEL0 GPIO Function Select 0
- 1 GPFSEL1 GPIO Function Select 1
- 2 GPFSEL2 GPIO Function Select 2
- 3 GPFSEL3 GPIO Function Select 3
- 4 GPFSEL4 GPIO Function Select 4
- 5 GPFSEL5 GPIO Function Select 5
- 6 - Reserved
- 7 GPSET0 GPIO Pin Output Set 0
- 8 GPSET1 GPIO Pin Output Set 1
- 9 - Reserved
-10 GPCLR0 GPIO Pin Output Clear 0
-11 GPCLR1 GPIO Pin Output Clear 1
-12 - Reserved
-13 GPLEV0 GPIO Pin Level 0
-14 GPLEV1 GPIO Pin Level 1
-15 - Reserved
-16 GPEDS0 GPIO Pin Event Detect Status 0
-17 GPEDS1 GPIO Pin Event Detect Status 1
-18 - Reserved
-19 GPREN0 GPIO Pin Rising Edge Detect Enable 0
-20 GPREN1 GPIO Pin Rising Edge Detect Enable 1
-21 - Reserved
-22 GPFEN0 GPIO Pin Falling Edge Detect Enable 0
-23 GPFEN1 GPIO Pin Falling Edge Detect Enable 1
-24 - Reserved
-25 GPHEN0 GPIO Pin High Detect Enable 0
-26 GPHEN1 GPIO Pin High Detect Enable 1
-27 - Reserved
-28 GPLEN0 GPIO Pin Low Detect Enable 0
-29 GPLEN1 GPIO Pin Low Detect Enable 1
-30 - Reserved
-31 GPAREN0 GPIO Pin Async. Rising Edge Detect 0
-32 GPAREN1 GPIO Pin Async. Rising Edge Detect 1
-33 - Reserved
-34 GPAFEN0 GPIO Pin Async. Falling Edge Detect 0
-35 GPAFEN1 GPIO Pin Async. Falling Edge Detect 1
-36 - Reserved
-37 GPPUD GPIO Pin Pull-up/down Enable
-38 GPPUDCLK0 GPIO Pin Pull-up/down Enable Clock 0
-39 GPPUDCLK1 GPIO Pin Pull-up/down Enable Clock 1
-40 - Reserved
-41 - Test
-*/
-
-/*
-0 CS DMA Channel 0 Control and Status
-1 CPI_ONBLK_AD DMA Channel 0 Control Block Address
-2 TI DMA Channel 0 CB Word 0 (Transfer Information)
-3 SOURCE_AD DMA Channel 0 CB Word 1 (Source Address)
-4 DEST_AD DMA Channel 0 CB Word 2 (Destination Address)
-5 TXFR_LEN DMA Channel 0 CB Word 3 (Transfer Length)
-6 STRIDE DMA Channel 0 CB Word 4 (2D Stride)
-7 NEXTCPI_ONBK DMA Channel 0 CB Word 5 (Next CB Address)
-8 DEBUG DMA Channel 0 Debug
-*/
-
-/*
-DEBUG register bits
-
-bit 2 READ_ERROR
-
- Slave Read Response Error RW 0x0
-
- Set if the read operation returned an error value on
- the read response bus. It can be cleared by writing
- a 1.
-
-bit 1 FIFO_ERROR
-
- Fifo Error RW 0x0
-
- Set if the optional read Fifo records an error
- condition. It can be cleared by writing a 1.
-
-bit 0 READ_LAST_NOT_SET_ERROR
-
- Read Last Not Set Error RW 0x0
-
- If the AXI read last signal was not set when
- expected, then this error bit will be set. It can be
- cleared by writing a 1.
-*/
-
-/*
-0 CTL PWM Control
-1 STA PWM Status
-2 DMAC PWM DMA Configuration
-4 RNG1 PWM Channel 1 Range
-5 DAT1 PWM Channel 1 Data
-6 FIF1 PWM FIFO Input
-8 RNG2 PWM Channel 2 Range
-9 DAT2 PWM Channel 2 Data
-*/
-
-/*
-0 PCM_CS PCM Control and Status
-1 PCM_FIFO PCM FIFO Data
-2 PCM_MODE PCM Mode
-3 PCM_RXC PCM Receive Configuration
-4 PCM_TXC PCM Transmit Configuration
-5 PCM_DREQ PCM DMA Request Level
-6 PCM_INTEN PCM Interrupt Enables
-7 PCM_INTSTC PCM Interrupt Status & Clear
-8 PCM_GRAY PCM Gray Mode Control
-*/
-
-/*
-0 CS System Timer Control/Status
-1 CLO System Timer Counter Lower 32 bits
-2 CHI System Timer Counter Higher 32 bits
-3 C0 System Timer Compare 0
-4 C1 System Timer Compare 1
-5 C2 System Timer Compare 2
-6 C3 System Timer Compare 3
-*/
-
-/* define -------------------------------------------------------- */
-
-#define THOUSAND 1000
-#define MILLION 1000000
-#define BILLION 1000000000
-
-#define BANK (gpio>>5)
-
-#define BIT (1<<(gpio&0x1F))
-
-#ifndef EMBEDDED_IN_VM
-#define DBG(level, format, arg...) DO_DBG(level, format, ## arg)
-#else
-#define DBG(level, format, arg...)
-#endif
-
-#define DO_DBG(level, format, arg...) \
- { \
- if (gpioCfg.dbgLevel >= level) \
- fprintf(stderr, "%s %s: " format "\n" , \
- myTimeStamp(), __FUNCTION__ , ## arg); \
- }
-
-#ifndef DISABLE_SER_CHECK_INITED
-#define SER_CHECK_INITED CHECK_INITED
-#else
-#define SER_CHECK_INITED
-#endif
-
-#define CHECK_INITED \
- do \
- { \
- if (!libInitialised) \
- { \
- DBG(DBG_ALWAYS, \
- "pigpio uninitialised, call gpioInitialise()"); \
- return PI_NOT_INITIALISED; \
- } \
- } \
- while (0)
-
-#define CHECK_INITED_RET_NULL_PTR \
- do \
- { \
- if (!libInitialised) \
- { \
- DBG(DBG_ALWAYS, \
- "pigpio uninitialised, call gpioInitialise()"); \
- return (NULL); \
- } \
- } \
- while (0)
-
-#define CHECK_INITED_RET_NIL \
- do \
- { \
- if (!libInitialised) \
- { \
- DBG(DBG_ALWAYS, \
- "pigpio uninitialised, call gpioInitialise()"); \
- } \
- } \
- while (0)
-
-#define CHECK_NOT_INITED \
- do \
- { \
- if (libInitialised) \
- { \
- DBG(DBG_ALWAYS, \
- "pigpio initialised, call gpioTerminate()"); \
- return PI_INITIALISED; \
- } \
- } \
- while (0)
-
-#define SOFT_ERROR(x, format, arg...) \
- do \
- { \
- DBG(DBG_ALWAYS, format, ## arg); \
- return x; \
- } \
- while (0)
-
-#define TIMER_ADD(a, b, result) \
- do \
- { \
- (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
- (result)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \
- if ((result)->tv_nsec >= BILLION) \
- { \
- ++(result)->tv_sec; \
- (result)->tv_nsec -= BILLION; \
- } \
- } \
- while (0)
-
-#define TIMER_SUB(a, b, result) \
- do \
- { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_nsec = (a)->tv_nsec - (b)->tv_nsec; \
- if ((result)->tv_nsec < 0) \
- { \
- --(result)->tv_sec; \
- (result)->tv_nsec += BILLION; \
- } \
- } \
- while (0)
-
-#define PI_PERI_BUS 0x7E000000
-
-#define AUX_BASE (pi_peri_phys + 0x00215000)
-#define CLK_BASE (pi_peri_phys + 0x00101000)
-#define DMA_BASE (pi_peri_phys + 0x00007000)
-#define DMA15_BASE (pi_peri_phys + 0x00E05000)
-#define GPIO_BASE (pi_peri_phys + 0x00200000)
-#define PADS_BASE (pi_peri_phys + 0x00100000)
-#define PCM_BASE (pi_peri_phys + 0x00203000)
-#define PWM_BASE (pi_peri_phys + 0x0020C000)
-#define SPI_BASE (pi_peri_phys + 0x00204000)
-#define SYST_BASE (pi_peri_phys + 0x00003000)
-
-#define AUX_LEN 0xD8
-#define CLK_LEN 0xA8
-#define DMA_LEN 0x1000 /* allow access to all channels */
-#define GPIO_LEN 0xB4
-#define PADS_LEN 0x38
-#define PCM_LEN 0x24
-#define PWM_LEN 0x28
-#define SPI_LEN 0x18
-#define SYST_LEN 0x1C
-
-#define DMA_ENABLE (0xFF0/4)
-
-#define GPFSEL0 0
-
-#define GPSET0 7
-#define GPSET1 8
-
-#define GPCLR0 10
-#define GPCLR1 11
-
-#define GPLEV0 13
-#define GPLEV1 14
-
-#define GPEDS0 16
-#define GPEDS1 17
-
-#define GPREN0 19
-#define GPREN1 20
-#define GPFEN0 22
-#define GPFEN1 23
-#define GPHEN0 25
-#define GPHEN1 26
-#define GPLEN0 28
-#define GPLEN1 29
-#define GPAREN0 31
-#define GPAREN1 32
-#define GPAFEN0 34
-#define GPAFEN1 35
-
-#define GPPUD 37
-#define GPPUDCLK0 38
-#define GPPUDCLK1 39
-
-#define DMA_CS 0
-#define DMA_CONBLK_AD 1
-#define DMA_DEBUG 8
-
-/* DMA CS Control and Status bits */
-#define DMA_CHANNEL_RESET (1<<31)
-#define DMA_WAIT_ON_WRITES (1<<28)
-#define DMA_PANIC_PRIORITY(x) ((x)<<20)
-#define DMA_PRIORITY(x) ((x)<<16)
-#define DMA_INTERRUPT_STATUS (1<< 2)
-#define DMA_END_FLAG (1<< 1)
-#define DMA_ACTIVATE (1<< 0)
-
-/* DMA control block "info" field bits */
-#define DMA_NO_WIDE_BURSTS (1<<26)
-#define DMA_PERIPHERAL_MAPPING(x) ((x)<<16)
-#define DMA_BURST_LENGTH(x) ((x)<<12)
-#define DMA_SRC_IGNORE (1<<11)
-#define DMA_SRC_DREQ (1<<10)
-#define DMA_SRC_WIDTH (1<< 9)
-#define DMA_SRC_INC (1<< 8)
-#define DMA_DEST_IGNORE (1<< 7)
-#define DMA_DEST_DREQ (1<< 6)
-#define DMA_DEST_WIDTH (1<< 5)
-#define DMA_DEST_INC (1<< 4)
-#define DMA_WAIT_RESP (1<< 3)
-
-#define DMA_DEBUG_READ_ERR (1<<2)
-#define DMA_DEBUG_FIFO_ERR (1<<1)
-#define DMA_DEBUG_RD_LST_NOT_SET_ERR (1<<0)
-
-#define DMA_LITE_FIRST 7
-#define DMA_LITE_MAX 0xfffc
-
-#define PWM_CTL 0
-#define PWM_STA 1
-#define PWM_DMAC 2
-#define PWM_RNG1 4
-#define PWM_DAT1 5
-#define PWM_FIFO 6
-#define PWM_RNG2 8
-#define PWM_DAT2 9
-
-#define PWM_CTL_MSEN2 (1<<15)
-#define PWM_CTL_PWEN2 (1<<8)
-#define PWM_CTL_MSEN1 (1<<7)
-#define PWM_CTL_CLRF1 (1<<6)
-#define PWM_CTL_USEF1 (1<<5)
-#define PWM_CTL_MODE1 (1<<1)
-#define PWM_CTL_PWEN1 (1<<0)
-
-#define PWM_DMAC_ENAB (1 <<31)
-#define PWM_DMAC_PANIC(x) ((x)<< 8)
-#define PWM_DMAC_DREQ(x) (x)
-
-#define PCM_CS 0
-#define PCM_FIFO 1
-#define PCM_MODE 2
-#define PCM_RXC 3
-#define PCM_TXC 4
-#define PCM_DREQ 5
-#define PCM_INTEN 6
-#define PCM_INTSTC 7
-#define PCM_GRAY 8
-
-#define PCM_CS_STBY (1 <<25)
-#define PCM_CS_SYNC (1 <<24)
-#define PCM_CS_RXSEX (1 <<23)
-#define PCM_CS_RXERR (1 <<16)
-#define PCM_CS_TXERR (1 <<15)
-#define PCM_CS_DMAEN (1 <<9)
-#define PCM_CS_RXTHR(x) ((x)<<7)
-#define PCM_CS_TXTHR(x) ((x)<<5)
-#define PCM_CS_RXCLR (1 <<4)
-#define PCM_CS_TXCLR (1 <<3)
-#define PCM_CS_TXON (1 <<2)
-#define PCM_CS_RXON (1 <<1)
-#define PCM_CS_EN (1 <<0)
-
-#define PCM_MODE_CLK_DIS (1 <<28)
-#define PCM_MODE_PDMN (1 <<27)
-#define PCM_MODE_PDME (1 <<26)
-#define PCM_MODE_FRXP (1 <<25)
-#define PCM_MODE_FTXP (1 <<24)
-#define PCM_MODE_CLKM (1 <<23)
-#define PCM_MODE_CLKI (1 <<22)
-#define PCM_MODE_FSM (1 <<21)
-#define PCM_MODE_FSI (1 <<20)
-#define PCM_MODE_FLEN(x) ((x)<<10)
-#define PCM_MODE_FSLEN(x) ((x)<< 0)
-
-#define PCM_RXC_CH1WEX (1 <<31)
-#define PCM_RXC_CH1EN (1 <<30)
-#define PCM_RXC_CH1POS(x) ((x)<<20)
-#define PCM_RXC_CH1WID(x) ((x)<<16)
-#define PCM_RXC_CH2WEX (1 <<15)
-#define PCM_RXC_CH2EN (1 <<14)
-#define PCM_RXC_CH2POS(x) ((x)<< 4)
-#define PCM_RXC_CH2WID(x) ((x)<< 0)
-
-#define PCM_TXC_CH1WEX (1 <<31)
-#define PCM_TXC_CH1EN (1 <<30)
-#define PCM_TXC_CH1POS(x) ((x)<<20)
-#define PCM_TXC_CH1WID(x) ((x)<<16)
-#define PCM_TXC_CH2WEX (1 <<15)
-#define PCM_TXC_CH2EN (1 <<14)
-#define PCM_TXC_CH2POS(x) ((x)<< 4)
-#define PCM_TXC_CH2WID(x) ((x)<< 0)
-
-#define PCM_DREQ_TX_PANIC(x) ((x)<<24)
-#define PCM_DREQ_RX_PANIC(x) ((x)<<16)
-#define PCM_DREQ_TX_REQ_L(x) ((x)<< 8)
-#define PCM_DREQ_RX_REQ_L(x) ((x)<< 0)
-
-#define PCM_INTEN_RXERR (1<<3)
-#define PCM_INTEN_TXERR (1<<2)
-#define PCM_INTEN_RXR (1<<1)
-#define PCM_INTEN_TXW (1<<0)
-
-#define PCM_INTSTC_RXERR (1<<3)
-#define PCM_INTSTC_TXERR (1<<2)
-#define PCM_INTSTC_RXR (1<<1)
-#define PCM_INTSTC_TXW (1<<0)
-
-#define PCM_GRAY_FLUSH (1<<2)
-#define PCM_GRAY_CLR (1<<1)
-#define PCM_GRAY_EN (1<<0)
-
-#define BCM_PASSWD (0x5A<<24)
-
-#define CLK_CTL_MASH(x)((x)<<9)
-#define CLK_CTL_BUSY (1 <<7)
-#define CLK_CTL_KILL (1 <<5)
-#define CLK_CTL_ENAB (1 <<4)
-#define CLK_CTL_SRC(x) ((x)<<0)
-
-#define CLK_SRCS 2
-
-#define CLK_CTL_SRC_OSC 1
-#define CLK_CTL_SRC_PLLD 6
-
-#define CLK_OSC_FREQ 19200000
-#define CLK_PLLD_FREQ 500000000
-
-#define CLK_DIV_DIVI(x) ((x)<<12)
-#define CLK_DIV_DIVF(x) ((x)<< 0)
-
-#define CLK_GP0_CTL 28
-#define CLK_GP0_DIV 29
-#define CLK_GP1_CTL 30
-#define CLK_GP1_DIV 31
-#define CLK_GP2_CTL 32
-#define CLK_GP2_DIV 33
-
-#define CLK_PCMCTL 38
-#define CLK_PCMDIV 39
-
-#define CLK_PWMCTL 40
-#define CLK_PWMDIV 41
-
-#define SYST_CS 0
-#define SYST_CLO 1
-#define SYST_CHI 2
-
-/* SPI */
-
-#define SPI_CS 0
-#define SPI_FIFO 1
-#define SPI_CLK 2
-#define SPI_DLEN 3
-#define SPI_LTOH 4
-#define SPI_DC 5
-
-#define SPI_CS_LEN_LONG (1<<25)
-#define SPI_CS_DMA_LEN (1<<24)
-#define SPI_CS_CSPOLS(x) ((x)<<21)
-#define SPI_CS_RXF (1<<20)
-#define SPI_CS_RXR (1<<19)
-#define SPI_CS_TXD (1<<18)
-#define SPI_CS_RXD (1<<17)
-#define SPI_CS_DONE (1<<16)
-#define SPI_CS_LEN (1<<13)
-#define SPI_CS_REN (1<<12)
-#define SPI_CS_ADCS (1<<11)
-#define SPI_CS_INTR (1<<10)
-#define SPI_CS_INTD (1<<9)
-#define SPI_CS_DMAEN (1<<8)
-#define SPI_CS_TA (1<<7)
-#define SPI_CS_CSPOL(x) ((x)<<6)
-#define SPI_CS_CLEAR(x) ((x)<<4)
-#define SPI_CS_MODE(x) ((x)<<2)
-#define SPI_CS_CS(x) ((x)<<0)
-
-#define SPI_DC_RPANIC(x) ((x)<<24)
-#define SPI_DC_RDREQ(x) ((x)<<16)
-#define SPI_DC_TPANIC(x) ((x)<<8)
-#define SPI_DC_TDREQ(x) ((x)<<0)
-
-#define SPI_MODE0 0
-#define SPI_MODE1 1
-#define SPI_MODE2 2
-#define SPI_MODE3 3
-
-#define SPI_CS0 0
-#define SPI_CS1 1
-#define SPI_CS2 2
-
-/* standard SPI gpios (ALT0) */
-
-#define PI_SPI_CE0 8
-#define PI_SPI_CE1 7
-#define PI_SPI_SCLK 11
-#define PI_SPI_MISO 9
-#define PI_SPI_MOSI 10
-
-/* auxiliary SPI gpios (ALT4) */
-
-#define PI_ASPI_CE0 18
-#define PI_ASPI_CE1 17
-#define PI_ASPI_CE2 16
-#define PI_ASPI_MISO 19
-#define PI_ASPI_MOSI 20
-#define PI_ASPI_SCLK 21
-
-/* AUX */
-
-#define AUX_IRQ 0
-#define AUX_ENABLES 1
-
-#define AUX_MU_IO_REG 16
-#define AUX_MU_IER_REG 17
-#define AUX_MU_IIR_REG 18
-#define AUX_MU_LCR_REG 19
-#define AUX_MU_MCR_REG 20
-#define AUX_MU_LSR_REG 21
-#define AUX_MU_MSR_REG 22
-#define AUX_MU_SCRATCH 23
-#define AUX_MU_CNTL_REG 24
-#define AUX_MU_STAT_REG 25
-#define AUX_MU_BAUD_REG 26
-
-#define AUX_SPI0_CNTL0_REG 32
-#define AUX_SPI0_CNTL1_REG 33
-#define AUX_SPI0_STAT_REG 34
-#define AUX_SPI0_PEEK_REG 35
-
-#define AUX_SPI0_IO_REG 40
-#define AUX_SPI0_TX_HOLD 44
-
-#define AUX_SPI1_CNTL0_REG 48
-#define AUX_SPI1_CNTL1_REG 49
-#define AUX_SPI1_STAT_REG 50
-#define AUX_SPI1_PEEK_REG 51
-
-#define AUX_SPI1_IO_REG 56
-#define AUX_SPI1_TX_HOLD 60
-
-#define AUXENB_SPI2 (1<<2)
-#define AUXENB_SPI1 (1<<1)
-#define AUXENB_UART (1<<0)
-
-#define AUXSPI_CNTL0_SPEED(x) ((x)<<20)
-#define AUXSPI_CNTL0_CS(x) ((x)<<17)
-#define AUXSPI_CNTL0_POSTINP (1<<16)
-#define AUXSPI_CNTL0_VAR_CS (1<<15)
-#define AUXSPI_CNTL0_VAR_WIDTH (1<<14)
-#define AUXSPI_CNTL0_DOUT_HOLD(x) ((x)<<12)
-#define AUXSPI_CNTL0_ENABLE (1<<11)
-#define AUXSPI_CNTL0_IN_RISING(x) ((x)<<10)
-#define AUXSPI_CNTL0_CLR_FIFOS (1<<9)
-#define AUXSPI_CNTL0_OUT_RISING(x) ((x)<<8)
-#define AUXSPI_CNTL0_INVERT_CLK(x) ((x)<<7)
-#define AUXSPI_CNTL0_MSB_FIRST(x) ((x)<<6)
-#define AUXSPI_CNTL0_SHIFT_LEN(x) ((x)<<0)
-
-#define AUXSPI_CNTL1_CS_HIGH(x) ((x)<<8)
-#define AUXSPI_CNTL1_TX_IRQ (1<<7)
-#define AUXSPI_CNTL1_DONE_IRQ (1<<6)
-#define AUXSPI_CNTL1_MSB_FIRST(x)((x)<<1)
-#define AUXSPI_CNTL1_KEEP_INPUT (1<<0)
-
-#define AUXSPI_STAT_TX_FIFO(x) ((x)<<28)
-#define AUXSPI_STAT_RX_FIFO(x) ((x)<<20)
-#define AUXSPI_STAT_TX_FULL (1<<10)
-#define AUXSPI_STAT_TX_EMPTY (1<<9)
-#define AUXSPI_STAT_RX_EMPTY (1<<7)
-#define AUXSPI_STAT_BUSY (1<<6)
-#define AUXSPI_STAT_BITS(x) ((x)<<0)
-
-/* --------------------------------------------------------------- */
-
-#define NORMAL_DMA (DMA_NO_WIDE_BURSTS | DMA_WAIT_RESP)
-
-#define TIMED_DMA(x) (DMA_DEST_DREQ | DMA_PERIPHERAL_MAPPING(x))
-
-#define PCM_TIMER (((PCM_BASE + PCM_FIFO*4) & 0x00ffffff) | PI_PERI_BUS)
-#define PWM_TIMER (((PWM_BASE + PWM_FIFO*4) & 0x00ffffff) | PI_PERI_BUS)
-
-#define DBG_MIN_LEVEL 0
-#define DBG_ALWAYS 0
-#define DBG_STARTUP 1
-#define DBG_DMACBS 2
-#define DBG_SCRIPT 3
-#define DBG_USER 4
-#define DBG_INTERNAL 5
-#define DBG_SLOW_TICK 6
-#define DBG_FAST_TICK 7
-#define DBG_MAX_LEVEL 8
-
-#define GPIO_UNDEFINED 0
-#define GPIO_WRITE 1
-#define GPIO_PWM 2
-#define GPIO_SERVO 3
-#define GPIO_HW_CLK 4
-#define GPIO_HW_PWM 5
-#define GPIO_SPI 6
-#define GPIO_I2C 7
-
-#define STACK_SIZE (256*1024)
-
-#define PAGE_SIZE 4096
-
-#define PWM_FREQS 18
-
-#define CYCLES_PER_BLOCK 80
-#define PULSE_PER_CYCLE 25
-
-#define PAGES_PER_BLOCK 53
-
-#define CBS_PER_IPAGE 117
-#define LVS_PER_IPAGE 38
-#define OFF_PER_IPAGE 38
-#define TCK_PER_IPAGE 2
-#define ON_PER_IPAGE 2
-#define PAD_PER_IPAGE 7
-
-#define CBS_PER_OPAGE 118
-#define OOL_PER_OPAGE 79
-
-/*
-Wave Count Block
-
-Assumes two counters per block. Each counter 4 * 16 (16^4=65536)
- 0 CB [13] 13*8 104 CBs for counter 0
- 104 CB [13] 13*8 104 CBs for counter 1
- 208 CB [60] 60*8 480 CBs reserved to construct wave
- 688 OOL [60] 60*1 60 OOL reserved to construct wave
- 748 OOL[136] 136*1 136 OOL for counter 0
- 884 OOL[136] 136*1 136 OOL for counter 1
-1020 pad [4] 4*1 4 spare
-*/
-
-#define WCB_CNT_PER_PAGE 2
-#define WCB_COUNTERS (WCB_CNT_PER_PAGE * PI_WAVE_COUNT_PAGES)
-#define WCB_CNT_CBS 13
-#define WCB_CNT_OOL 68
-#define WCB_COUNTER_OOL (WCB_CNT_PER_PAGE * WCB_CNT_OOL)
-#define WCB_COUNTER_CBS (WCB_CNT_PER_PAGE * WCB_CNT_CBS)
-#define WCB_CHAIN_CBS 60
-#define WCB_CHAIN_OOL 60
-
-#define CBS_PER_CYCLE ((PULSE_PER_CYCLE*3)+2)
-
-#define NUM_CBS (CBS_PER_CYCLE * bufferCycles)
-
-#define SUPERCYCLE 800
-#define SUPERLEVEL 20000
-
-#define BLOCK_SIZE (PAGES_PER_BLOCK*PAGE_SIZE)
-
-#define DMAI_PAGES (PAGES_PER_BLOCK * bufferBlocks)
-
-#define DMAO_PAGES (PAGES_PER_BLOCK * PI_WAVE_BLOCKS)
-
-#define NUM_WAVE_OOL (DMAO_PAGES * OOL_PER_OPAGE)
-#define NUM_WAVE_CBS (DMAO_PAGES * CBS_PER_OPAGE)
-
-#define TICKSLOTS 50
-
-#define PI_I2C_CLOSED 0
-#define PI_I2C_OPENED 1
-
-#define PI_SPI_CLOSED 0
-#define PI_SPI_OPENED 1
-
-#define PI_SER_CLOSED 0
-#define PI_SER_OPENED 1
-
-#define PI_FILE_CLOSED 0
-#define PI_FILE_OPENED 1
-
-#define PI_NOTIFY_CLOSED 0
-#define PI_NOTIFY_CLOSING 1
-#define PI_NOTIFY_OPENED 2
-#define PI_NOTIFY_RUNNING 3
-#define PI_NOTIFY_PAUSED 4
-
-#define PI_WFRX_NONE 0
-#define PI_WFRX_SERIAL 1
-#define PI_WFRX_I2C_SDA 2
-#define PI_WFRX_I2C_SCL 3
-#define PI_WFRX_SPI_SCLK 4
-#define PI_WFRX_SPI_MISO 5
-#define PI_WFRX_SPI_MOSI 6
-#define PI_WFRX_SPI_CS 7
-
-#define PI_WF_MICROS 1
-
-#define BPD 4
-
-#define MAX_REPORT 120
-#define MAX_SAMPLE 4000
-
-#define DEFAULT_PWM_IDX 5
-
-#define MAX_EMITS (PIPE_BUF / sizeof(gpioReport_t))
-
-#define SRX_BUF_SIZE 8192
-
-#define PI_I2C_RETRIES 0x0701
-#define PI_I2C_TIMEOUT 0x0702
-#define PI_I2C_SLAVE 0x0703
-#define PI_I2C_FUNCS 0x0705
-#define PI_I2C_RDWR 0x0707
-#define PI_I2C_SMBUS 0x0720
-
-#define PI_I2C_SMBUS_READ 1
-#define PI_I2C_SMBUS_WRITE 0
-
-#define PI_I2C_SMBUS_QUICK 0
-#define PI_I2C_SMBUS_BYTE 1
-#define PI_I2C_SMBUS_BYTE_DATA 2
-#define PI_I2C_SMBUS_WORD_DATA 3
-#define PI_I2C_SMBUS_PROC_CALL 4
-#define PI_I2C_SMBUS_BLOCK_DATA 5
-#define PI_I2C_SMBUS_I2C_BLOCK_BROKEN 6
-#define PI_I2C_SMBUS_BLOCK_PROC_CALL 7
-#define PI_I2C_SMBUS_I2C_BLOCK_DATA 8
-
-#define PI_I2C_SMBUS_BLOCK_MAX 32
-#define PI_I2C_SMBUS_I2C_BLOCK_MAX 32
-
-#define PI_I2C_FUNC_SMBUS_QUICK 0x00010000
-#define PI_I2C_FUNC_SMBUS_READ_BYTE 0x00020000
-#define PI_I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000
-#define PI_I2C_FUNC_SMBUS_READ_BYTE_DATA 0x00080000
-#define PI_I2C_FUNC_SMBUS_WRITE_BYTE_DATA 0x00100000
-#define PI_I2C_FUNC_SMBUS_READ_WORD_DATA 0x00200000
-#define PI_I2C_FUNC_SMBUS_WRITE_WORD_DATA 0x00400000
-#define PI_I2C_FUNC_SMBUS_PROC_CALL 0x00800000
-#define PI_I2C_FUNC_SMBUS_READ_BLOCK_DATA 0x01000000
-#define PI_I2C_FUNC_SMBUS_WRITE_BLOCK_DATA 0x02000000
-#define PI_I2C_FUNC_SMBUS_READ_I2C_BLOCK 0x04000000
-#define PI_I2C_FUNC_SMBUS_WRITE_I2C_BLOCK 0x08000000
-
-#define PI_MASH_MAX_FREQ 23800000
-
-#define FLUSH_PAGES 1024
-
-#define MB_DEV_MAJOR 100
-
-#define MB_IOCTL _IOWR(MB_DEV_MAJOR, 0, char *)
-
-#define MB_DEV1 "/dev/vcio"
-#define MB_DEV2 "/dev/pigpio-mb"
-
-#define BUS_TO_PHYS(x) ((x)&~0xC0000000)
-
-#define MB_END_TAG 0
-#define MB_PROCESS_REQUEST 0
-
-#define MB_ALLOCATE_MEMORY_TAG 0x3000C
-#define MB_LOCK_MEMORY_TAG 0x3000D
-#define MB_UNLOCK_MEMORY_TAG 0x3000E
-#define MB_RELEASE_MEMORY_TAG 0x3000F
-
-#define PI_SCRIPT_FREE 0
-#define PI_SCRIPT_RESERVED 1
-#define PI_SCRIPT_IN_USE 2
-#define PI_SCRIPT_DYING 3
-
-#define PI_SCRIPT_HALT 0
-#define PI_SCRIPT_RUN 1
-#define PI_SCRIPT_DELETE 2
-
-#define PI_SCRIPT_STACK_SIZE 256
-
-#define PI_SPI_FLAGS_CHANNEL(x) ((x&7)<<29)
-
-#define PI_SPI_FLAGS_GET_CHANNEL(x) (((x)>>29)&7)
-#define PI_SPI_FLAGS_GET_BITLEN(x) (((x)>>16)&63)
-#define PI_SPI_FLAGS_GET_RX_LSB(x) (((x)>>15)&1)
-#define PI_SPI_FLAGS_GET_TX_LSB(x) (((x)>>14)&1)
-#define PI_SPI_FLAGS_GET_3WREN(x) (((x)>>10)&15)
-#define PI_SPI_FLAGS_GET_3WIRE(x) (((x)>>9)&1)
-#define PI_SPI_FLAGS_GET_AUX_SPI(x) (((x)>>8)&1)
-#define PI_SPI_FLAGS_GET_RESVD(x) (((x)>>5)&7)
-#define PI_SPI_FLAGS_GET_CSPOLS(x) (((x)>>2)&7)
-#define PI_SPI_FLAGS_GET_MODE(x) ((x)&3)
-
-#define PI_SPI_FLAGS_GET_CPHA(x) ((x)&1)
-#define PI_SPI_FLAGS_GET_CPOL(x) ((x)&2)
-#define PI_SPI_FLAGS_GET_CSPOL(x) ((x)&4)
-
-#define PI_STARTING 0
-#define PI_RUNNING 1
-#define PI_ENDING 2
-
-#define PI_MAX_PATH 512
-
-/* typedef ------------------------------------------------------- */
-
-typedef void (*callbk_t) ();
-
-typedef struct
-{
- rawCbs_t cb [128];
-} dmaPage_t;
-
-typedef struct
-{
- rawCbs_t cb [CBS_PER_IPAGE];
- uint32_t level [LVS_PER_IPAGE];
- uint32_t gpioOff [OFF_PER_IPAGE];
- uint32_t tick [TCK_PER_IPAGE];
- uint32_t gpioOn [ON_PER_IPAGE];
- uint32_t periphData;
- uint32_t pad [PAD_PER_IPAGE];
-} dmaIPage_t;
-
-typedef struct
-{
- rawCbs_t cb [CBS_PER_OPAGE];
- uint32_t OOL [OOL_PER_OPAGE];
- uint32_t periphData;
-} dmaOPage_t;
-
-typedef struct
-{
- uint8_t is;
- uint8_t pad;
- uint16_t width;
- uint16_t range; /* dutycycles specified by 0 .. range */
- uint16_t freqIdx;
-} gpioInfo_t;
-
-typedef struct
-{
- callbk_t func;
- unsigned ex;
- void *userdata;
-
- int wdSteadyUs;
- uint32_t wdTick;
- uint32_t wdLBitV;
-
- int nfSteadyUs;
- int nfActiveUs;
- int nfActive;
- uint32_t nfTick1;
- uint32_t nfTick2;
- uint32_t nfLBitV;
- uint32_t nfRBitV;
-
- uint32_t gfSteadyUs;
- uint32_t gfTick;
- uint32_t gfLBitV;
- uint32_t gfRBitV;
-
-} gpioAlert_t;
-
-typedef struct
-{
- unsigned gpio;
- pthread_t *pth;
- callbk_t func;
- unsigned edge;
- int timeout;
- unsigned ex;
- void *userdata;
- int inited;
-} gpioISR_t;
-
-typedef struct
-{
- callbk_t func;
- unsigned ex;
- void *userdata;
-} gpioSignal_t;
-
-typedef struct
-{
- callbk_t func;
- unsigned ex;
- void *userdata;
- uint32_t bits;
-} gpioGetSamples_t;
-
-typedef struct
-{
- callbk_t func;
- unsigned ex;
- void *userdata;
- unsigned id;
- unsigned running;
- unsigned millis;
- struct timespec nextTick;
- pthread_t pthId;
-} gpioTimer_t;
-
-typedef struct
-{
- unsigned id;
- unsigned state;
- unsigned request;
- unsigned run_state;
- uint32_t waitBits;
- uint32_t changedBits;
- pthread_t *pthIdp;
- pthread_mutex_t pthMutex;
- pthread_cond_t pthCond;
- cmdScript_t script;
-} gpioScript_t;
-
-
-typedef struct
-{
- uint16_t valid;
- uint16_t servoIdx;
-} clkCfg_t;
-
-typedef struct
-{
- uint16_t seqno;
- uint16_t state;
- uint32_t bits;
- uint32_t lastReportTick;
- int fd;
- int pipe;
- int max_emits;
-} gpioNotify_t;
-
-typedef struct
-{
- uint16_t state;
- int16_t fd;
- uint32_t mode;
-} fileInfo_t;
-
-typedef struct
-{
- uint16_t state;
- int16_t fd;
- uint32_t addr;
- uint32_t flags;
- uint32_t funcs;
-} i2cInfo_t;
-
-typedef struct
-{
- uint16_t state;
- int16_t fd;
- uint32_t flags;
-} serInfo_t;
-
-typedef struct
-{
- uint16_t state;
- unsigned speed;
- uint32_t flags;
-} spiInfo_t;
-
-typedef struct
-{
- uint32_t alertTicks;
- uint32_t lateTicks;
- uint32_t moreToDo;
- uint32_t diffTick[TICKSLOTS];
- uint32_t cbTicks;
- uint32_t cbCalls;
- uint32_t maxEmit;
- uint32_t emitFrags;
- uint32_t maxSamples;
- uint32_t numSamples;
- uint32_t DMARestarts;
- uint32_t dmaInitCbsCount;
- uint32_t goodPipeWrite;
- uint32_t shortPipeWrite;
- uint32_t wouldBlockPipeWrite;
-} gpioStats_t;
-
-typedef struct
-{
- unsigned bufferMilliseconds;
- unsigned clockMicros;
- unsigned clockPeriph;
- unsigned DMAprimaryChannel;
- unsigned DMAsecondaryChannel;
- unsigned socketPort;
- unsigned ifFlags;
- unsigned memAllocMode;
- unsigned dbgLevel;
- unsigned alertFreq;
- uint32_t internals;
- /*
- 0-3: dbgLevel
- 4-7: alertFreq
- */
-} gpioCfg_t;
-
-typedef struct
-{
- uint32_t micros;
- uint32_t highMicros;
- uint32_t maxMicros;
- uint32_t pulses;
- uint32_t highPulses;
- uint32_t maxPulses;
- uint32_t cbs;
- uint32_t highCbs;
- uint32_t maxCbs;
-} wfStats_t;
-
-typedef struct
-{
- char *buf;
- uint32_t bufSize;
- int readPos;
- int writePos;
- uint32_t fullBit; /* nanoseconds */
- uint32_t halfBit; /* nanoseconds */
- int timeout; /* millisconds */
- uint32_t startBitTick; /* microseconds */
- uint32_t nextBitDiff; /* nanoseconds */
- int bit;
- uint32_t data;
- int bytes; /* 1, 2, 4 */
- int level;
- int dataBits; /* 1-32 */
- int invert; /* 0, 1 */
-} wfRxSerial_t;
-
-typedef struct
-{
- int SDA;
- int SCL;
- int delay;
- int SDAMode;
- int SCLMode;
- int started;
-} wfRxI2C_t;
-
-typedef struct
-{
- int CS;
- int MISO;
- int MOSI;
- int SCLK;
- int usage;
- int delay;
- int spiFlags;
- int MISOMode;
- int MOSIMode;
- int CSMode;
- int SCLKMode;
-} wfRxSPI_t;
-
-typedef struct
-{
- int mode;
- int gpio;
- uint32_t baud;
- pthread_mutex_t mutex;
- union
- {
- wfRxSerial_t s;
- wfRxI2C_t I;
- wfRxSPI_t S;
- };
-} wfRx_t;
-
-union my_smbus_data
-{
- uint8_t byte;
- uint16_t word;
- uint8_t block[PI_I2C_SMBUS_BLOCK_MAX + 2];
-};
-
-struct my_smbus_ioctl_data
-{
- uint8_t read_write;
- uint8_t command;
- uint32_t size;
- union my_smbus_data *data;
-};
-
-typedef struct
-{
- pi_i2c_msg_t *msgs; /* pointers to pi_i2c_msgs */
- uint32_t nmsgs; /* number of pi_i2c_msgs */
-} my_i2c_rdwr_ioctl_data_t;
-
-typedef struct
-{
- unsigned div;
- unsigned frac;
- unsigned clock;
-} clkInf_t;
-
-typedef struct
-{
- unsigned handle; /* mbAllocateMemory() */
- uintptr_t bus_addr; /* mbLockMemory() */
- uintptr_t *virtual_addr; /* mbMapMem() */
- unsigned size; /* in bytes */
-} DMAMem_t;
-
-/* global -------------------------------------------------------- */
-
-/* initialise once then preserve */
-
-static volatile uint32_t piCores = 0;
-static volatile uint32_t pi_peri_phys = 0x20000000;
-static volatile uint32_t pi_dram_bus = 0x40000000;
-static volatile uint32_t pi_mem_flag = 0x0C;
-
-static int libInitialised = 0;
-
-/* initialise every gpioInitialise */
-
-static struct timespec libStarted;
-
-static uint32_t sockNetAddr[MAX_CONNECT_ADDRESSES];
-
-static int numSockNetAddr = 0;
-
-static uint32_t reportedLevel = 0;
-
-static int waveClockInited = 0;
-static int PWMClockInited = 0;
-
-static volatile gpioStats_t gpioStats;
-
-static int gpioMaskSet = 0;
-
-/* initialise if not libInitialised */
-
-static uint64_t gpioMask;
-
-static rawWave_t wf[3][PI_WAVE_MAX_PULSES];
-
-static int wfc[3]={0, 0, 0};
-
-static int wfcur=0;
-
-static wfStats_t wfStats=
-{
- 0, 0, PI_WAVE_MAX_MICROS,
- 0, 0, PI_WAVE_MAX_PULSES,
- 0, 0, (DMAO_PAGES * CBS_PER_OPAGE)
-};
-
-static rawWaveInfo_t waveInfo[PI_MAX_WAVES];
-
-static wfRx_t wfRx[PI_MAX_USER_GPIO+1];
-
-static int waveOutBotCB = PI_WAVE_COUNT_PAGES*CBS_PER_OPAGE;
-static int waveOutBotOOL = PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE;
-static int waveOutTopOOL = NUM_WAVE_OOL;
-static int waveOutCount = 0;
-
-static uint32_t *waveEndPtr = NULL;
-
-static volatile uint32_t alertBits = 0;
-static volatile uint32_t monitorBits = 0;
-static volatile uint32_t notifyBits = 0;
-static volatile uint32_t scriptBits = 0;
-static volatile uint32_t gFilterBits = 0;
-static volatile uint32_t nFilterBits = 0;
-static volatile uint32_t wdogBits = 0;
-
-static volatile int runState = PI_STARTING;
-
-static int pthAlertRunning = 0;
-static int pthFifoRunning = 0;
-static int pthSocketRunning = 0;
-
-static gpioAlert_t gpioAlert [PI_MAX_USER_GPIO+1];
-
-static gpioISR_t gpioISR [PI_MAX_USER_GPIO+1];
-
-static gpioGetSamples_t gpioGetSamples;
-
-static gpioInfo_t gpioInfo [PI_MAX_GPIO+1];
-
-static gpioNotify_t gpioNotify [PI_NOTIFY_SLOTS];
-
-static fileInfo_t fileInfo [PI_FILE_SLOTS];
-static i2cInfo_t i2cInfo [PI_I2C_SLOTS];
-static serInfo_t serInfo [PI_SER_SLOTS];
-static spiInfo_t spiInfo [PI_SPI_SLOTS];
-
-static gpioScript_t gpioScript [PI_MAX_SCRIPTS];
-
-static gpioSignal_t gpioSignal [PI_MAX_SIGNUM+1];
-
-static gpioTimer_t gpioTimer [PI_MAX_TIMER+1];
-
-static int pwmFreq[PWM_FREQS];
-
-static pthread_mutex_t spi_main_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t spi_aux_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* reset after gpioTerminated */
-
-/* resources which must be released on gpioTerminate */
-
-static FILE * inpFifo = NULL;
-static FILE * outFifo = NULL;
-
-static int fdLock = -1;
-static int fdMem = -1;
-static int fdSock = -1;
-static int fdPmap = -1;
-static int fdMbox = -1;
-
-static DMAMem_t *dmaMboxBlk = MAP_FAILED;
-static uintptr_t * * dmaPMapBlk = MAP_FAILED;
-static dmaPage_t * * dmaVirt = MAP_FAILED;
-static dmaPage_t * * dmaBus = MAP_FAILED;
-
-static dmaIPage_t * * dmaIVirt = MAP_FAILED;
-static dmaIPage_t * * dmaIBus = MAP_FAILED;
-
-static dmaOPage_t * * dmaOVirt = MAP_FAILED;
-static dmaOPage_t * * dmaOBus = MAP_FAILED;
-
-static volatile uint32_t * auxReg = MAP_FAILED;
-static volatile uint32_t * clkReg = MAP_FAILED;
-static volatile uint32_t * dmaReg = MAP_FAILED;
-static volatile uint32_t * gpioReg = MAP_FAILED;
-static volatile uint32_t * padsReg = MAP_FAILED;
-static volatile uint32_t * pcmReg = MAP_FAILED;
-static volatile uint32_t * pwmReg = MAP_FAILED;
-static volatile uint32_t * spiReg = MAP_FAILED;
-static volatile uint32_t * systReg = MAP_FAILED;
-
-static volatile uint32_t * dmaIn = MAP_FAILED;
-static volatile uint32_t * dmaOut = MAP_FAILED;
-
-static uint32_t hw_clk_freq[3];
-static uint32_t hw_pwm_freq[2];
-static uint32_t hw_pwm_duty[2];
-static uint32_t hw_pwm_real_range[2];
-
-static volatile gpioCfg_t gpioCfg =
-{
- PI_DEFAULT_BUFFER_MILLIS,
- PI_DEFAULT_CLK_MICROS,
- PI_DEFAULT_CLK_PERIPHERAL,
- PI_DEFAULT_DMA_PRIMARY_CHANNEL,
- PI_DEFAULT_DMA_SECONDARY_CHANNEL,
- PI_DEFAULT_SOCKET_PORT,
- PI_DEFAULT_IF_FLAGS,
- PI_DEFAULT_MEM_ALLOC_MODE,
- 0, /* dbgLevel */
- 0, /* alertFreq */
- 0, /* internals */
-};
-
-/* no initialisation required */
-
-static unsigned bufferBlocks; /* number of blocks in buffer */
-static unsigned bufferCycles; /* number of cycles */
-
-static pthread_t pthAlert;
-static pthread_t pthFifo;
-static pthread_t pthSocket;
-
-static uint32_t spi_dummy;
-
-static unsigned old_mode_ce0;
-static unsigned old_mode_ce1;
-static unsigned old_mode_sclk;
-static unsigned old_mode_miso;
-static unsigned old_mode_mosi;
-
-static uint32_t old_spi_cs;
-static uint32_t old_spi_clk;
-
-static unsigned old_mode_ace0;
-static unsigned old_mode_ace1;
-static unsigned old_mode_ace2;
-static unsigned old_mode_asclk;
-static unsigned old_mode_amiso;
-static unsigned old_mode_amosi;
-
-static uint32_t old_spi_cntl0;
-static uint32_t old_spi_cntl1;
-
-/* const --------------------------------------------------------- */
-
-static const uint8_t clkDef[PI_MAX_GPIO + 1] =
-{
- /* 0 1 2 3 4 5 6 7 8 9 */
- /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x84, 0x94, 0xA4, 0x00, 0x00, 0x00,
- /* 1 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 2 */ 0x82, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 3 */ 0x00, 0x00, 0x84, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 4 */ 0x00, 0x00, 0x94, 0xA4, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 5 */ 0x00, 0x00, 0x00, 0x00,
-};
-
-/*
- 7 6 5 4 3 2 1 0
- V . C C . M M M
-
- V: 0 no clock, 1 has a clock
-CC: 00 CLK0, 01 CLK1, 10 CLK2
- M: 100 ALT0, 010 ALT5
-
- gpio4 GPCLK0 ALT0
- gpio5 GPCLK1 ALT0 B+ and compute module only (reserved for system use)
- gpio6 GPCLK2 ALT0 B+ and compute module only
- gpio20 GPCLK0 ALT5 B+ and compute module only
- gpio21 GPCLK1 ALT5 Not available on Rev.2 B (reserved for system use)
-
- gpio32 GPCLK0 ALT0 Compute module only
- gpio34 GPCLK0 ALT0 Compute module only
- gpio42 GPCLK1 ALT0 Compute module only (reserved for system use)
- gpio43 GPCLK2 ALT0 Compute module only
- gpio44 GPCLK1 ALT0 Compute module only (reserved for system use)
-*/
-
-static const uint8_t PWMDef[PI_MAX_GPIO + 1] =
-{
- /* 0 1 2 3 4 5 6 7 8 9 */
- /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 1 */ 0x00, 0x00, 0x84, 0x94, 0x00, 0x00, 0x00, 0x00, 0x82, 0x92,
- /* 2 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 3 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- /* 4 */ 0x84, 0x94, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x00,
- /* 5 */ 0x00, 0x00, 0x85, 0x95,
-};
-
-/*
- 7 6 5 4 3 2 1 0
- V . . P . M M M
-
- V: 0 no PWM, 1 has a PWM
- P: 0 PWM0, 1 PWM1
- M: 010 ALT5, 100 ALT0, 101 ALT1
-
- gpio12 pwm0 ALT0
- gpio13 pwm1 ALT0
- gpio18 pwm0 ALT5
- gpio19 pwm1 ALT5
- gpio40 pwm0 ALT0
- gpio41 pwm1 ALT0
- gpio45 pwm1 ALT0
- gpio52 pwm0 ALT1
- gpio53 pwm1 ALT1
-*/
-
-static const clkCfg_t clkCfg[]=
-{
- /* valid servo */
- { 0, 0}, /* 0 */
- { 1, 17}, /* 1 */
- { 1, 16}, /* 2 */
- { 0, 0}, /* 3 */
- { 1, 15}, /* 4 */
- { 1, 14}, /* 5 */
- { 0, 0}, /* 6 */
- { 0, 0}, /* 7 */
- { 1, 13}, /* 8 */
- { 0, 0}, /* 9 */
- { 1, 12}, /* 10 */
-};
-
-static const uint16_t pwmCycles[PWM_FREQS]=
- { 1, 2, 4, 5, 8, 10, 16, 20, 25,
- 32, 40, 50, 80, 100, 160, 200, 400, 800};
-
-static const uint16_t pwmRealRange[PWM_FREQS]=
- { 25, 50, 100, 125, 200, 250, 400, 500, 625,
- 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000};
-
-/* prototype ----------------------------------------------------- */
-
-static void intNotifyBits(void);
-
-static void intScriptBits(void);
-
-static int gpioNotifyOpenInBand(int fd);
-
-static void initHWClk
- (int clkCtl, int clkDiv, int clkSrc, int divI, int divF, int MASH);
-
-static void initDMAgo(volatile uint32_t *dmaAddr, uint32_t cbAddr);
-
-int gpioWaveTxStart(unsigned wave_mode); /* deprecated */
-
-static void closeOrphanedNotifications(int slot, int fd);
-
-
-/* ======================================================================= */
-
-int myScriptNameValid(char *name)
-{
- int i, c, len, valid;
-
- len = strlen(name);
-
- valid = 1;
-
- for (i=0; i 40) c = 40; else c = count;
-
- for (i=0; ibyte+1, (char*)data));
-
- args.read_write = rw;
- args.command = cmd;
- args.size = size;
- args.data = data;
-
- return ioctl(fd, PI_I2C_SMBUS, &args);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void myGpioSetMode(unsigned gpio, unsigned mode)
-{
- int reg, shift;
-
- reg = gpio/10;
- shift = (gpio%10) * 3;
-
- gpioReg[reg] = (gpioReg[reg] & ~(7<level[slot];
-
- return level;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int myI2CGetPar(char *inBuf, int *inPos, int inLen, int *esc)
-{
- int bytes;
-
- if (*esc) bytes = 2; else bytes = 1;
-
- *esc = 0;
-
- if (*inPos <= (inLen - bytes))
- {
- if (bytes == 1)
- {
- return inBuf[(*inPos)++];
- }
- else
- {
- (*inPos) += 2;
- return inBuf[*inPos-2] + (inBuf[*inPos-1]<<8);
- }
- }
- return -1;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t myGetTick(int pos)
-{
- uint32_t tick;
- int page, slot;
-
- myTckPageSlot(pos, &page, &slot);
-
- tick = dmaIVirt[page]->tick[slot];
-
- return tick;
-}
-
-static int myPermit(unsigned gpio)
-{
- if (gpio <= PI_MAX_GPIO)
- {
- if (gpioMask & ((uint64_t)(1)<>32;
-
- res = gpioWrite_Bits_32_53_Clear(p[1]&mask);
-
- if ((mask | p[1]) != mask)
- {
- DBG(DBG_USER,
- "gpioWrite_Bits_32_53_Clear: bad bits %08X (permissions %08X)",
- p[1], mask);
- res = PI_SOME_PERMITTED;
- }
- break;
-
- case PI_CMD_BI2CC:
- res = bbI2CClose(p[1]);
- break;
-
- case PI_CMD_BI2CO:
- memcpy(&p[4], buf, 4);
- res = bbI2COpen(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_BI2CZ:
- /* use half buffer for write, half buffer for read */
- if (p[3] > (bufSize/2)) p[3] = bufSize/2;
- res = bbI2CZip(p[1], buf, p[3], buf+(bufSize/2), bufSize/2);
- if (res > 0)
- {
- memcpy(buf, buf+(bufSize/2), res);
- }
- break;
-
- case PI_CMD_BSPIO:
-
- memcpy(&tmp1, buf+ 0, 4); // MISO
- memcpy(&tmp2, buf+ 4, 4); // MOSI
- memcpy(&tmp3, buf+ 8, 4); // SCLK
- memcpy(&tmp4, buf+12, 4); // baud
- memcpy(&tmp5, buf+16, 4); // flags
-
- if (!myPermit(p[1]))
- {
- DBG(DBG_USER,
- "bbSPIOpen: gpio %d, no permission to update CS", p[1]);
- res = PI_NOT_PERMITTED;
- }
-
- if (!myPermit(tmp1))
- {
- DBG(DBG_USER,
- "bbSPIOpen: gpio %d, no permission to update MISO", tmp1);
- res = PI_NOT_PERMITTED;
- }
-
- if (!myPermit(tmp2))
- {
- DBG(DBG_USER,
- "bbSPIOpen: gpio %d, no permission to update MOSI", tmp2);
- res = PI_NOT_PERMITTED;
- }
-
- if (!myPermit(tmp3))
- {
- DBG(DBG_USER,
- "bbSPIOpen: gpio %d, no permission to update SCLK", tmp3);
- res = PI_NOT_PERMITTED;
- }
-
- if (!res) res = bbSPIOpen(p[1], tmp1, tmp2, tmp3, tmp4, tmp5);
- break;
-
- case PI_CMD_BSPIC:
- res = bbSPIClose(p[1]);
- break;
-
- case PI_CMD_BSPIX:
- if (p[3] > bufSize) p[3] = bufSize;
- res = bbSPIXfer(p[1], buf, buf, p[3]);
- break;
-
- case PI_CMD_BR1: res = gpioRead_Bits_0_31(); break;
-
- case PI_CMD_BR2: res = gpioRead_Bits_32_53(); break;
-
- case PI_CMD_BS1:
- mask = gpioMask;
-
- res = gpioWrite_Bits_0_31_Set(p[1]&mask);
-
- if ((mask | p[1]) != mask)
- {
- DBG(DBG_USER,
- "gpioWrite_Bits_0_31_Set: bad bits %08X (permissions %08X)",
- p[1], mask);
- res = PI_SOME_PERMITTED;
- }
- break;
-
- case PI_CMD_BS2:
- mask = gpioMask>>32;
-
- res = gpioWrite_Bits_32_53_Set(p[1]&mask);
-
- if ((mask | p[1]) != mask)
- {
- DBG(DBG_USER,
- "gpioWrite_Bits_32_53_Set: bad bits %08X (permissions %08X)",
- p[1], mask);
- res = PI_SOME_PERMITTED;
- }
- break;
-
- case PI_CMD_CF1:
- res = gpioCustom1(p[1], p[2], buf, p[3]);
- break;
-
- case PI_CMD_CF2:
- /* a couple of extra precautions for untrusted code */
- if (p[2] > bufSize) p[2] = bufSize;
- res = gpioCustom2(p[1], buf, p[3], buf, p[2]);
- if (res > p[2]) res = p[2];
- break;
-
- case PI_CMD_CGI: res = gpioCfgGetInternals(); break;
-
- case PI_CMD_CSI: res = gpioCfgSetInternals(p[1]); break;
-
- case PI_CMD_FC: res = fileClose(p[1]); break;
-
- case PI_CMD_FG:
- res = gpioGlitchFilter(p[1], p[2]);
- break;
-
- case PI_CMD_FL:
- if (p[1] > bufSize) p[1] = bufSize;
- res = fileList(buf, buf, p[1]);
- break;
-
- case PI_CMD_FN:
- memcpy(&p[4], buf, 4);
- res = gpioNoiseFilter(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_FO: res = fileOpen(buf, p[1]); break;
-
- case PI_CMD_FR:
- if (p[2] > bufSize) p[2] = bufSize;
- res = fileRead(p[1], buf, p[2]);
- break;
-
- case PI_CMD_FS:
- memcpy(&p[4], buf, 4);
- res = fileSeek(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_FW: res = fileWrite(p[1], buf, p[3]); break;
-
- case PI_CMD_GDC: res = gpioGetPWMdutycycle(p[1]); break;
-
- case PI_CMD_GPW: res = gpioGetServoPulsewidth(p[1]); break;
-
- case PI_CMD_HC:
- /* special case to allow password in upper byte */
- if (myPermit(p[1]&0xFFFFFF)) res = gpioHardwareClock(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioHardwareClock: gpio %d, no permission to update",
- p[1] & 0xFFFFFF);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_HELP: break;
-
- case PI_CMD_HP:
- if (myPermit(p[1]))
- {
- memcpy(&p[4], buf, 4);
- res = gpioHardwarePWM(p[1], p[2], p[4]);
- }
- else
- {
- DBG(DBG_USER,
- "gpioHardwarePWM: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_HWVER: res = gpioHardwareRevision(); break;
-
-
-
- case PI_CMD_I2CC: res = i2cClose(p[1]); break;
-
- case PI_CMD_I2CO:
- memcpy(&p[4], buf, 4);
- res = i2cOpen(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_I2CPC:
- memcpy(&p[4], buf, 4);
- res = i2cProcessCall(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_I2CPK:
- res = i2cBlockProcessCall(p[1], p[2], buf, p[3]);
- break;
-
- case PI_CMD_I2CRB: res = i2cReadByteData(p[1], p[2]); break;
-
- case PI_CMD_I2CRD:
- if (p[2] > bufSize) p[2] = bufSize;
- res = i2cReadDevice(p[1], buf, p[2]);
- break;
-
- case PI_CMD_I2CRI:
- memcpy(&p[4], buf, 4);
- res = i2cReadI2CBlockData(p[1], p[2], buf, p[4]);
- break;
-
- case PI_CMD_I2CRK:
- res = i2cReadBlockData(p[1], p[2], buf);
- break;
-
- case PI_CMD_I2CRS: res = i2cReadByte(p[1]); break;
-
- case PI_CMD_I2CRW: res = i2cReadWordData(p[1], p[2]); break;
-
- case PI_CMD_I2CWB:
- memcpy(&p[4], buf, 4);
- res = i2cWriteByteData(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_I2CWD:
- res = i2cWriteDevice(p[1], buf, p[3]);
- break;
-
- case PI_CMD_I2CWI:
- res = i2cWriteI2CBlockData(p[1], p[2], buf, p[3]);
- break;
-
- case PI_CMD_I2CWK:
- res = i2cWriteBlockData(p[1], p[2], buf, p[3]);
- break;
-
- case PI_CMD_I2CWQ: res = i2cWriteQuick(p[1], p[2]); break;
-
- case PI_CMD_I2CWS: res = i2cWriteByte(p[1], p[2]); break;
-
- case PI_CMD_I2CWW:
- memcpy(&p[4], buf, 4);
- res = i2cWriteWordData(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_I2CZ:
- /* use half buffer for write, half buffer for read */
- if (p[3] > (bufSize/2)) p[3] = bufSize/2;
- res = i2cZip(p[1], buf, p[3], buf+(bufSize/2), bufSize/2);
- if (res > 0)
- {
- memcpy(buf, buf+(bufSize/2), res);
- }
- break;
-
- case PI_CMD_MICS:
- if (p[1] <= PI_MAX_MICS_DELAY) myGpioDelay(p[1]);
- else res = PI_BAD_MICS_DELAY;
- break;
-
- case PI_CMD_MILS:
- if (p[1] <= PI_MAX_MILS_DELAY) myGpioDelay(p[1] * 1000);
- else res = PI_BAD_MILS_DELAY;
- break;
-
- case PI_CMD_MODEG: res = gpioGetMode(p[1]); break;
-
- case PI_CMD_MODES:
- if (myPermit(p[1])) res = gpioSetMode(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioSetMode: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_NB: res = gpioNotifyBegin(p[1], p[2]); break;
-
- case PI_CMD_NC: res = gpioNotifyClose(p[1]); break;
-
- case PI_CMD_NO: res = gpioNotifyOpen(); break;
-
- case PI_CMD_NP: res = gpioNotifyPause(p[1]); break;
-
- case PI_CMD_PADG: res = gpioGetPad(p[1]); break;
-
- case PI_CMD_PADS: res = gpioSetPad(p[1], p[2]); break;
-
- case PI_CMD_PFG: res = gpioGetPWMfrequency(p[1]); break;
-
- case PI_CMD_PFS:
- if (myPermit(p[1])) res = gpioSetPWMfrequency(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioSetPWMfrequency: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_PIGPV: res = gpioVersion(); break;
-
- case PI_CMD_PRG: res = gpioGetPWMrange(p[1]); break;
-
- case PI_CMD_PROC:
- res = gpioStoreScript(buf);
- break;
-
- case PI_CMD_PROCD: res = gpioDeleteScript(p[1]); break;
-
- case PI_CMD_PROCP:
- res = gpioScriptStatus(p[1], (uint32_t *)buf);
- break;
-
- case PI_CMD_PROCR:
- res = gpioRunScript(p[1], p[3]/4, (uint32_t *)buf);
- break;
-
- case PI_CMD_PROCS: res = gpioStopScript(p[1]); break;
-
- case PI_CMD_PRRG: res = gpioGetPWMrealRange(p[1]); break;
-
- case PI_CMD_PRS:
- if (myPermit(p[1])) res = gpioSetPWMrange(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioSetPWMrange: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_PUD:
- if (myPermit(p[1])) res = gpioSetPullUpDown(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioSetPullUpDown: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_PWM:
- if (myPermit(p[1])) res = gpioPWM(p[1], p[2]);
- else
- {
- DBG(DBG_USER, "gpioPWM: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_READ: res = gpioRead(p[1]); break;
-
- case PI_CMD_SERVO:
- if (myPermit(p[1])) res = gpioServo(p[1], p[2]);
- else
- {
- DBG(DBG_USER,
- "gpioServo: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
-
-
- case PI_CMD_SERRB: res = serReadByte(p[1]); break;
-
- case PI_CMD_SERWB: res = serWriteByte(p[1], p[2]); break;
-
- case PI_CMD_SERC: res = serClose(p[1]); break;
-
- case PI_CMD_SERDA: res = serDataAvailable(p[1]); break;
-
- case PI_CMD_SERO: res = serOpen(buf, p[1], p[2]); break;
-
- case PI_CMD_SERR:
- if (p[2] > bufSize) p[2] = bufSize;
- res = serRead(p[1], buf, p[2]);
- break;
-
- case PI_CMD_SERW: res = serWrite(p[1], buf, p[3]); break;
-
-
- case PI_CMD_SHELL:
- res = shell(buf, buf+p[1]+1);
- break;
-
-
- case PI_CMD_SLR:
- if (p[2] > bufSize) p[2] = bufSize;
- res = gpioSerialRead(p[1], buf, p[2]);
- break;
-
- case PI_CMD_SLRC: res = gpioSerialReadClose(p[1]); break;
-
- case PI_CMD_SLRO:
- memcpy(&p[4], buf, 4);
- res = gpioSerialReadOpen(p[1], p[2], p[4]); break;
-
- case PI_CMD_SLRI: res = gpioSerialReadInvert(p[1], p[2]); break;
-
- case PI_CMD_SPIC:
- res = spiClose(p[1]);
- break;
-
- case PI_CMD_SPIO:
- memcpy(&p[4], buf, 4);
- res = spiOpen(p[1], p[2], p[4]);
- break;
-
- case PI_CMD_SPIR:
- if (p[2] > bufSize) p[2] = bufSize;
- res = spiRead(p[1], buf, p[2]);
- break;
-
- case PI_CMD_SPIW:
- if (p[3] > bufSize) p[3] = bufSize;
- res = spiWrite(p[1], buf, p[3]);
- break;
-
- case PI_CMD_SPIX:
- if (p[3] > bufSize) p[3] = bufSize;
- res = spiXfer(p[1], buf, buf, p[3]);
- break;
-
- case PI_CMD_TICK: res = gpioTick(); break;
-
- case PI_CMD_TRIG:
- if (myPermit(p[1]))
- {
- memcpy(&p[4], buf, 4);
- res = gpioTrigger(p[1], p[2], p[4]);
- }
- else
- {
- DBG(DBG_USER,
- "gpioTrigger: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_WDOG: res = gpioSetWatchdog(p[1], p[2]); break;
-
- case PI_CMD_WRITE:
- if (myPermit(p[1])) res = gpioWrite(p[1], p[2]);
- else
- {
- DBG(DBG_USER, "gpioWrite: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
-
-
- case PI_CMD_WVAG:
-
- /* need to mask off any non permitted gpios */
-
- mask = gpioMask;
- pulse = (gpioPulse_t *)buf;
- j = p[3]/sizeof(gpioPulse_t);
- masked = 0;
-
- for (i=0; i= 0)) res = PI_SOME_PERMITTED;
-
- break;
-
- case PI_CMD_WVAS:
- if (myPermit(p[1]))
- {
- memcpy(&tmp1, buf, 4); /* databits */
- memcpy(&tmp2, buf+4, 4); /* stophalfbits */
- memcpy(&tmp3, buf+8, 4); /* offset */
- res = gpioWaveAddSerial
- (p[1], p[2], tmp1, tmp2, tmp3, p[3]-12, buf+12);
- }
- else
- {
- DBG(
- DBG_USER,
- "gpioWaveAddSerial: gpio %d, no permission to update", p[1]);
- res = PI_NOT_PERMITTED;
- }
- break;
-
- case PI_CMD_WVBSY: res = gpioWaveTxBusy(); break;
-
- case PI_CMD_WVCHA:
- if (p[3] > bufSize) p[3] = bufSize;
- res = gpioWaveChain(buf, p[3]);
- break;
-
-
- case PI_CMD_WVCLR: res = gpioWaveClear(); break;
-
- case PI_CMD_WVCRE: res = gpioWaveCreate(); break;
-
- case PI_CMD_WVDEL: res = gpioWaveDelete(p[1]); break;
-
- case PI_CMD_WVGO: res = gpioWaveTxStart(PI_WAVE_MODE_ONE_SHOT); break;
-
- case PI_CMD_WVGOR: res = gpioWaveTxStart(PI_WAVE_MODE_REPEAT); break;
-
- case PI_CMD_WVHLT: res = gpioWaveTxStop(); break;
-
- case PI_CMD_WVNEW: res = gpioWaveAddNew(); break;
-
- case PI_CMD_WVSC:
- switch(p[1])
- {
- case 0: res = gpioWaveGetCbs(); break;
- case 1: res = gpioWaveGetHighCbs(); break;
- case 2: res = gpioWaveGetMaxCbs(); break;
- default: res = PI_BAD_WVSC_COMMND;
- }
- break;
-
- case PI_CMD_WVSM:
- switch(p[1])
- {
- case 0: res = gpioWaveGetMicros(); break;
- case 1: res = gpioWaveGetHighMicros(); break;
- case 2: res = gpioWaveGetMaxMicros(); break;
- default: res = PI_BAD_WVSM_COMMND;
- }
- break;
-
- case PI_CMD_WVSP:
- switch(p[1])
- {
- case 0: res = gpioWaveGetPulses(); break;
- case 1: res = gpioWaveGetHighPulses(); break;
- case 2: res = gpioWaveGetMaxPulses(); break;
- default: res = PI_BAD_WVSP_COMMND;
- }
- break;
-
- case PI_CMD_WVTAT: res = gpioWaveTxAt(); break;
-
- case PI_CMD_WVTX:
- res = gpioWaveTxSend(p[1], PI_WAVE_MODE_ONE_SHOT); break;
-
- case PI_CMD_WVTXM:
- res = gpioWaveTxSend(p[1], p[2]); break;
-
- case PI_CMD_WVTXR:
- res = gpioWaveTxSend(p[1], PI_WAVE_MODE_REPEAT); break;
-
- default:
- res = PI_UNKNOWN_COMMAND;
- break;
- }
-
- return res;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void mySetGpioOff(unsigned gpio, int pos)
-{
- int page, slot;
-
- myOffPageSlot(pos, &page, &slot);
-
- dmaIVirt[page]->gpioOff[slot] |= (1<gpioOff[slot] &= ~(1<gpioOn[slot] |= (1<gpioOn[slot] &= ~(1<handle)
- {
- mbUnmapMem(DMAMemP->virtual_addr, DMAMemP->size);
- mbUnlockMemory(fdMbox, DMAMemP->handle);
- mbReleaseMemory(fdMbox, DMAMemP->handle);
- DMAMemP->handle = 0;
- }
-}
-
-static int mbDMAAlloc(DMAMem_t *DMAMemP, unsigned size, uint32_t pi_mem_flag)
-{
- DMAMemP->size = size;
-
- DMAMemP->handle =
- mbAllocateMemory(fdMbox, size, PAGE_SIZE, pi_mem_flag);
-
- if (DMAMemP->handle)
- {
- DMAMemP->bus_addr = mbLockMemory(fdMbox, DMAMemP->handle);
-
- DMAMemP->virtual_addr =
- mbMapMem(BUS_TO_PHYS(DMAMemP->bus_addr), size);
-
- return 1;
- }
- return 0;
-}
-
-
-/* ======================================================================= */
-
-rawCbs_t * rawWaveCBAdr(int cbNum)
-{
- int page, slot;
-
- page = cbNum/CBS_PER_OPAGE;
- slot = cbNum%CBS_PER_OPAGE;
-
- return &dmaOVirt[page]->cb[slot];
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t waveCbPOadr(int pos)
-{
- int page, slot;
-
- page = pos/CBS_PER_OPAGE;
- slot = pos%CBS_PER_OPAGE;
-
- return (uint32_t) &dmaOBus[page]->cb[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void waveOOLPageSlot(int pos, int *page, int *slot)
-{
- *page = pos/OOL_PER_OPAGE;
- *slot = pos%OOL_PER_OPAGE;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static void waveSetOOL(int pos, uint32_t OOL)
-{
- int page, slot;
-
- waveOOLPageSlot(pos, &page, &slot);
-
- dmaOVirt[page]->OOL[slot] = OOL;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t waveOOLPOadr(int pos)
-{
- int page, slot;
-
- waveOOLPageSlot(pos, &page, &slot);
-
- return (uint32_t) &dmaOBus[page]->OOL[slot];
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static void waveBitDelay
- (unsigned baud, unsigned bits, unsigned stops, unsigned *bitDelay)
-{
- unsigned fullBit, last, diff, t, i;
-
- /* scaled 1000X */
-
- fullBit = 1000000000 / baud;
- last = 0;
-
- for (i=0; i<=bits; i++)
- {
- t = (((i+1)*fullBit)+500)/1000;
- diff = t - last;
- last = t;
- bitDelay[i] = diff;
- }
-
- t = (((bits+1)*fullBit) + ((stops*fullBit)/2) + 500)/1000;
- diff = t - last;
- bitDelay[i] = diff;
-}
-
-static int waveDelayCBs(uint32_t delay)
-{
- uint32_t cbs;
-
- if (!delay) return 0;
- if (gpioCfg.DMAsecondaryChannel < DMA_LITE_FIRST) return 1;
- cbs = BPD * delay / DMA_LITE_MAX;
- if ((BPD * delay) % DMA_LITE_MAX) cbs++;
- return cbs;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void waveCBsOOLs(int *numCBs, int *numBOOLs, int *numTOOLs)
-{
- int numCB=0, numBOOL=0, numTOOL=0;
-
- unsigned i;
-
- unsigned numWaves;
-
- rawWave_t *waves;
-
- numWaves = wfc[wfcur];
- waves = wf [wfcur];
-
- /* delay cb at start of DMA */
-
- numCB++;
-
- for (i=0; iinfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
-
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
- p->next = waveCbPOadr(botCB);
-
- repeatCB = botCB;
-
- for (i=0; iinfo = NORMAL_DMA;
- p->src = waveOOLPOadr(botOOL++);
- p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->length = 4;
- p->next = waveCbPOadr(botCB);
- }
-
- if (waves[i].gpioOff)
- {
- waveSetOOL(botOOL, waves[i].gpioOff);
-
- p = rawWaveCBAdr(botCB++);
-
- p->info = NORMAL_DMA;
- p->src = waveOOLPOadr(botOOL++);
- p->dst = ((GPIO_BASE + (GPCLR0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->length = 4;
- p->next = waveCbPOadr(botCB);
- }
-
- if (waves[i].flags & WAVE_FLAG_READ)
- {
- p = rawWaveCBAdr(botCB++);
-
- p->info = NORMAL_DMA;
- p->src = ((GPIO_BASE + (GPLEV0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->dst = waveOOLPOadr(--topOOL);
- p->length = 4;
- p->next = waveCbPOadr(botCB);
- }
-
- if (waves[i].flags & WAVE_FLAG_TICK)
- {
- p = rawWaveCBAdr(botCB++);
-
- p->info = NORMAL_DMA;
- p->src = ((SYST_BASE + (SYST_CLO*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->dst = waveOOLPOadr(--topOOL);
- p->length = 4;
- p->next = waveCbPOadr(botCB);
- }
-
- if (waves[i].usDelay)
- {
- delayLeft = waves[i].usDelay;
-
- delayCBs = waveDelayCBs(delayLeft);
-
- for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
-
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
-
- p->length = BPD * delayLeft / PI_WF_MICROS;
-
- if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
- (p->length > DMA_LITE_MAX))
- {
- p->length = DMA_LITE_MAX;
- }
-
- delayLeft -= (p->length / BPD);
-
- p->next = waveCbPOadr(botCB);
- }
- }
- }
-
- if (p != NULL)
- {
- if (wave_mode == PI_WAVE_MODE_ONE_SHOT)
- p->next = 0;
- else p->next = waveCbPOadr(repeatCB);
- }
-
- status = botCB - *CB;
-
- *CB = botCB;
- *BOOL = botOOL;
- *TOOL = topOOL;
-
- return status;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void waveRxSerial(wfRx_t *w, int level, uint32_t tick)
-{
- int diffTicks, lastLevel;
- int newWritePos;
-
- level = level ^ w->s.invert;
-
- if (w->s.bit >= 0)
- {
- diffTicks = tick - w->s.startBitTick;
-
- if (level != PI_TIMEOUT)
- {
- w->s.level = level;
- lastLevel = !level;
- }
- else lastLevel = w->s.level;
-
- while ((w->s.bit <= w->s.dataBits) &&
- (diffTicks > (w->s.nextBitDiff/1000)))
- {
- if (w->s.bit)
- {
- if (lastLevel) w->s.data |= (1<<(w->s.bit-1));
- }
- else w->s.data = 0;
-
- ++(w->s.bit);
-
- w->s.nextBitDiff += w->s.fullBit;
- }
-
- if (w->s.bit > w->s.dataBits)
- {
- memcpy(w->s.buf + w->s.writePos, &w->s.data, w->s.bytes);
-
- /* don't let writePos catch readPos */
-
- newWritePos = (w->s.writePos + w->s.bytes) % (w->s.bufSize);
-
- if (newWritePos != w->s.readPos) w->s.writePos = newWritePos;
-
- if (level == 0)
- {
- gpioSetWatchdog(w->gpio, w->s.timeout);
- w->s.bit = 0;
- w->s.startBitTick = tick;
- w->s.nextBitDiff = w->s.halfBit;
- }
- else
- {
- w->s.bit = -1;
- gpioSetWatchdog(w->gpio, 0);
- }
- }
- }
- else
- {
- /* start bit if high->low */
-
- if (level == 0)
- {
- gpioSetWatchdog(w->gpio, w->s.timeout);
- w->s.level = 0;
- w->s.bit = 0;
- w->s.startBitTick = tick;
- w->s.nextBitDiff = w->s.halfBit;
- }
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static void waveRxBit(int gpio, int level, uint32_t tick)
-{
- switch (wfRx[gpio].mode)
- {
- case PI_WFRX_SERIAL:
- waveRxSerial(&wfRx[gpio], level, tick);
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int rawWaveAddGeneric(unsigned numIn1, rawWave_t *in1)
-{
- unsigned inPos1=0, inPos2=0, outPos=0, level = NUM_WAVE_OOL;
-
- unsigned cbs=0;
-
- unsigned numIn2, numOut;
-
- uint32_t tNow, tNext1, tNext2, tDelay;
-
- rawWave_t *in2, *out;
-
- numIn2 = wfc[wfcur];
- in2 = wf[wfcur];
-
- numOut = PI_WAVE_MAX_PULSES;
- out = wf[1-wfcur];
-
- tNow = 0;
-
- if (!numIn1) tNext1 = -1; else tNext1 = 0;
- if (!numIn2) tNext2 = -1; else tNext2 = 0;
-
- while (((inPos1= numIn1) tNext1 = -1;
- if (inPos2 >= numIn2) tNext2 = -1;
-
- }
-
- if ((outPos < numOut) && (outPos < level))
- {
- wfStats.micros = tNow;
-
- if (tNow > wfStats.highMicros) wfStats.highMicros = tNow;
-
- wfStats.pulses = outPos;
-
- if (outPos > wfStats.highPulses) wfStats.highPulses = outPos;
-
- wfStats.cbs = cbs;
-
- if (cbs > wfStats.highCbs) wfStats.highCbs = cbs;
-
- wfc[1-wfcur] = outPos;
- wfcur = 1 - wfcur;
-
- return outPos;
- }
- else return PI_TOO_MANY_PULSES;
-}
-
-/* ======================================================================= */
-
-int i2cWriteQuick(unsigned handle, unsigned bit)
-{
- int status;
-
- DBG(DBG_USER, "handle=%d bit=%d", handle, bit);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_QUICK) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (bit > 1)
- SOFT_ERROR(PI_BAD_PARAM, "bad bit (%d)", bit);
-
- status = my_smbus_access(
- i2cInfo[handle].fd, bit, 0, PI_I2C_SMBUS_QUICK, NULL);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-int i2cReadByte(unsigned handle)
-{
- union my_smbus_data data;
- int status;
-
- DBG(DBG_USER, "handle=%d", handle);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BYTE) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- status = my_smbus_access(
- i2cInfo[handle].fd, PI_I2C_SMBUS_READ, 0, PI_I2C_SMBUS_BYTE, &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
-
- return 0xFF & data.byte;
-}
-
-
-int i2cWriteByte(unsigned handle, unsigned bVal)
-{
- int status;
-
- DBG(DBG_USER, "handle=%d bVal=%d", handle, bVal);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BYTE) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (bVal > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad bVal (%d)", bVal);
-
- status = my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- bVal,
- PI_I2C_SMBUS_BYTE,
- NULL);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-
-int i2cReadByteData(unsigned handle, unsigned reg)
-{
- union my_smbus_data data;
- int status;
-
- DBG(DBG_USER, "handle=%d reg=%d", handle, reg);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BYTE_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- status = my_smbus_access(i2cInfo[handle].fd,
- PI_I2C_SMBUS_READ, reg, PI_I2C_SMBUS_BYTE_DATA, &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
-
- return 0xFF & data.byte;
-}
-
-
-int i2cWriteByteData(unsigned handle, unsigned reg, unsigned bVal)
-{
- union my_smbus_data data;
-
- int status;
-
- DBG(DBG_USER, "handle=%d reg=%d bVal=%d", handle, reg, bVal);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BYTE_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if (bVal > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad bVal (%d)", bVal);
-
- data.byte = bVal;
-
- status = my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- reg,
- PI_I2C_SMBUS_BYTE_DATA,
- &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-
-int i2cReadWordData(unsigned handle, unsigned reg)
-{
- union my_smbus_data data;
- int status;
-
- DBG(DBG_USER, "handle=%d reg=%d", handle, reg);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_WORD_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- status = (my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_READ,
- reg,
- PI_I2C_SMBUS_WORD_DATA,
- &data));
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
-
- return 0xFFFF & data.word;
-}
-
-
-int i2cWriteWordData(unsigned handle, unsigned reg, unsigned wVal)
-{
- union my_smbus_data data;
-
- int status;
-
- DBG(DBG_USER, "handle=%d reg=%d wVal=%d", handle, reg, wVal);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_WORD_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if (wVal > 0xFFFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad wVal (%d)", wVal);
-
- data.word = wVal;
-
- status = my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- reg,
- PI_I2C_SMBUS_WORD_DATA,
- &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-
-int i2cProcessCall(unsigned handle, unsigned reg, unsigned wVal)
-{
- union my_smbus_data data;
- int status;
-
- DBG(DBG_USER, "handle=%d reg=%d wVal=%d", handle, reg, wVal);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_PROC_CALL) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if (wVal > 0xFFFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad wVal (%d)", wVal);
-
- data.word = wVal;
-
- status = (my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- reg, PI_I2C_SMBUS_PROC_CALL,
- &data));
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
-
- return 0xFFFF & data.word;
-}
-
-
-int i2cReadBlockData(unsigned handle, unsigned reg, char *buf)
-{
- union my_smbus_data data;
-
- int i, status;
-
- DBG(DBG_USER, "handle=%d reg=%d buf=%08X", handle, reg, (unsigned)buf);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_BLOCK_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- status = (my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_READ,
- reg,
- PI_I2C_SMBUS_BLOCK_DATA,
- &data));
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
- else
- {
- if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX)
- {
- for (i=0; i= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_BLOCK_DATA) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if ((count < 1) || (count > 32))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- for (i=1; i<=count; i++) data.block[i] = buf[i-1];
- data.block[0] = count;
-
- status = my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- reg,
- PI_I2C_SMBUS_BLOCK_DATA,
- &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-
-int i2cBlockProcessCall(
- unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- union my_smbus_data data;
-
- int i, status;
-
- DBG(DBG_USER, "handle=%d reg=%d count=%d [%s]",
- handle, reg, count, myBuf2Str(count, buf));
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_PROC_CALL) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if ((count < 1) || (count > 32))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- for (i=1; i<=count; i++) data.block[i] = buf[i-1];
- data.block[0] = count;
-
- status = (my_smbus_access(
- i2cInfo[handle].fd, PI_I2C_SMBUS_WRITE, reg,
- PI_I2C_SMBUS_BLOCK_PROC_CALL, &data));
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
- else
- {
- if (data.block[0] <= PI_I2C_SMBUS_BLOCK_MAX)
- {
- for (i=0; i= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_READ_I2C_BLOCK) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if ((count < 1) || (count > 32))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- if (count == 32)
- size = PI_I2C_SMBUS_I2C_BLOCK_BROKEN;
- else
- size = PI_I2C_SMBUS_I2C_BLOCK_DATA;
-
- data.block[0] = count;
-
- status = (my_smbus_access(
- i2cInfo[handle].fd, PI_I2C_SMBUS_READ, reg, size, &data));
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_READ_FAILED;
- }
- else
- {
- if (data.block[0] <= PI_I2C_SMBUS_I2C_BLOCK_MAX)
- {
- for (i=0; i= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((i2cInfo[handle].funcs & PI_I2C_FUNC_SMBUS_WRITE_I2C_BLOCK) == 0)
- SOFT_ERROR(PI_BAD_SMBUS_CMD, "SMBUS command not supported by driver");
-
- if (reg > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad reg (%d)", reg);
-
- if ((count < 1) || (count > 32))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- for (i=1; i<=count; i++) data.block[i] = buf[i-1];
-
- data.block[0] = count;
-
- status = my_smbus_access(
- i2cInfo[handle].fd,
- PI_I2C_SMBUS_WRITE,
- reg,
- PI_I2C_SMBUS_I2C_BLOCK_BROKEN,
- &data);
-
- if (status < 0)
- {
- DBG(DBG_USER, "error=%d (%m)", status);
- return PI_I2C_WRITE_FAILED;
- }
-
- return status;
-}
-
-int i2cWriteDevice(unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, buf));
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((count < 1) || (count > PI_MAX_I2C_DEVICE_COUNT))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- bytes = write(i2cInfo[handle].fd, buf, count);
-
- if (bytes != count)
- {
- DBG(DBG_USER, "error=%d (%m)", bytes);
- return PI_I2C_WRITE_FAILED;
- }
-
- return 0;
-}
-
-int i2cReadDevice(unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- DBG(DBG_USER, "handle=%d count=%d buf=%08X",
- handle, count, (unsigned)buf);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state == PI_I2C_CLOSED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if ((count < 1) || (count > PI_MAX_I2C_DEVICE_COUNT))
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- bytes = read(i2cInfo[handle].fd, buf, count);
-
- if (bytes != count)
- {
- DBG(DBG_USER, "error=%d (%m)", bytes);
- return PI_I2C_READ_FAILED;
- }
-
- return bytes;
-}
-
-int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags)
-{
- char dev[32];
- int i, slot, fd;
- uint32_t funcs;
-
- DBG(DBG_USER, "i2cBus=%d i2cAddr=%d flags=0x%X",
- i2cBus, i2cAddr, i2cFlags);
-
- CHECK_INITED;
-
- if (i2cAddr > PI_MAX_I2C_ADDR)
- SOFT_ERROR(PI_BAD_I2C_ADDR, "bad I2C address (%d)", i2cAddr);
-
- if (i2cFlags)
- SOFT_ERROR(PI_BAD_FLAGS, "bad flags (0x%X)", i2cFlags);
-
- slot = -1;
-
- for (i=0; i= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state != PI_I2C_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].fd >= 0) close(i2cInfo[handle].fd);
-
- i2cInfo[handle].fd = -1;
- i2cInfo[handle].state = PI_I2C_CLOSED;
-
- return 0;
-}
-
-void i2cSwitchCombined(int setting)
-{
- int fd;
-
- DBG(DBG_USER, "setting=%d", setting);
-
- fd = open(PI_I2C_COMBINED, O_WRONLY);
-
- if (fd >= 0)
- {
- if (setting) write(fd, "1\n", 2); else write(fd, "0\n", 2);
-
- close(fd);
- }
-}
-
-int i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs)
-{
- int retval;
- my_i2c_rdwr_ioctl_data_t rdwr;
-
- DBG(DBG_USER, "handle=%d", handle);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state != PI_I2C_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (segs == NULL)
- SOFT_ERROR(PI_BAD_POINTER, "null segments");
-
- if (numSegs > PI_I2C_RDRW_IOCTL_MAX_MSGS)
- SOFT_ERROR(PI_TOO_MANY_SEGS, "too many segments (%d)", numSegs);
-
- rdwr.msgs = segs;
- rdwr.nmsgs = numSegs;
-
- retval = ioctl(i2cInfo[handle].fd, PI_I2C_RDWR, &rdwr);
-
- if (retval >= 0) return retval;
- else return PI_BAD_I2C_SEG;
-}
-
-int i2cZip(
- unsigned handle,
- char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)
-{
- int numSegs, inPos, outPos, status, bytes, flags, addr;
- int esc, setesc;
- pi_i2c_msg_t segs[PI_I2C_RDRW_IOCTL_MAX_MSGS];
-
- DBG(DBG_USER, "handle=%d inBuf=%s outBuf=%08X len=%d",
- handle, myBuf2Str(inLen, (char *)inBuf), (int)outBuf, outLen);
-
- CHECK_INITED;
-
- if (handle >= PI_I2C_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (i2cInfo[handle].state != PI_I2C_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (!inBuf || !inLen)
- SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL");
-
- if (!outBuf && outLen)
- SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL");
-
- numSegs = 0;
-
- inPos = 0;
- outPos = 0;
- status = 0;
-
- addr = i2cInfo[handle].addr;
- flags = 0;
- esc = 0;
- setesc = 0;
-
- while (!status && (inPos < inLen))
- {
- DBG(DBG_INTERNAL, "status=%d inpos=%d inlen=%d cmd=%d addr=%d flags=%x",
- status, inPos, inLen, inBuf[inPos], addr, flags);
-
- switch (inBuf[inPos++])
- {
- case PI_I2C_END:
- status = 1;
- break;
-
- case PI_I2C_COMBINED_ON:
- /* Run prior transactions before setting combined flag */
- if (numSegs)
- {
- status = i2cSegments(handle, segs, numSegs);
- if (status >= 0) status = 0; /* continue */
- numSegs = 0;
- }
- i2cSwitchCombined(1);
- break;
-
- case PI_I2C_COMBINED_OFF:
- /* Run prior transactions before clearing combined flag */
- if (numSegs)
- {
- status = i2cSegments(handle, segs, numSegs);
- if (status >= 0) status = 0; /* continue */
- numSegs = 0;
- }
- i2cSwitchCombined(0);
- break;
-
- case PI_I2C_ADDR:
- addr = myI2CGetPar(inBuf, &inPos, inLen, &esc);
- if (addr < 0) status = PI_BAD_I2C_CMD;
- break;
-
- case PI_I2C_FLAGS:
- /* cheat to force two byte flags */
- esc = 1;
- flags = myI2CGetPar(inBuf, &inPos, inLen, &esc);
- if (flags < 0) status = PI_BAD_I2C_CMD;
- break;
-
- case PI_I2C_ESC:
- setesc = 1;
- break;
-
- case PI_I2C_READ:
-
- bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc);
-
- if (bytes >= 0)
- {
- if ((bytes + outPos) < outLen)
- {
- segs[numSegs].addr = addr;
- segs[numSegs].flags = (flags|1);
- segs[numSegs].len = bytes;
- segs[numSegs].buf = (uint8_t *)(outBuf + outPos);
- outPos += bytes;
- numSegs++;
- if (numSegs >= PI_I2C_RDRW_IOCTL_MAX_MSGS)
- {
- status = i2cSegments(handle, segs, numSegs);
- if (status >= 0) status = 0; /* continue */
- numSegs = 0;
- }
- }
- else status = PI_BAD_I2C_RLEN;
- }
- else status = PI_BAD_I2C_RLEN;
- break;
-
- case PI_I2C_WRITE:
-
- bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc);
-
- if (bytes >= 0)
- {
- if ((bytes + inPos) < inLen)
- {
- segs[numSegs].addr = addr;
- segs[numSegs].flags = (flags&0xfffe);
- segs[numSegs].len = bytes;
- segs[numSegs].buf = (uint8_t *)(inBuf + inPos);
- inPos += bytes;
- numSegs++;
- if (numSegs >= PI_I2C_RDRW_IOCTL_MAX_MSGS)
- {
- status = i2cSegments(handle, segs, numSegs);
- if (status >= 0) status = 0; /* continue */
- numSegs = 0;
- }
- }
- else status = PI_BAD_I2C_WLEN;
- }
- else status = PI_BAD_I2C_WLEN;
- break;
-
- default:
- status = PI_BAD_I2C_CMD;
- }
-
- if (setesc) esc = 1; else esc = 0;
-
- setesc = 0;
- }
-
- if (status >= 0)
- {
- if (numSegs) status = i2cSegments(handle, segs, numSegs);
- }
-
- if (status >= 0) status = outPos;
-
- return status;
-}
-
-/* ======================================================================= */
-
-/*SPI */
-
-static uint32_t _spiTXBits(char *buf, int pos, int bitlen, int msbf)
-{
- uint32_t bits=0;
-
- if (buf)
- {
- if (bitlen <= 8) bits = *((( uint8_t*)buf)+pos);
- else if (bitlen <= 16) bits = *(((uint16_t*)buf)+pos);
- else bits = *(((uint32_t*)buf)+pos);
-
- if (msbf) bits <<= (32-bitlen);
- }
-
- return bits;
-}
-
-static void _spiRXBits(
- char *buf, int pos, int bitlen, int msbf, uint32_t bits)
-{
- if (buf)
- {
- if (!msbf) bits >>= (32-bitlen);
-
- if (bitlen <= 8) *((( uint8_t*)buf)+pos) = bits;
- else if (bitlen <= 16) *(((uint16_t*)buf)+pos) = bits;
- else *(((uint32_t*)buf)+pos) = bits;
- }
-}
-
-static void spiACS(int channel, int on)
-{
- int gpio;
-
- switch (channel)
- {
- case 0: gpio = PI_ASPI_CE0; break;
- case 1: gpio = PI_ASPI_CE1; break;
- default: gpio = PI_ASPI_CE2; break;
- }
- myGpioWrite(gpio, on);
-}
-
-static void spiGoA(
- unsigned speed, /* bits per second */
- uint32_t flags, /* flags */
- char *txBuf, /* tx buffer */
- char *rxBuf, /* rx buffer */
- unsigned count) /* number of bytes */
-{
- int cs;
- char bit_ir[4] = {1, 0, 0, 1}; /* read on rising edge */
- char bit_or[4] = {0, 1, 1, 0}; /* write on rising edge */
- char bit_ic[4] = {0, 0, 1, 1}; /* invert clock */
-
- int mode, bitlen, txmsbf, rxmsbf, channel;
- unsigned txCnt=0;
- unsigned rxCnt=0;
- uint32_t spiDefaults;
- uint32_t statusReg;
- int txFull, rxEmpty;
-
- channel = PI_SPI_FLAGS_GET_CHANNEL(flags);
- mode = PI_SPI_FLAGS_GET_MODE (flags);
-
- bitlen = PI_SPI_FLAGS_GET_BITLEN (flags);
-
- if (!bitlen) bitlen = 8;
-
- /* correct count for word size */
-
- if (bitlen > 8) count /= 2;
- if (bitlen > 16) count /= 2;
-
- txmsbf = !PI_SPI_FLAGS_GET_TX_LSB (flags);
- rxmsbf = !PI_SPI_FLAGS_GET_RX_LSB (flags);
-
- cs = PI_SPI_FLAGS_GET_CSPOLS(flags) & (1<>28)&15) > 2);
-
- if (rxCnt < count)
- {
- if (!rxEmpty)
- {
- _spiRXBits(
- rxBuf, rxCnt++, bitlen, rxmsbf, auxReg[AUX_SPI0_IO_REG]);
- }
- }
-
- if (txCnt < count)
- {
- if (!txFull)
- {
- if (txCnt != (count-1))
- {
- auxReg[AUX_SPI0_TX_HOLD] =
- _spiTXBits(txBuf, txCnt++, bitlen, txmsbf);
- }
- else
- {
- auxReg[AUX_SPI0_IO_REG] =
- _spiTXBits(txBuf, txCnt++, bitlen, txmsbf);
- }
- }
- }
- }
-
- while ((auxReg[AUX_SPI0_STAT_REG] & AUXSPI_STAT_BUSY)) ;
-
- spiACS(channel, !cs);
-}
-
-static void spiGoS(
- unsigned speed,
- uint32_t flags,
- char *txBuf,
- char *rxBuf,
- unsigned count)
-{
- unsigned txCnt=0;
- unsigned rxCnt=0;
- unsigned cnt, cnt4w, cnt3w;
- uint32_t spiDefaults;
- unsigned mode, channel, cspol, cspols, flag3w, ren3w;
-
- channel = PI_SPI_FLAGS_GET_CHANNEL(flags);
- mode = PI_SPI_FLAGS_GET_MODE (flags);
- cspols = PI_SPI_FLAGS_GET_CSPOLS(flags);
- cspol = (cspols>>channel) & 1;
- flag3w = PI_SPI_FLAGS_GET_3WIRE(flags);
- ren3w = PI_SPI_FLAGS_GET_3WREN(flags);
-
- spiDefaults = SPI_CS_MODE(mode) |
- SPI_CS_CSPOLS(cspols) |
- SPI_CS_CS(channel) |
- SPI_CS_CSPOL(cspol) |
- SPI_CS_CLEAR(3);
-
- spiReg[SPI_CS] = spiDefaults; /* stop */
-
- if (!count) return;
-
- if (flag3w)
- {
- if (ren3w < count)
- {
- cnt4w = ren3w;
- cnt3w = count - ren3w;
- }
- else
- {
- cnt4w = count;
- cnt3w = 0;
- }
- }
- else
- {
- cnt4w = count;
- cnt3w = 0;
- }
-
- spiReg[SPI_CLK] = 250000000/speed;
-
- spiReg[SPI_CS] = spiDefaults | SPI_CS_TA; /* start */
-
- cnt = cnt4w;
-
- while((txCnt < cnt) || (rxCnt < cnt))
- {
- while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
- {
- if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
- else spi_dummy = spiReg[SPI_FIFO];
- rxCnt++;
- }
-
- while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
- {
- if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
- else spiReg[SPI_FIFO] = 0;
- txCnt++;
- }
- }
-
- while (!(spiReg[SPI_CS] & SPI_CS_DONE)) ;
-
- /* now switch to 3-wire bus */
-
- cnt += cnt3w;
-
- spiReg[SPI_CS] |= SPI_CS_REN;
-
- while((txCnt < cnt) || (rxCnt < cnt))
- {
- while((rxCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_RXD)))
- {
- if (rxBuf) rxBuf[rxCnt] = spiReg[SPI_FIFO];
- else spi_dummy = spiReg[SPI_FIFO];
- rxCnt++;
- }
-
- while((txCnt < cnt) && ((spiReg[SPI_CS] & SPI_CS_TXD)))
- {
- if (txBuf) spiReg[SPI_FIFO] = txBuf[txCnt];
- else spiReg[SPI_FIFO] = 0;
- txCnt++;
- }
- }
-
- while (!(spiReg[SPI_CS] & SPI_CS_DONE)) ;
-
- spiReg[SPI_CS] = spiDefaults; /* stop */
-}
-
-static void spiGo(
- unsigned speed,
- uint32_t flags,
- char *txBuf,
- char *rxBuf,
- unsigned count)
-{
- if (PI_SPI_FLAGS_GET_AUX_SPI(flags))
- {
- pthread_mutex_lock(&spi_aux_mutex);
- spiGoA(speed, flags, txBuf, rxBuf, count);
- pthread_mutex_unlock(&spi_aux_mutex);
- }
- else
- {
- pthread_mutex_lock(&spi_main_mutex);
- spiGoS(speed, flags, txBuf, rxBuf, count);
- pthread_mutex_unlock(&spi_main_mutex);
- }
-}
-
-static int spiAnyOpen(uint32_t flags)
-{
- int i, aux;
-
- aux = PI_SPI_FLAGS_GET_AUX_SPI(flags);
-
- for (i=0; i= i)
- SOFT_ERROR(PI_BAD_SPI_CHANNEL, "bad spiChan (%d)", spiChan);
-
- if ((baud < PI_SPI_MIN_BAUD) || (baud > PI_SPI_MAX_BAUD))
- SOFT_ERROR(PI_BAD_SPI_SPEED, "bad baud (%d)", baud);
-
- if (spiFlags > (1<<22))
- SOFT_ERROR(PI_BAD_FLAGS, "bad spiFlags (0x%X)", spiFlags);
-
- if (!spiAnyOpen(spiFlags)) /* initialise on first open */
- {
- spiInit(spiFlags);
- spiGo(baud, spiFlags, NULL, NULL, 0);
- }
-
- slot = -1;
-
- for (i=0; i= PI_SPI_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (spiInfo[handle].state != PI_SPI_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- spiInfo[handle].state = PI_I2C_CLOSED;
-
- if (!spiAnyOpen(spiInfo[handle].flags))
- spiTerm(spiInfo[handle].flags); /* terminate on last close */
-
- return 0;
-}
-
-int spiRead(unsigned handle, char *buf, unsigned count)
-{
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, buf));
-
- CHECK_INITED;
-
- if (handle >= PI_SPI_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (spiInfo[handle].state != PI_SPI_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (count > PI_MAX_SPI_DEVICE_COUNT)
- SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count);
-
- spiGo(spiInfo[handle].speed, spiInfo[handle].flags, NULL, buf, count);
-
- return count;
-}
-
-int spiWrite(unsigned handle, char *buf, unsigned count)
-{
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, buf));
-
- CHECK_INITED;
-
- if (handle >= PI_SPI_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (spiInfo[handle].state != PI_SPI_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (count > PI_MAX_SPI_DEVICE_COUNT)
- SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count);
-
- spiGo(spiInfo[handle].speed, spiInfo[handle].flags, buf, NULL, count);
-
- return count;
-}
-
-int spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)
-{
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, txBuf));
-
- CHECK_INITED;
-
- if (handle >= PI_SPI_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (spiInfo[handle].state != PI_SPI_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (count > PI_MAX_SPI_DEVICE_COUNT)
- SOFT_ERROR(PI_BAD_SPI_COUNT, "bad count (%d)", count);
-
- spiGo(spiInfo[handle].speed, spiInfo[handle].flags, txBuf, rxBuf, count);
-
- return count;
-}
-
-/* ======================================================================= */
-
-
-int serOpen(char *tty, unsigned serBaud, unsigned serFlags)
-{
- struct termios new;
- int speed;
- int fd;
- int i, slot;
-
- DBG(DBG_USER, "tty=%s serBaud=%d serFlags=0x%X", tty, serBaud, serFlags);
-
- SER_CHECK_INITED;
-
- if (strncmp("/dev/tty", tty, 8) && strncmp("/dev/serial", tty, 11))
- SOFT_ERROR(PI_BAD_SER_DEVICE, "bad device (%s)", tty);
-
- switch (serBaud)
- {
- case 50: speed = B50; break;
- case 75: speed = B75; break;
- case 110: speed = B110; break;
- case 134: speed = B134; break;
- case 150: speed = B150; break;
- case 200: speed = B200; break;
- case 300: speed = B300; break;
- case 600: speed = B600; break;
- case 1200: speed = B1200; break;
- case 1800: speed = B1800; break;
- case 2400: speed = B2400; break;
- case 4800: speed = B4800; break;
- case 9600: speed = B9600; break;
- case 19200: speed = B19200; break;
- case 38400: speed = B38400; break;
- case 57600: speed = B57600; break;
- case 115200: speed = B115200; break;
- case 230400: speed = B230400; break;
-
- default:
- SOFT_ERROR(PI_BAD_SER_SPEED, "bad speed (%d)", serBaud);
- }
-
- if (serFlags)
- SOFT_ERROR(PI_BAD_FLAGS, "bad flags (0x%X)", serFlags);
-
- slot = -1;
-
- for (i=0; i= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].fd >= 0) close(serInfo[handle].fd);
-
- serInfo[handle].fd = -1;
- serInfo[handle].state = PI_SER_CLOSED;
-
- return 0;
-}
-
-int serWriteByte(unsigned handle, unsigned bVal)
-{
- char c;
-
- DBG(DBG_USER, "handle=%d bVal=%d", handle, bVal);
-
- SER_CHECK_INITED;
-
- if (handle >= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (bVal > 0xFF)
- SOFT_ERROR(PI_BAD_PARAM, "bad parameter (%d)", bVal);
-
- c = bVal;
-
- if (write(serInfo[handle].fd, &c, 1) != 1)
- return PI_SER_WRITE_FAILED;
- else
- return 0;
-}
-
-int serReadByte(unsigned handle)
-{
- char x;
-
- DBG(DBG_USER, "handle=%d", handle);
-
- SER_CHECK_INITED;
-
- if (handle >= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (read(serInfo[handle].fd, &x, 1) != 1)
- {
- if (errno == EAGAIN)
- return PI_SER_READ_NO_DATA;
- else
- return PI_SER_READ_FAILED;
- }
-
- return ((int)x) & 0xFF;
-}
-
-int serWrite(unsigned handle, char *buf, unsigned count)
-{
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, buf));
-
- SER_CHECK_INITED;
-
- if (handle >= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (!count)
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- if (write(serInfo[handle].fd, buf, count) != count)
- return PI_SER_WRITE_FAILED;
- else
- return 0;
-}
-
-int serRead(unsigned handle, char *buf, unsigned count)
-{
- int r;
-
- DBG(DBG_USER, "handle=%d count=%d buf=0x%X", handle, count, (unsigned)buf);
-
- SER_CHECK_INITED;
-
- if (handle >= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (!count)
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- r = read(serInfo[handle].fd, buf, count);
-
- if (r == -1)
- {
- if (errno == EAGAIN)
- return PI_SER_READ_NO_DATA;
- else
- return PI_SER_READ_FAILED;
- }
- else
- {
- buf[r] = 0;
- return r;
- }
-}
-
-int serDataAvailable(unsigned handle)
-{
- int result;
-
- DBG(DBG_USER, "handle=%d", handle);
-
- SER_CHECK_INITED;
-
- if (handle >= PI_SER_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (serInfo[handle].state != PI_SER_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (ioctl(serInfo[handle].fd, FIONREAD, &result) == -1) return 0;
-
- return result;
-}
-
-/* ======================================================================= */
-
-static int chooseBestClock
- (clkInf_t *clkInf, unsigned f, unsigned numc, unsigned *cf)
-{
- int c, valid, offby, offby2, best_offby;
- uint32_t div;
- uint64_t frac;
-
- valid = 0;
- best_offby = 0;
-
- for (c=0; c 1) && (div < 4096))
- {
- if (f < PI_MASH_MAX_FREQ)
- {
- frac = cf[c] - (div * f);
- frac = (frac * 4096) / f;
- offby = cf[c] - (div * f) - ((frac * f) / 4096);
- if (frac < 4095)
- {
- offby2 = cf[c] - (div * f) - (((frac+1) * f) / 4096);
- if (offby2 < 0) offby2 = -offby2;
- if (offby2 < offby)
- {
- offby = offby2;
- frac++;
- }
- }
- }
- else
- {
- frac = 0;
- offby = cf[c] - (div * f);
- if (div < 4095)
- {
- offby2 = cf[c] - ((div+1) * f);
- if (offby2 < 0) offby2 = -offby2;
- if (offby2 < offby)
- {
- offby = offby2;
- div++;
- }
- }
- }
-
- if ((!valid) || (offby <= best_offby))
- {
- valid = 1;
- clkInf->div = div;
- clkInf->frac = frac;
- clkInf->clock = c;
- best_offby = offby;
- }
- }
- }
- return valid;
-}
-
-/* ======================================================================= */
-
-static rawCbs_t * dmaCB2adr(int pos)
-{
- int page, slot;
-
- page = pos/CBS_PER_IPAGE;
- slot = pos%CBS_PER_IPAGE;
-
- return &dmaIVirt[page]->cb[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaCbPrint(int pos)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(pos);
-
- fprintf(stderr, "i=%x s=%x d=%x len=%x s=%x nxt=%x\n",
- p->info, p->src, p->dst, p->length, p->stride, p->next);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static unsigned dmaNowAtICB(void)
-{
- unsigned cb;
- static unsigned lastPage=0;
- unsigned page;
- uint32_t cbAddr;
- uint32_t startTick, endTick;
-
- startTick = systReg[SYST_CLO];
-
- cbAddr = dmaIn[DMA_CONBLK_AD];
-
- page = lastPage;
-
- /* which page are we dma'ing? */
-
- while (1)
- {
- cb = (cbAddr - ((int)dmaIBus[page])) / 32;
-
- if (cb < CBS_PER_IPAGE)
- {
- endTick = systReg[SYST_CLO];
-
- if (endTick != startTick)
- gpioStats.cbTicks += (endTick - startTick);
-
- gpioStats.cbCalls++;
-
- lastPage = page;
-
- return (page*CBS_PER_IPAGE) + cb;
- }
-
- if (page++ >= DMAI_PAGES) page=0;
-
- if (page == lastPage) break;
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int dmaNowAtOCB(void)
-{
- unsigned cb;
- unsigned page;
- uint32_t cbAddr;
-
- cbAddr = dmaOut[DMA_CONBLK_AD];
-
- if (!cbAddr) return -PI_NO_TX_WAVE;
-
- page = 0;
-
- /* which page are we dma'ing? */
-
- while (1)
- {
- cb = (cbAddr - ((int)dmaOBus[page])) / 32;
-
- if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
-
- if (page++ >= DMAO_PAGES) break;
- }
-
- /* Try twice */
-
- cbAddr = dmaOut[DMA_CONBLK_AD];
-
- if (!cbAddr) return -PI_NO_TX_WAVE;
-
- page = 0;
-
- /* which page are we dma'ing? */
-
- while (1)
- {
- cb = (cbAddr - ((int)dmaOBus[page])) / 32;
-
- if (cb < CBS_PER_OPAGE) return (page*CBS_PER_OPAGE) + cb;
-
- if (page++ >= DMAO_PAGES) break;
- }
-
- return -PI_WAVE_NOT_FOUND;
-}
-
-/* ----------------------------------------------------------------------- */
-
-unsigned rawWaveCB(void)
-{
- unsigned cb;
- static unsigned lastPage=0;
- unsigned page;
- uint32_t cbAddr;
-
- cbAddr = dmaOut[DMA_CONBLK_AD];
-
- if (!cbAddr) return -1;
-
- page = lastPage;
-
- /* which page are we dma'ing? */
-
- while (1)
- {
- cb = (cbAddr - ((int)dmaOBus[page])) / 32;
-
- if (cb < CBS_PER_OPAGE)
- {
- lastPage = page;
-
- return (page*CBS_PER_OPAGE) + cb;
- }
-
- if (page++ >= DMAO_PAGES) page=0;
-
- if (page == lastPage) break;
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static unsigned dmaCurrentSlot(unsigned pos)
-{
- unsigned cycle=0, slot=0, tmp;
-
- cycle = (pos/CBS_PER_CYCLE);
- tmp = (pos%CBS_PER_CYCLE);
-
- if (tmp > 2) slot = ((tmp-2)/3);
-
- return (cycle*PULSE_PER_CYCLE)+slot;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaPwmDataAdr(int pos)
-{
- return (uint32_t) &dmaIBus[pos]->periphData;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaGpioOnAdr(int pos)
-{
- int page, slot;
-
- page = pos/ON_PER_IPAGE;
- slot = pos%ON_PER_IPAGE;
-
- return (uint32_t) &dmaIBus[page]->gpioOn[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaGpioOffAdr(int pos)
-{
- int page, slot;
-
- myOffPageSlot(pos, &page, &slot);
-
- return (uint32_t) &dmaIBus[page]->gpioOff[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaTickAdr(int pos)
-{
- int page, slot;
-
- myTckPageSlot(pos, &page, &slot);
-
- return (uint32_t) &dmaIBus[page]->tick[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaReadLevelsAdr(int pos)
-{
- int page, slot;
-
- myLvsPageSlot(pos, &page, &slot);
-
- return (uint32_t) &dmaIBus[page]->level[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t dmaCbAdr(int pos)
-{
- int page, slot;
-
- page = (pos/CBS_PER_IPAGE);
- slot = (pos%CBS_PER_IPAGE);
-
- return (uint32_t) &dmaIBus[page]->cb[slot];
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaGpioOnCb(int b, int pos)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(b);
-
- p->info = NORMAL_DMA;
- p->src = dmaGpioOnAdr(pos);
- p->dst = ((GPIO_BASE + (GPSET0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->length = 4;
- p->next = dmaCbAdr(b+1);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaTickCb(int b, int pos)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(b);
-
- p->info = NORMAL_DMA;
- p->src = ((SYST_BASE + (SYST_CLO*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->dst = dmaTickAdr(pos);
- p->length = 4;
- p->next = dmaCbAdr(b+1);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaGpioOffCb(int b, int pos)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(b);
-
- p->info = NORMAL_DMA;
- p->src = dmaGpioOffAdr(pos);
- p->dst = ((GPIO_BASE + (GPCLR0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->length = 4;
- p->next = dmaCbAdr(b+1);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaReadLevelsCb(int b, int pos)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(b);
-
- p->info = NORMAL_DMA;
- p->src = ((GPIO_BASE + (GPLEV0*4)) & 0x00ffffff) | PI_PERI_BUS;
- p->dst = dmaReadLevelsAdr(pos);
- p->length = 4;
- p->next = dmaCbAdr(b+1);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaDelayCb(int b)
-{
- rawCbs_t * p;
-
- p = dmaCB2adr(b);
-
- if (gpioCfg.clockPeriph == PI_CLOCK_PCM)
- {
- p->info = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
-
- p->src = dmaPwmDataAdr(b%DMAI_PAGES);
- p->length = 4;
- p->next = dmaCbAdr(b+1);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void dmaInitCbs(void)
-{
- int b, pulse, level, cycle;
-
- rawCbs_t * p;
-
- /* set up the DMA control blocks */
-
- DBG(DBG_STARTUP, "");
-
- gpioStats.dmaInitCbsCount++;
-
- b = -1;
- level = 0;
-
- for (cycle=0; cyclenext = dmaCbAdr(0);
-
- DBG(DBG_STARTUP, "DMA page type count = %d", sizeof(dmaIPage_t));
-
- DBG(DBG_STARTUP, "%d control blocks (exp=%d)", b+1, NUM_CBS);
-}
-
-/* ======================================================================= */
-
-
-static void sigHandler(int signum)
-{
- if ((signum >= PI_MIN_SIGNUM) && (signum <= PI_MAX_SIGNUM))
- {
- if (gpioSignal[signum].func)
- {
- if (gpioSignal[signum].ex)
- {
- (gpioSignal[signum].func)(signum, gpioSignal[signum].userdata);
- }
- else
- {
- (gpioSignal[signum].func)(signum);
- }
- }
- else
- {
- switch(signum)
- {
- case SIGUSR1:
-
- if (gpioCfg.dbgLevel > DBG_MIN_LEVEL) --gpioCfg.dbgLevel;
- else gpioCfg.dbgLevel = DBG_MIN_LEVEL;
- DBG(DBG_USER, "Debug level %d\n", gpioCfg.dbgLevel);
- break;
-
- case SIGUSR2:
- if (gpioCfg.dbgLevel < DBG_MAX_LEVEL) ++gpioCfg.dbgLevel;
- else gpioCfg.dbgLevel = DBG_MAX_LEVEL;
- DBG(DBG_USER, "Debug level %d\n", gpioCfg.dbgLevel);
- break;
-
- case SIGPIPE:
- case SIGWINCH:
- DBG(DBG_USER, "signal %d ignored", signum);
- break;
-
- case SIGCHLD:
- /* Used to notify threads of events */
- break;
-
- default:
- DBG(DBG_ALWAYS, "Unhandled signal %d, terminating\n", signum);
- gpioTerminate();
- exit(-1);
- }
- }
- }
- else
- {
- /* exit */
-
- DBG(DBG_ALWAYS, "Unhandled signal %d, terminating\n", signum);
- gpioTerminate();
- exit(-1);
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void sigSetHandler(void)
-{
- int i;
- struct sigaction new;
-
- for (i=PI_MIN_SIGNUM; i<=PI_MAX_SIGNUM; i++)
- {
-
- memset(&new, 0, sizeof(new));
- new.sa_handler = sigHandler;
-
- sigaction(i, &new, NULL);
- }
-}
-
-/*
- freq mics net
- 0 1000 1000 900
- 1 4000 250 225
- 2 3750 266 240
- 3 3500 285 257
- 4 3250 307 276
- 5 3000 333 300
- 6 2750 363 327
- 7 2500 400 360
- 8 2250 444 400
- 9 2000 500 450
-10 1750 571 514
-11 1500 666 600
-12 1250 800 720
-13 1000 1000 900
-14 750 1333 1200
-15 500 2000 1800
-*/
-
-unsigned alert_delays[]=
-{
- 900000, 225000, 240000, 257142, 276923, 300000, 327272, 360000,
- 400000, 450000, 514285, 600000, 720000, 900000, 1200000, 1800000
-};
-
-/* ======================================================================= */
-
-static void alertGlitchFilter(gpioSample_t *sample, int numSamples)
-{
- int i, j, diff;
- uint32_t steadyUs, changedTick, RBitV, LBitV;
- uint32_t bit, bitV;
-
- for (i=0; i<=PI_MAX_USER_GPIO; i++)
- {
- bit = (1<= steadyUs)
- {
- /* Level stable for steady period. */
- RBitV = bitV;
- }
- else
- {
- /* Keep reporting old level. */
-
- sample[j].level ^= bit;
- }
- }
-
- }
-
- gpioAlert[i].gfRBitV = RBitV;
- gpioAlert[i].gfLBitV = LBitV;
- gpioAlert[i].gfTick = changedTick;
- }
- }
-}
-
-static void alertNoiseFilter(gpioSample_t *sample, int numSamples)
-{
- int i, j, diff;
- uint32_t LBitV;
- uint32_t bit, bitV;
- uint32_t nowTick;
-
- for (i=0; i<=PI_MAX_USER_GPIO; i++)
- {
- bit = (1<= 0)
- {
- /* Stop reporting gpio changes */
-
- gpioAlert[i].nfActive = 0;
- gpioAlert[i].nfTick1 = nowTick;
- }
- }
- else /* waiting for steady us */
- {
- if (bitV != LBitV)
- {
- diff = nowTick - gpioAlert[i].nfTick1;
- gpioAlert[i].nfTick1 = nowTick;
-
- if (diff >= gpioAlert[i].nfSteadyUs)
- {
- /* Start reporting gpio changes */
-
- gpioAlert[i].nfRBitV = LBitV;
- gpioAlert[i].nfActive = 1;
- gpioAlert[i].nfTick2 =
- nowTick + gpioAlert[i].nfActiveUs;
- }
- }
- }
-
- if (!gpioAlert[i].nfActive)
- {
- if (bitV != gpioAlert[i].nfRBitV)
- sample[j].level ^= bit;
- }
-
- LBitV = bitV;
- }
-
- gpioAlert[i].nfLBitV = LBitV;
-
- }
- }
-}
-
-static void alertEmit(
- gpioSample_t *sample, int numSamples, uint32_t changedBits, uint32_t eTick)
-{
- uint32_t oldLevel, newLevel;
- int32_t diff;
- int emit, seqno, emitted;
- uint32_t changes, bits, timeoutBits;
- int d;
- int b, n, v;
- int err;
- int max_emits;
- char fifo[32];
- gpioReport_t report[MAX_REPORT];
-
- if (changedBits)
- {
- if (gpioGetSamples.func)
- {
- if (gpioGetSamples.ex)
- {
- (gpioGetSamples.func)
- (sample, numSamples, gpioGetSamples.userdata);
- }
- else
- {
- (gpioGetSamples.func)(sample, numSamples);
- }
- }
- }
-
- /* call alert callbacks for each bit transition */
-
- if (changedBits & alertBits)
- {
- oldLevel = (reportedLevel & alertBits);
-
- for (d=0; d= gpioAlert[b].wdSteadyUs)
- {
- timeoutBits |= (1< 60000000)
- {
- if (numSamples)
- newLevel = sample[numSamples-1].level;
- else
- newLevel = reportedLevel;
-
- report[emit].seqno = seqno;
- report[emit].flags = PI_NTFY_FLAGS_ALIVE;
- report[emit].tick = eTick;
- report[emit].level = newLevel;
-
- emit++;
- seqno++;
- }
- }
-
- if (emit)
- {
- DBG(DBG_FAST_TICK, "notification %d (%d reports, %x-%x)",
- n, emit, report[0].seqno, report[emit-1].seqno);
- gpioNotify[n].lastReportTick = eTick;
- max_emits = gpioNotify[n].max_emits;
-
- if (emit > gpioStats.maxEmit) gpioStats.maxEmit = emit;
-
- emitted = 0;
-
- while (emit > 0)
- {
- if (emit > max_emits)
- {
- gpioStats.emitFrags++;
-
- err = write(gpioNotify[n].fd,
- report+emitted,
- max_emits*sizeof(gpioReport_t));
-
- if (err != (max_emits*sizeof(gpioReport_t)))
- {
- if (err < 0)
- {
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK))
- {
- /* serious error, no point continuing */
-
- DBG(DBG_ALWAYS, "fd=%d err=%d errno=%d",
- gpioNotify[n].fd, err, errno);
-
- DBG(DBG_ALWAYS, "%s", strerror(errno));
-
- gpioNotify[n].bits = 0;
- gpioNotify[n].state = PI_NOTIFY_CLOSING;
- intNotifyBits();
- break;
- }
- else gpioStats.wouldBlockPipeWrite++;
- }
- else
- {
- gpioStats.shortPipeWrite++;
- DBG(DBG_ALWAYS, "emitted %d, asked for %d",
- err/sizeof(gpioReport_t), max_emits);
- }
- }
- else
- {
- gpioStats.goodPipeWrite++;
- }
-
- emitted += max_emits;
- emit -= max_emits;
- }
- else
- {
- err = write(gpioNotify[n].fd,
- report+emitted,
- emit*sizeof(gpioReport_t));
-
- if (err != (emit*sizeof(gpioReport_t)))
- {
- if (err < 0)
- {
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK))
- {
- DBG(DBG_ALWAYS, "fd=%d err=%d errno=%d",
- gpioNotify[n].fd, err, errno);
-
- DBG(DBG_ALWAYS, "%s", strerror(errno));
-
- /* serious error, no point continuing */
- gpioNotify[n].bits = 0;
- gpioNotify[n].state = PI_NOTIFY_CLOSING;
- intNotifyBits();
- break;
- }
- else gpioStats.wouldBlockPipeWrite++;
- }
- else
- {
- gpioStats.shortPipeWrite++;
- DBG(DBG_ALWAYS, "emitted %d, asked for %d",
- err/sizeof(gpioReport_t), emit);
- }
- }
- else
- {
- gpioStats.goodPipeWrite++;
- }
-
- emitted += emit;
- emit = 0;
- }
- }
-
- gpioNotify[n].seqno = seqno;
- }
- }
- }
-
- if (changedBits & scriptBits)
- {
- for (n=0; n= PULSE_PER_CYCLE)
- {
- pulse = 0;
-
- if (++cycle >= bufferCycles)
- {
- cycle = 0;
- oldSlot = 0;
- }
-
- expected = sTick;
-
- sTick = myGetTick(cycle);
-
- if (stickInited)
- {
- diff = sTick - expected;
-
- if (abs(diff) > minDiff)
- {
- ft = sample[numSamples-PULSE_PER_CYCLE].tick;
-
- ticks = sTick - ft;
-
- for (i=1; i= TICKSLOTS)
- {
- gpioStats.diffTick[TICKSLOTS-1]++;
- }
-
- else gpioStats.diffTick[diff]++;
- }
- else
- {
- stickInited = 1;
- numSamples = 0;
- }
- }
- }
-
- if (oldSlot == newSlot) moreToDo = 0; else moreToDo = 1;
-
- /* Apply glitch filter */
-
- if (numSamples && gFilterBits) alertGlitchFilter(sample, numSamples);
-
- /* Apply noise filter */
-
- if (numSamples && nFilterBits) alertNoiseFilter(sample, numSamples);
-
- /* Compact samples */
-
- changedBits = 0;
- oldLevel &= monitorBits;
- reports = 0;
- totalSamples = 0;
-
- for (rp=0; rp= MAX_REPORT)
- {
- totalSamples += reports;
-
- /* Rebase watchdog timeouts */
- if (wdogBits) alertWdogCheck(sample, reports);
-
- gpioStats.numSamples += reports;
-
- alertEmit(sample, reports, changedBits, sample[rp].tick);
-
- changedBits = 0;
- reports = 0;
- }
- }
- }
-
- if (reports)
- {
- totalSamples += reports;
-
- /* Rebase watchdog timeouts */
- if (wdogBits) alertWdogCheck(sample, reports);
-
- gpioStats.numSamples += reports;
- }
-
- alertEmit(sample, reports, changedBits, sTick);
-
- if (totalSamples > gpioStats.maxSamples)
- gpioStats.maxSamples = numSamples;
-
- req.tv_sec = 0;
- req.tv_nsec = alert_delays[(gpioCfg.internals>>PI_CFG_ALERT_FREQ)&15];
-
- if (moreToDo)
- {
- gpioStats.moreToDo++;
- }
- else
- {
- gpioStats.alertTicks++;
-
- while (nanosleep(&req, &rem))
- {
- req.tv_sec = rem.tv_sec;
- req.tv_nsec = rem.tv_nsec;
- }
- }
- }
-
- return 0;
-}
-
-/* ======================================================================= */
-
-static int scrPop(gpioScript_t *s, int *SP, int *S)
-{
- if ((*SP) > 0)
- {
- return S[--(*SP)];
- }
- else
- {
- s->run_state = PI_SCRIPT_FAILED;
- DBG(DBG_ALWAYS, "script %d too many pops", s->id);
- return 0;
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void scrPush(gpioScript_t *s, int *SP, int *S, int val)
-{
- if ((*SP) < PI_SCRIPT_STACK_SIZE)
- {
- S[(*SP)++] = val;
- }
- else
- {
- s->run_state = PI_SCRIPT_FAILED;
- DBG(DBG_ALWAYS, "script %d too many pushes", s->id);
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void scrSwap(int *v1, int *v2)
-{
- int t;
-
- t=*v1; *v1=*v2; *v2= t;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int scrWait(gpioScript_t *s, uint32_t bits)
-{
- pthread_mutex_lock(&s->pthMutex);
-
- if (s->request == PI_SCRIPT_RUN)
- {
- s->run_state = PI_SCRIPT_WAITING;
- s->waitBits = bits;
- intScriptBits();
-
- pthread_cond_wait(&s->pthCond, &s->pthMutex);
-
- s->waitBits = 0;
- intScriptBits();
- s->run_state = PI_SCRIPT_RUNNING;
- }
-
- pthread_mutex_unlock(&s->pthMutex);
-
- return s->changedBits;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int scrSys(char *cmd, uint32_t p1, uint32_t p2)
-{
- char buf[1024];
- int status;
-
- if (!myScriptNameValid(cmd))
- SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", cmd);
-
- snprintf(buf, sizeof(buf), "/opt/pigpio/cgi/%s %u %u", cmd, p1, p2);
-
- DBG(DBG_USER, "%s", buf);
-
- status = system(buf);
-
- if (status < 0) status = PI_BAD_SHELL_STATUS;
-
- return status;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void *pthScript(void *x)
-{
- gpioScript_t *s;
- cmdInstr_t instr;
- int p1, p2, p1o, p2o, *t1, *t2;
- int PC, A, F, SP;
- int S[PI_SCRIPT_STACK_SIZE];
- char buf[CMD_MAX_EXTENSION];
-
-
- S[0] = 0; /* to prevent compiler warning */
-
- s = x;
-
- while ((volatile int)s->request != PI_SCRIPT_DELETE)
- {
- pthread_mutex_lock(&s->pthMutex);
- s->run_state = PI_SCRIPT_HALTED;
- pthread_cond_wait(&s->pthCond, &s->pthMutex);
- pthread_mutex_unlock(&s->pthMutex);
-
- s->run_state = PI_SCRIPT_RUNNING;
-
- A = 0;
- F = 0;
- PC = 0;
- SP = 0;
-
- while (((volatile int)s->request == PI_SCRIPT_RUN ) &&
- (s->run_state == PI_SCRIPT_RUNNING))
- {
- instr = s->script.instr[PC];
-
- p1o = instr.p[1];
- p2o = instr.p[2];
-
- if (instr.opt[1] == CMD_VAR) instr.p[1] = s->script.var[p1o];
- else if (instr.opt[1] == CMD_PAR) instr.p[1] = s->script.par[p1o];
-
- if (instr.opt[2] == CMD_VAR) instr.p[2] = s->script.var[p2o];
- else if (instr.opt[2] == CMD_PAR) instr.p[2] = s->script.par[p2o];
-/*
- fprintf(stderr, "PC=%d cmd=%d p1o=%d p1=%d p2o=%d p2=%d\n",
- PC, instr.p[0], p1o, instr.p[1], p2o, instr.p[2]);
- fflush(stderr);
-*/
- if (instr.p[0] < 100)
- {
- if (instr.p[3])
- {
- memcpy(buf, (char *)instr.p[4], instr.p[3]);
- }
-
- A = myDoCommand(instr.p, sizeof(buf)-1, buf);
-
- F = A;
-
- PC++;
- }
- else
- {
- p1 = instr.p[1];
- p2 = instr.p[2];
-
- switch (instr.p[0])
- {
- case PI_CMD_ADD: A+=p1; F=A; PC++; break;
-
- case PI_CMD_AND: A&=p1; F=A; PC++; break;
-
- case PI_CMD_CALL: scrPush(s, &SP, S, PC+1); PC = p1; break;
-
- case PI_CMD_CMP: F=A-p1; PC++; break;
-
- case PI_CMD_DCR:
- if (instr.opt[1] == CMD_PAR)
- {--s->script.par[p1o]; F=s->script.par[p1o];}
- else
- {--s->script.var[p1o]; F=s->script.var[p1o];}
- PC++;
- break;
-
- case PI_CMD_DCRA: --A; F=A; PC++; break;
-
- case PI_CMD_DIV: A/=p1; F=A; PC++; break;
-
- case PI_CMD_HALT: s->run_state = PI_SCRIPT_HALTED; break;
-
- case PI_CMD_INR:
- if (instr.opt[1] == CMD_PAR)
- {++s->script.par[p1o]; F=s->script.par[p1o];}
- else
- {++s->script.var[p1o]; F=s->script.var[p1o];}
- PC++;
- break;
-
- case PI_CMD_INRA: ++A; F=A; PC++; break;
-
- case PI_CMD_JM: if (F<0) PC=p1; else PC++; break;
-
- case PI_CMD_JMP: PC=p1; break;
-
- case PI_CMD_JNZ: if (F) PC=p1; else PC++; break;
-
- case PI_CMD_JP: if (F>=0) PC=p1; else PC++; break;
-
- case PI_CMD_JZ: if (!F) PC=p1; else PC++; break;
-
- case PI_CMD_LD:
- if (instr.opt[1] == CMD_PAR) s->script.par[p1o]=p2;
- else s->script.var[p1o]=p2;
- PC++;
- break;
-
- case PI_CMD_LDA: A=p1; PC++; break;
-
- case PI_CMD_LDAB:
- if ((p1 >= 0) && (p1 < sizeof(buf))) A = buf[p1];
- PC++;
- break;
-
- case PI_CMD_MLT: A*=p1; F=A; PC++; break;
-
- case PI_CMD_MOD: A%=p1; F=A; PC++; break;
-
- case PI_CMD_OR: A|=p1; F=A; PC++; break;
-
- case PI_CMD_POP:
- if (instr.opt[1] == CMD_PAR)
- s->script.par[p1o]=scrPop(s, &SP, S);
- else
- s->script.var[p1o]=scrPop(s, &SP, S);
- PC++;
- break;
-
- case PI_CMD_POPA: A=scrPop(s, &SP, S); PC++; break;
-
- case PI_CMD_PUSH:
- if (instr.opt[1] == CMD_PAR)
- scrPush(s, &SP, S, s->script.par[p1o]);
- else
- scrPush(s, &SP, S, s->script.var[p1o]);
- PC++;
- break;
-
- case PI_CMD_PUSHA: scrPush(s, &SP, S, A); PC++; break;
-
- case PI_CMD_RET: PC=scrPop(s, &SP, S); break;
-
- case PI_CMD_RL:
- if (instr.opt[1] == CMD_PAR)
- {s->script.par[p1o]<<=p2; F=s->script.par[p1o];}
- else
- {s->script.var[p1o]<<=p2; F=s->script.var[p1o];}
- PC++;
- break;
-
- case PI_CMD_RLA: A<<=p1; F=A; PC++; break;
-
- case PI_CMD_RR:
- if (instr.opt[1] == CMD_PAR)
- {s->script.par[p1o]>>=p2; F=s->script.par[p1o];}
- else
- {s->script.var[p1o]>>=p2; F=s->script.var[p1o];}
- PC++;
- break;
-
- case PI_CMD_RRA: A>>=p1; F=A; PC++; break;
-
- case PI_CMD_STA:
- if (instr.opt[1] == CMD_PAR) s->script.par[p1o]=A;
- else s->script.var[p1o]=A;
- PC++;
- break;
-
- case PI_CMD_STAB:
- if ((p1 >= 0) && (p1 < sizeof(buf))) buf[p1] = A;
- PC++;
- break;
-
- case PI_CMD_SUB: A-=p1; F=A; PC++; break;
-
- case PI_CMD_SYS:
- A=scrSys((char*)instr.p[4], A, *(gpioReg + GPLEV0));
- F=A;
- PC++;
- break;
-
- case PI_CMD_WAIT: A=scrWait(s, p1); F=A; PC++; break;
-
- case PI_CMD_X:
- if (instr.opt[1] == CMD_PAR) t1 = &s->script.par[p1o];
- else t1 = &s->script.var[p1o];
-
- if (instr.opt[2] == CMD_PAR) t2 = &s->script.par[p2o];
- else t2 = &s->script.var[p2o];
-
- scrSwap(t1, t2);
- PC++;
- break;
-
- case PI_CMD_XA:
- if (instr.opt[1] == CMD_PAR)
- scrSwap(&s->script.par[p1o], &A);
- else
- scrSwap(&s->script.var[p1o], &A);
- PC++;
- break;
-
- case PI_CMD_XOR: A^=p1; F=A; PC++; break;
-
- }
- }
-
- if (PC >= s->script.instrs) s->run_state = PI_SCRIPT_HALTED;
-
- }
-
- if ((volatile int)s->request == PI_SCRIPT_HALT)
- s->run_state = PI_SCRIPT_HALTED;
-
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void * pthTimerTick(void *x)
-{
- gpioTimer_t * tp;
- struct timespec req, rem, period;
- char buf[256];
-
- tp = x;
-
- clock_gettime(CLOCK_REALTIME, &tp->nextTick);
-
- while (1)
- {
- clock_gettime(CLOCK_REALTIME, &rem);
-
- period.tv_sec = tp->millis / THOUSAND;
- period.tv_nsec = (tp->millis % THOUSAND) * THOUSAND * THOUSAND;
-
- do
- {
- TIMER_ADD(&tp->nextTick, &period, &tp->nextTick);
-
- TIMER_SUB(&tp->nextTick, &rem, &req);
- }
- while (req.tv_sec < 0);
-
- while (nanosleep(&req, &rem))
- {
- req.tv_sec = rem.tv_sec;
- req.tv_nsec = rem.tv_nsec;
- }
-
- if (gpioCfg.dbgLevel >= DBG_SLOW_TICK)
- {
- if ((tp->millis > 50) || (gpioCfg.dbgLevel >= DBG_FAST_TICK))
- {
- sprintf(buf, "pigpio: TIMER=%d @ %u %u\n",
- tp->id,
- (unsigned)tp->nextTick.tv_sec,
- (unsigned)tp->nextTick.tv_nsec);
- fprintf(stderr, buf);
- }
- }
-
- if (tp->ex) (tp->func)(tp->userdata);
- else (tp->func)();
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-
-static void * pthFifoThread(void *x)
-{
- char buf[CMD_MAX_EXTENSION];
- int idx, flags, len, res, i;
- uint32_t p[CMD_P_ARR];
- cmdCtlParse_t ctl;
- uint32_t *param;
- char v[CMD_MAX_EXTENSION];
-
- myCreatePipe(PI_INPFIFO, 0662);
-
- if ((inpFifo = fopen(PI_INPFIFO, "r+")) == NULL)
- SOFT_ERROR((void*)PI_INIT_FAILED, "fopen %s failed(%m)", PI_INPFIFO);
-
- myCreatePipe(PI_OUTFIFO, 0664);
-
- if ((outFifo = fopen(PI_OUTFIFO, "w+")) == NULL)
- SOFT_ERROR((void*)PI_INIT_FAILED, "fopen %s failed (%m)", PI_OUTFIFO);
-
- /* set outFifo non-blocking */
-
- flags = fcntl(fileno(outFifo), F_GETFL, 0);
- fcntl(fileno(outFifo), F_SETFL, flags | O_NONBLOCK);
-
- /* don't start until DMA started */
-
- spinWhileStarting();
-
- while (1)
- {
- if (fgets(buf, sizeof(buf), inpFifo) == NULL)
- SOFT_ERROR((void*)PI_INIT_FAILED, "fifo fgets failed (%m)");
-
- len = strlen(buf);
-
- if (len)
- {
- --len;
- buf[len] = 0; /* replace terminating */
- }
-
- ctl.eaten = 0;
- idx = 0;
-
- while (((ctl.eaten)= 0))
- {
- if ((idx=cmdParse(buf, p, CMD_MAX_EXTENSION, v, &ctl)) >= 0)
- {
- /* make sure extensions are null terminated */
-
- v[p[3]] = 0;
-
- res = myDoCommand(p, sizeof(v)-1, v);
-
- switch (cmdInfo[idx].rv)
- {
- case 0:
- fprintf(outFifo, "%d\n", res);
- break;
-
- case 1:
- fprintf(outFifo, "%d\n", res);
- break;
-
- case 2:
- fprintf(outFifo, "%d\n", res);
- break;
-
- case 3:
- fprintf(outFifo, "%08X\n", res);
- break;
-
- case 4:
- fprintf(outFifo, "%u\n", res);
- break;
-
- case 5:
- fprintf(outFifo, cmdUsage);
- break;
-
- case 6:
- fprintf(outFifo, "%d", res);
- if (res > 0)
- {
- for (i=0; i= 0)
- {
- memcpy(buf, &p[3], 4);
- p[3] = 4 + (4*PI_MAX_SCRIPT_PARAMS);
- }
- break;
-
- default:
- p[3] = myDoCommand(p, sizeof(buf)-1, buf);
- }
-
- write(sock, p, 16);
-
- switch (p[0])
- {
- /* extensions */
-
- case PI_CMD_BI2CZ:
- case PI_CMD_CF2:
- case PI_CMD_FL:
- case PI_CMD_FR:
- case PI_CMD_I2CPK:
- case PI_CMD_I2CRD:
- case PI_CMD_I2CRI:
- case PI_CMD_I2CRK:
- case PI_CMD_I2CZ:
- case PI_CMD_PROCP:
- case PI_CMD_SERR:
- case PI_CMD_SLR:
- case PI_CMD_SPIX:
- case PI_CMD_SPIR:
- case PI_CMD_BSPIX:
-
- if (((int)p[3]) > 0)
- {
- write(sock, buf, p[3]);
- }
- break;
-
- default:
- break;
- }
- }
-
- closeOrphanedNotifications(-1, sock);
-
- close(sock);
-
- return 0;
-}
-
-static int addrAllowed(uint32_t addr)
-{
- int i;
-
- if (!numSockNetAddr) return 1;
-
- for (i=0; i= 0)
- {
- pthread_t thr;
-
- fdC = accept(fdSock, (struct sockaddr *)&client, (socklen_t*)&c);
-
- closeOrphanedNotifications(-1, fdC);
-
- if (addrAllowed(client.sin_addr.s_addr))
- {
- sock = malloc(sizeof(int));
-
- *sock = fdC;
-
- if (pthread_create
- (&thr, &attr, pthSocketThreadHandler, (void*) sock) < 0)
- SOFT_ERROR((void*)PI_INIT_FAILED,
- "socket pthread_create failed (%m)");
- }
- else
- {
- close(fdC);
- }
- }
-
- if (fdC < 0)
- SOFT_ERROR((void*)PI_INIT_FAILED, "accept failed (%m)");
-
- return 0;
-}
-
-/* ======================================================================= */
-
-static void initCheckLockFile(void)
-{
- int fd;
- int count;
- int pid;
- int err;
- int delete;
- char str[20];
-
- fd = open(PI_LOCKFILE, O_RDONLY);
-
- if (fd != -1)
- {
- DBG(DBG_STARTUP, "lock file exists");
- delete = 1;
-
- count = read(fd, str, sizeof(str)-1);
-
- if (count)
- {
- pid = atoi(str);
- err = kill(pid, 0);
- if (!err) delete = 0; /* process still exists */
- DBG(DBG_STARTUP, "lock file pid=%d err=%d", pid, err);
- }
-
- close(fd);
- DBG(DBG_STARTUP, "lock file delete=%d", delete);
-
- if (delete) unlink(PI_LOCKFILE);
- }
-}
-
-static int initGrabLockFile(void)
-{
- int fd;
- int lockResult;
- char pidStr[20];
-
- initCheckLockFile();
-
- /* try to grab the lock file */
-
- fd = open(PI_LOCKFILE, O_WRONLY|O_CREAT|O_EXCL|O_TRUNC, 0644);
-
- if (fd != -1)
- {
- lockResult = flock(fd, LOCK_EX|LOCK_NB);
-
- if(lockResult == 0)
- {
- sprintf(pidStr, "%d\n", (int)getpid());
-
- write(fd, pidStr, strlen(pidStr));
- }
- else
- {
- close(fd);
- return -1;
- }
- }
-
- return fd;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static uint32_t * initMapMem(int fd, uint32_t addr, uint32_t len)
-{
- return (uint32_t *) mmap(0, len,
- PROT_READ|PROT_WRITE|PROT_EXEC,
- MAP_SHARED|MAP_LOCKED,
- fd, addr);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int initCheckPermitted(void)
-{
- DBG(DBG_STARTUP, "");
-
- if ((fdMem = open("/dev/mem", O_RDWR | O_SYNC) ) < 0)
- {
- DBG(DBG_ALWAYS,
- "\n" \
- "+---------------------------------------------------------+\n" \
- "|Sorry, you don't have permission to run this program. |\n" \
- "|Try running as root, e.g. precede the command with sudo. |\n" \
- "+---------------------------------------------------------+\n\n");
- return -1;
- }
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int initPeripherals(void)
-{
- uint32_t dmaBase;
-
- DBG(DBG_STARTUP, "");
-
- gpioReg = initMapMem(fdMem, GPIO_BASE, GPIO_LEN);
-
- if (gpioReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap gpio failed (%m)");
-
- /* dma channels 0-14 share one page, 15 has another */
-
- if (gpioCfg.DMAprimaryChannel < 15)
- {
- dmaBase = DMA_BASE;
- }
- else dmaBase = DMA15_BASE;
-
- dmaReg = initMapMem(fdMem, dmaBase, DMA_LEN);
-
- if (dmaReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap dma failed (%m)");
-
- if (gpioCfg.DMAprimaryChannel < 15)
- {
- dmaIn = dmaReg + (gpioCfg.DMAprimaryChannel * 0x40);
- dmaOut = dmaReg + (gpioCfg.DMAsecondaryChannel * 0x40);
- }
-
- DBG(DBG_STARTUP, "DMA #%d @ %08X @ %08X",
- gpioCfg.DMAprimaryChannel, dmaBase, (uint32_t)dmaIn);
-
- DBG(DBG_STARTUP, "debug reg is %08X", dmaIn[DMA_DEBUG]);
-
- clkReg = initMapMem(fdMem, CLK_BASE, CLK_LEN);
-
- if (clkReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap clk failed (%m)");
-
- systReg = initMapMem(fdMem, SYST_BASE, SYST_LEN);
-
- if (systReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap syst failed (%m)");
-
- spiReg = initMapMem(fdMem, SPI_BASE, SPI_LEN);
-
- if (spiReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap spi failed (%m)");
-
- pwmReg = initMapMem(fdMem, PWM_BASE, PWM_LEN);
-
- if (pwmReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap pwm failed (%m)");
-
- pcmReg = initMapMem(fdMem, PCM_BASE, PCM_LEN);
-
- if (pcmReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap pcm failed (%m)");
-
- auxReg = initMapMem(fdMem, AUX_BASE, AUX_LEN);
-
- if (auxReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap aux failed (%m)");
-
- padsReg = initMapMem(fdMem, PADS_BASE, PADS_LEN);
-
- if (padsReg == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap pads failed (%m)");
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int initZaps
- (int pmapFd, void *virtualBase, int basePage, int pages)
-{
- int n;
- long index;
- off_t offset;
- ssize_t t;
- uint32_t physical;
- int status;
- uint32_t pageAdr;
- unsigned long long pa;
-
- DBG(DBG_STARTUP, "");
-
- status = 0;
-
- pageAdr = (uint32_t) dmaVirt[basePage];
-
- index = ((uint32_t)virtualBase / PAGE_SIZE) * 8;
-
- offset = lseek(pmapFd, index, SEEK_SET);
-
- if (offset != index)
- SOFT_ERROR(PI_INIT_FAILED, "lseek pagemap failed (%m)");
-
- for (n=0; n PI_DEFAULT_BUFFER_MILLIS)))
- {
- /* pagemap allocation of DMA memory */
-
- dmaPMapBlk = mmap(
- 0, (bufferBlocks+PI_WAVE_BLOCKS)*sizeof(dmaPage_t *),
- PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED,
- -1, 0);
-
- if (dmaPMapBlk == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "pagemap mmap block failed (%m)");
-
- fdPmap = open("/proc/self/pagemap", O_RDONLY);
-
- if (fdPmap < 0)
- SOFT_ERROR(PI_INIT_FAILED, "pagemap open failed(%m)");
-
- for (i=0; i<(bufferBlocks+PI_WAVE_BLOCKS); i++)
- {
- status = initPagemapBlock(i);
- if (status < 0)
- {
- close(fdPmap);
- return status;
- }
- }
-
- close(fdPmap);
-
- DBG(DBG_STARTUP, "dmaPMapBlk=%08X dmaIn=%08X",
- (uint32_t)dmaPMapBlk, (uint32_t)dmaIn);
- }
- else
- {
- /* mailbox allocation of DMA memory */
-
- dmaMboxBlk = mmap(
- 0, (bufferBlocks+PI_WAVE_BLOCKS)*sizeof(DMAMem_t),
- PROT_READ|PROT_WRITE,
- MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED,
- -1, 0);
-
- if (dmaMboxBlk == MAP_FAILED)
- SOFT_ERROR(PI_INIT_FAILED, "mmap mbox block failed (%m)");
-
- fdMbox = mbOpen();
-
- if (fdMbox < 0)
- SOFT_ERROR(PI_INIT_FAILED, "mbox open failed(%m)");
-
- for (i=0; i<(bufferBlocks+PI_WAVE_BLOCKS); i++)
- {
- status = initMboxBlock(i);
- if (status < 0)
- {
- mbClose(fdMbox);
- return status;
- }
- }
-
- mbClose(fdMbox);
-
- DBG(DBG_STARTUP, "dmaMboxBlk=%08X dmaIn=%08X",
- (uint32_t)dmaMboxBlk, (uint32_t)dmaIn);
- }
-
- DBG(DBG_STARTUP,
- "gpioReg=%08X pwmReg=%08X pcmReg=%08X clkReg=%08X auxReg=%08X",
- (uint32_t)gpioReg, (uint32_t)pwmReg,
- (uint32_t)pcmReg, (uint32_t)clkReg, (uint32_t)auxReg);
-
- for (i=0; i= DBG_DMACBS)
- {
- fprintf(stderr, "*** INPUT DMA CONTROL BLOCKS ***\n");
- for (i=0; iperiphData = 1;
-
- /* enable PWM DMA, raise panic and dreq thresholds to 15 */
-
- pwmReg[PWM_DMAC] = PWM_DMAC_ENAB |
- PWM_DMAC_PANIC(15) |
- PWM_DMAC_DREQ(15);
-
- myGpioDelay(10);
-
- /* clear PWM fifo */
-
- pwmReg[PWM_CTL] = PWM_CTL_CLRF1;
-
- myGpioDelay(10);
-
- /* enable PWM channel 1 and use fifo */
-
- pwmReg[PWM_CTL] = PWM_CTL_USEF1 | PWM_CTL_MODE1 | PWM_CTL_PWEN1;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void initPCM(unsigned bits)
-{
- DBG(DBG_STARTUP, "bits=%d", bits);
-
- /* disable PCM so we can modify the regs */
-
- pcmReg[PCM_CS] = 0;
-
- myGpioDelay(1000);
-
- pcmReg[PCM_FIFO] = 0;
- pcmReg[PCM_MODE] = 0;
- pcmReg[PCM_RXC] = 0;
- pcmReg[PCM_TXC] = 0;
- pcmReg[PCM_DREQ] = 0;
- pcmReg[PCM_INTEN] = 0;
- pcmReg[PCM_INTSTC] = 0;
- pcmReg[PCM_GRAY] = 0;
-
- myGpioDelay(1000);
-
- pcmReg[PCM_MODE] = PCM_MODE_FLEN(bits-1); /* # bits in frame */
-
- /* enable channel 1 with # bits width */
-
- pcmReg[PCM_TXC] = PCM_TXC_CH1EN | PCM_TXC_CH1WID(bits-8);
-
- pcmReg[PCM_CS] |= PCM_CS_STBY; /* clear standby */
-
- myGpioDelay(1000);
-
- pcmReg[PCM_CS] |= PCM_CS_TXCLR; /* clear TX FIFO */
-
- pcmReg[PCM_CS] |= PCM_CS_DMAEN; /* enable DREQ */
-
- pcmReg[PCM_DREQ] = PCM_DREQ_TX_PANIC(16) | PCM_DREQ_TX_REQ_L(30);
-
- pcmReg[PCM_INTSTC] = 0b1111; /* clear status bits */
-
- /* enable PCM */
-
- pcmReg[PCM_CS] |= PCM_CS_EN;
-
- /* enable tx */
-
- pcmReg[PCM_CS] |= PCM_CS_TXON;
-
- dmaIVirt[0]->periphData = 0x0F;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void initHWClk
- (int clkCtl, int clkDiv, int clkSrc, int divI, int divF, int MASH)
-{
- DBG(DBG_INTERNAL, "ctl=%d div=%d src=%d /I=%d /f=%d M=%d",
- clkCtl, clkDiv, clkSrc, divI, divF, MASH);
-
- /* kill the clock if busy, anything else isn't reliable */
-
- if (clkReg[clkCtl] & CLK_CTL_BUSY)
- {
- do
- {
- clkReg[clkCtl] = BCM_PASSWD | CLK_CTL_KILL;
- }
- while (clkReg[clkCtl] & CLK_CTL_BUSY);
- }
-
- clkReg[clkDiv] = (BCM_PASSWD | CLK_DIV_DIVI(divI) | CLK_DIV_DIVF(divF));
-
- usleep(10);
-
- clkReg[clkCtl] = (BCM_PASSWD | CLK_CTL_MASH(MASH) | CLK_CTL_SRC(clkSrc));
-
- usleep(10);
-
- clkReg[clkCtl] |= (BCM_PASSWD | CLK_CTL_ENAB);
-}
-
-static void initClock(int mainClock)
-{
- const unsigned BITS=10;
- int clockPWM;
- unsigned clkCtl, clkDiv, clkSrc, clkDivI, clkDivF, clkMash, clkBits;
- char *per;
- unsigned micros;
-
- DBG(DBG_STARTUP, "mainClock=%d", mainClock);
-
- if (mainClock) micros = gpioCfg.clockMicros;
- else micros = PI_WF_MICROS;
-
- clockPWM = mainClock ^ (gpioCfg.clockPeriph == PI_CLOCK_PCM);
-
- if (clockPWM)
- {
- clkCtl = CLK_PWMCTL;
- clkDiv = CLK_PWMDIV;
- per = "PWM";
- }
- else
- {
- clkCtl = CLK_PCMCTL;
- clkDiv = CLK_PCMDIV;
- per = "PCM";
- }
-
- clkSrc = CLK_CTL_SRC_PLLD;
- clkDivI = 50 * micros; /* 10 MHz - 1 MHz */
- clkBits = BITS; /* 10/BITS MHz - 1/BITS MHz */
- clkDivF = 0;
- clkMash = 0;
-
- DBG(DBG_STARTUP, "%s PLLD divi=%d divf=%d mash=%d bits=%d",
- per, clkDivI, clkDivF, clkMash, clkBits);
-
- initHWClk(clkCtl, clkDiv, clkSrc, clkDivI, clkDivF, clkMash);
-
- if (clockPWM) initPWM(BITS);
- else initPCM(BITS);
-
- myGpioDelay(2000);
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void initDMAgo(volatile uint32_t *dmaAddr, uint32_t cbAddr)
-{
- DBG(DBG_STARTUP, "");
-
- dmaAddr[DMA_CS] = DMA_CHANNEL_RESET;
-
- dmaAddr[DMA_CS] = DMA_INTERRUPT_STATUS | DMA_END_FLAG;
-
- dmaAddr[DMA_CONBLK_AD] = cbAddr;
-
- /* clear READ/FIFO/READ_LAST_NOT_SET error bits */
-
- dmaAddr[DMA_DEBUG] = DMA_DEBUG_READ_ERR |
- DMA_DEBUG_FIFO_ERR |
- DMA_DEBUG_RD_LST_NOT_SET_ERR;
-
-
- dmaAddr[DMA_CS] = DMA_WAIT_ON_WRITES |
- DMA_PANIC_PRIORITY(8) |
- DMA_PRIORITY(8) |
- DMA_ACTIVATE;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void initClearGlobals(void)
-{
- int i;
-
- DBG(DBG_STARTUP, "");
-
- alertBits = 0;
- monitorBits = 0;
- notifyBits = 0;
- scriptBits = 0;
- gFilterBits = 0;
- nFilterBits = 0;
- wdogBits = 0;
-
- pthAlertRunning = 0;
- pthFifoRunning = 0;
- pthSocketRunning = 0;
-
- wfc[0] = 0;
- wfc[1] = 0;
- wfc[2] = 0;
-
- wfcur=0;
-
- wfStats.micros = 0;
- wfStats.highMicros = 0;
- wfStats.maxMicros = PI_WAVE_MAX_MICROS;
-
- wfStats.pulses = 0;
- wfStats.highPulses = 0;
- wfStats.maxPulses = PI_WAVE_MAX_PULSES;
-
- wfStats.cbs = 0;
- wfStats.highCbs = 0;
- wfStats.maxCbs = (PI_WAVE_BLOCKS * PAGES_PER_BLOCK * CBS_PER_OPAGE);
-
- gpioGetSamples.func = NULL;
- gpioGetSamples.ex = 0;
- gpioGetSamples.userdata = NULL;
- gpioGetSamples.bits = 0;
-
- for (i=0; i<=PI_MAX_USER_GPIO; i++)
- {
- wfRx[i].mode = PI_WFRX_NONE;
- pthread_mutex_init(&wfRx[i].mutex, NULL);
- gpioAlert[i].func = NULL;
- }
-
- for (i=0; i<=PI_MAX_GPIO; i++)
- {
- gpioInfo [i].is = GPIO_UNDEFINED;
- gpioInfo [i].width = 0;
- gpioInfo [i].range = PI_DEFAULT_DUTYCYCLE_RANGE;
- gpioInfo [i].freqIdx = DEFAULT_PWM_IDX;
- }
-
- for (i=0; i> 4) & 0xFF;
-
- /* model
- 0=A 1=B
- 2=A+ 3=B+
- 4=Pi2B
- 5=Alpha
- 6=Compute Module
- 7=Unknown
- 8=Pi3B
- 9=Zero
- */
- if (model < 2) gpioMask = PI_DEFAULT_UPDATE_MASK_A_B2;
- else if (model < 4) gpioMask = PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS;
- else if (model == 4) gpioMask = PI_DEFAULT_UPDATE_MASK_PI2B;
- else if (model == 6) gpioMask = PI_DEFAULT_UPDATE_MASK_COMPUTE;
- else if (model == 8) gpioMask = PI_DEFAULT_UPDATE_MASK_PI3B;
- else if (model == 9) gpioMask = PI_DEFAULT_UPDATE_MASK_ZERO;
- else gpioMask = PI_DEFAULT_UPDATE_MASK_UNKNOWN;
- }
-
- gpioMaskSet = 1;
- }
-
-#ifndef EMBEDDED_IN_VM
- sigSetHandler();
-#endif
-
- if (initPeripherals() < 0) return PI_INIT_FAILED;
-
- if (initAllocDMAMem() < 0) return PI_INIT_FAILED;
-
- /* done with /dev/mem */
-
- if (fdMem != -1)
- {
- close(fdMem);
- fdMem = -1;
- }
-
- param.sched_priority = sched_get_priority_max(SCHED_FIFO);
-
- if (gpioCfg.internals & PI_CFG_RT_PRIORITY)
- sched_setscheduler(0, SCHED_FIFO, ¶m);
-
- initClock(1); /* initialise main clock */
-
- atexit(gpioTerminate);
-
- if (pthread_attr_init(&pthAttr))
- SOFT_ERROR(PI_INIT_FAILED, "pthread_attr_init failed (%m)");
-
- if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE))
- SOFT_ERROR(PI_INIT_FAILED, "pthread_attr_setstacksize failed (%m)");
-
- if (pthread_create(&pthAlert, &pthAttr, pthAlertThread, &i))
- SOFT_ERROR(PI_INIT_FAILED, "pthread_create alert failed (%m)");
-
- pthAlertRunning = 1;
-
- if (!(gpioCfg.ifFlags & PI_DISABLE_FIFO_IF))
- {
- if (pthread_create(&pthFifo, &pthAttr, pthFifoThread, &i))
- SOFT_ERROR(PI_INIT_FAILED, "pthread_create fifo failed (%m)");
-
- pthFifoRunning = 1;
- }
-
- if (!(gpioCfg.ifFlags & PI_DISABLE_SOCK_IF))
- {
- fdSock = socket(AF_INET , SOCK_STREAM , 0);
-
- if (fdSock == -1)
- SOFT_ERROR(PI_INIT_FAILED, "socket failed (%m)");
-
- portStr = getenv(PI_ENVPORT);
-
- if (portStr) port = atoi(portStr); else port = gpioCfg.socketPort;
-
- server.sin_family = AF_INET;
- if (gpioCfg.ifFlags & PI_LOCALHOST_SOCK_IF)
- {
- server.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- }
- else
- {
- server.sin_addr.s_addr = htonl(INADDR_ANY);
- }
- server.sin_port = htons(port);
-
- if (bind(fdSock,(struct sockaddr *)&server , sizeof(server)) < 0)
- SOFT_ERROR(PI_INIT_FAILED, "bind to port %d failed (%m)", port);
-
- if (pthread_create(&pthSocket, &pthAttr, pthSocketThread, &i))
- SOFT_ERROR(PI_INIT_FAILED, "pthread_create socket failed (%m)");
-
- pthSocketRunning = 1;
- }
-
- myGpioDelay(10000);
-
- dmaInitCbs();
-
- flushMemory();
-
- initDMAgo((uint32_t *)dmaIn, (uint32_t)dmaIBus[0]);
-
- myGpioDelay(20000);
-
- return PIGPIO_VERSION;
-}
-
-
-/* ======================================================================= */
-
-int getBitInBytes(int bitPos, char *buf, int numBits)
-{
- int bitp, bufp;
-
- if (bitPos < numBits)
- {
- bufp = bitPos / 8;
- bitp = 7 - (bitPos % 8);
- if (buf[bufp] & (1<= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot(pos, &page, &slot);
- return (dmaOVirt[page]->OOL[slot]);
- }
-
- return -1;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void rawWaveSetOOL(int pos, uint32_t value)
-{
- int page, slot;
-
- if ((pos >= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot(pos, &page, &slot);
- dmaOVirt[page]->OOL[slot] = value;
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t rawWaveGetOut(int pos)
-{
- int page, slot;
-
- if ((pos >= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot(pos, &page, &slot);
- return (dmaOVirt[page]->OOL[slot]);
- }
-
- return -1;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void rawWaveSetOut(int pos, uint32_t value)
-{
- int page, slot;
-
- if ((pos >= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot(pos, &page, &slot);
- dmaOVirt[page]->OOL[slot] = value;
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t rawWaveGetIn(int pos)
-{
- int page, slot;
-
- if ((pos >= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot((NUM_WAVE_OOL-1)-pos, &page, &slot);
- return (dmaOVirt[page]->OOL[slot]);
- }
-
- return -1;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void rawWaveSetIn(int pos, uint32_t value)
-{
- int page, slot;
-
- if ((pos >= 0) && (pos < NUM_WAVE_OOL))
- {
- waveOOLPageSlot((NUM_WAVE_OOL-1)-pos, &page, &slot);
- dmaOVirt[page]->OOL[slot] = value;
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-rawWaveInfo_t rawWaveInfo(int wave_id)
-{
- rawWaveInfo_t dummy = {0, 0, 0, 0, 0, 0, 0, 0};
-
- if ((wave_id >=0) && (wave_id < PI_MAX_WAVES)) return waveInfo[wave_id];
- else return dummy;
-}
-
-/* ----------------------------------------------------------------------- */
-
-double time_time(void)
-{
- struct timeval tv;
- double t;
-
- gettimeofday(&tv, 0);
-
- t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6);
-
- return t;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void time_sleep(double seconds)
-{
- struct timespec ts, rem;
-
- if (seconds > 0.0)
- {
- ts.tv_sec = seconds;
- ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9;
-
- while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem))
- {
- /* copy remaining time to ts */
- ts.tv_sec = rem.tv_sec;
- ts.tv_nsec = rem.tv_nsec;
- }
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-void rawDumpWave(void)
-{
- int i;
-
- unsigned numWaves, t;
-
- rawWave_t *waves;
-
- numWaves = wfc[wfcur];
- waves = wf [wfcur];
-
- t = 0;
-
- for (i=0; i= PI_MAX_SCRIPTS) return;
-
- if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
- {
-
- for (i=0; i> 4) & 3;
-
- if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1);
- else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2);
-
- gpioInfo[i].width = 0;
- gpioInfo[i].is = GPIO_UNDEFINED;
- }
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetMode(unsigned gpio, unsigned mode)
-{
- int reg, shift, old_mode;
-
- DBG(DBG_USER, "gpio=%d mode=%d", gpio, mode);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if (mode > PI_ALT3)
- SOFT_ERROR(PI_BAD_MODE, "gpio %d, bad mode (%d)", gpio, mode);
-
- reg = gpio/10;
- shift = (gpio%10) * 3;
-
- old_mode = (gpioReg[reg] >> shift) & 7;
-
- if (mode != old_mode)
- {
- switchFunctionOff(gpio);
-
- gpioInfo[gpio].is = GPIO_UNDEFINED;
- }
-
- gpioReg[reg] = (gpioReg[reg] & ~(7< PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- reg = gpio/10;
- shift = (gpio%10) * 3;
-
- return (gpioReg[reg] >> shift) & 7;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetPullUpDown(unsigned gpio, unsigned pud)
-{
- DBG(DBG_USER, "gpio=%d pud=%d", gpio, pud);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if (pud > PI_PUD_UP)
- SOFT_ERROR(PI_BAD_PUD, "gpio %d, bad pud (%d)", gpio, pud);
-
- *(gpioReg + GPPUD) = pud;
-
- myGpioDelay(20);
-
- *(gpioReg + GPPUDCLK0 + BANK) = BIT;
-
- myGpioDelay(20);
-
- *(gpioReg + GPPUD) = 0;
-
- *(gpioReg + GPPUDCLK0 + BANK) = 0;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioRead(unsigned gpio)
-{
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if ((*(gpioReg + GPLEV0 + BANK) & BIT) != 0) return PI_ON;
- else return PI_OFF;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWrite(unsigned gpio, unsigned level)
-{
- DBG(DBG_USER, "gpio=%d level=%d", gpio, level);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if (level > PI_ON)
- SOFT_ERROR(PI_BAD_LEVEL, "gpio %d, bad level (%d)", gpio, level);
-
- if (gpio <= PI_MAX_GPIO)
- {
- if (gpioInfo[gpio].is != GPIO_WRITE)
- {
- /* stop a glitch between setting mode then level */
- if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
- else *(gpioReg + GPSET0 + BANK) = BIT;
-
- switchFunctionOff(gpio);
-
- gpioInfo[gpio].is = GPIO_WRITE;
- }
- }
-
- myGpioSetMode(gpio, PI_OUTPUT);
-
- if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
- else *(gpioReg + GPSET0 + BANK) = BIT;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioPWM(unsigned gpio, unsigned val)
-{
- DBG(DBG_USER, "gpio=%d dutycycle=%d", gpio, val);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (val > gpioInfo[gpio].range)
- SOFT_ERROR(PI_BAD_DUTYCYCLE, "gpio %d, bad dutycycle (%d)", gpio, val);
-
- if (gpioInfo[gpio].is != GPIO_PWM)
- {
- switchFunctionOff(gpio);
-
- gpioInfo[gpio].is = GPIO_PWM;
- }
-
- myGpioSetMode(gpio, PI_OUTPUT);
-
- myGpioSetPwm(gpio, gpioInfo[gpio].width, val);
-
- gpioInfo[gpio].width=val;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioGetPWMdutycycle(unsigned gpio)
-{
- unsigned pwm;
-
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- switch (gpioInfo[gpio].is)
- {
- case GPIO_PWM:
- return gpioInfo[gpio].width;
-
- case GPIO_HW_PWM:
- pwm = (PWMDef[gpio] >> 4) & 3;
- return hw_pwm_duty[pwm];
-
- case GPIO_HW_CLK:
- return PI_HW_PWM_RANGE/2;
-
- default:
- SOFT_ERROR(PI_NOT_PWM_GPIO, "not a PWM gpio (%d)", gpio);
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetPWMrange(unsigned gpio, unsigned range)
-{
- int oldWidth, newWidth;
-
- DBG(DBG_USER, "gpio=%d range=%d", gpio, range);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if ((range < PI_MIN_DUTYCYCLE_RANGE) || (range > PI_MAX_DUTYCYCLE_RANGE))
- SOFT_ERROR(PI_BAD_DUTYRANGE, "gpio %d, bad range (%d)", gpio, range);
-
- oldWidth = gpioInfo[gpio].width;
-
- if (oldWidth)
- {
- if (gpioInfo[gpio].is == GPIO_PWM)
- {
- newWidth = (range * oldWidth) / gpioInfo[gpio].range;
-
- myGpioSetPwm(gpio, oldWidth, 0);
- gpioInfo[gpio].range = range;
- gpioInfo[gpio].width = newWidth;
- myGpioSetPwm(gpio, 0, newWidth);
- }
- }
-
- gpioInfo[gpio].range = range;
-
- /* return the actual range for the current gpio frequency */
-
- return pwmRealRange[gpioInfo[gpio].freqIdx];
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioGetPWMrange(unsigned gpio)
-{
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- switch (gpioInfo[gpio].is)
- {
- case GPIO_HW_PWM:
- case GPIO_HW_CLK:
- return PI_HW_PWM_RANGE;
-
- default:
- return gpioInfo[gpio].range;
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioGetPWMrealRange(unsigned gpio)
-{
- unsigned pwm;
-
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- switch (gpioInfo[gpio].is)
- {
- case GPIO_HW_PWM:
- pwm = (PWMDef[gpio] >> 4) & 3;
- return hw_pwm_real_range[pwm];
-
- case GPIO_HW_CLK:
- return PI_HW_PWM_RANGE;
-
- default:
- return pwmRealRange[gpioInfo[gpio].freqIdx];
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetPWMfrequency(unsigned gpio, unsigned frequency)
-{
- int i, width;
- unsigned diff, best, idx;
-
- DBG(DBG_USER, "gpio=%d frequency=%d", gpio, frequency);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (frequency > pwmFreq[0]) idx = 0;
- else if (frequency < pwmFreq[PWM_FREQS-1]) idx = PWM_FREQS-1;
- else
- {
- best = 100000; /* impossibly high frequency difference */
- idx = 0;
-
- for (i=0; i pwmFreq[i]) diff = frequency - pwmFreq[i];
- else diff = pwmFreq[i] - frequency;
-
- if (diff < best)
- {
- best = diff;
- idx = i;
- }
- }
- }
-
- width = gpioInfo[gpio].width;
-
- if (width)
- {
- if (gpioInfo[gpio].is == GPIO_PWM)
- {
- myGpioSetPwm(gpio, width, 0);
- gpioInfo[gpio].freqIdx = idx;
- myGpioSetPwm(gpio, 0, width);
- }
- }
-
- gpioInfo[gpio].freqIdx = idx;
-
- return pwmFreq[idx];
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioGetPWMfrequency(unsigned gpio)
-{
- unsigned pwm, clock;
-
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- switch (gpioInfo[gpio].is)
- {
- case GPIO_HW_PWM:
- pwm = (PWMDef[gpio] >> 4) & 3;
- return hw_pwm_freq[pwm];
-
- case GPIO_HW_CLK:
- clock = (clkDef[gpio] >> 4) & 3;
- return hw_clk_freq[clock];
-
- default:
- return pwmFreq[gpioInfo[gpio].freqIdx];
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioServo(unsigned gpio, unsigned val)
-{
- DBG(DBG_USER, "gpio=%d pulsewidth=%d", gpio, val);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if ((val!=PI_SERVO_OFF) && (valPI_MAX_SERVO_PULSEWIDTH)
- SOFT_ERROR(PI_BAD_PULSEWIDTH,
- "gpio %d, bad pulsewidth (%d)", gpio, val);
-
- if (gpioInfo[gpio].is != GPIO_SERVO)
- {
- switchFunctionOff(gpio);
-
- gpioInfo[gpio].is = GPIO_SERVO;
- }
-
- myGpioSetMode(gpio, PI_OUTPUT);
-
- myGpioSetServo(gpio, gpioInfo[gpio].width, val);
-
- gpioInfo[gpio].width=val;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioGetServoPulsewidth(unsigned gpio)
-{
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (gpioInfo[gpio].is != GPIO_SERVO)
- SOFT_ERROR(PI_NOT_SERVO_GPIO, "not a servo gpio (%d)", gpio);
-
- return gpioInfo[gpio].width;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveClear(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- wfc[0] = 0;
- wfc[1] = 0;
- wfc[2] = 0;
-
- wfcur = 0;
-
- wfStats.micros = 0;
- wfStats.pulses = 0;
- wfStats.cbs = 0;
-
- waveOutBotCB = PI_WAVE_COUNT_PAGES*CBS_PER_OPAGE;
- waveOutBotOOL = PI_WAVE_COUNT_PAGES*OOL_PER_OPAGE;
- waveOutTopOOL = NUM_WAVE_OOL;
-
- waveOutCount = 0;
-
- waveEndPtr = NULL;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveAddNew(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- wfc[0] = 0;
- wfc[1] = 0;
- wfc[2] = 0;
-
- wfcur = 0;
-
- wfStats.micros = 0;
- wfStats.pulses = 0;
- wfStats.cbs = 0;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses)
-{
- int p;
-
- DBG(DBG_USER, "numPulses=%u pulses=%08X", numPulses, (uint32_t)pulses);
-
- CHECK_INITED;
-
- if (numPulses > PI_WAVE_MAX_PULSES)
- SOFT_ERROR(PI_TOO_MANY_PULSES, "bad number of pulses (%d)", numPulses);
-
- if (!pulses) SOFT_ERROR(PI_BAD_POINTER, "bad (NULL) pulses pointer");
-
- for (p=0; p PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if ((baud < PI_WAVE_MIN_BAUD) || (baud > PI_WAVE_MAX_BAUD))
- SOFT_ERROR(PI_BAD_WAVE_BAUD, "bad baud rate (%d)", baud);
-
- if ((data_bits < PI_MIN_WAVE_DATABITS) ||
- (data_bits > PI_MAX_WAVE_DATABITS))
- SOFT_ERROR(PI_BAD_DATABITS, "bad number of databits (%d)", data_bits);
-
- if ((stop_bits < PI_MIN_WAVE_HALFSTOPBITS) ||
- (stop_bits > PI_MAX_WAVE_HALFSTOPBITS))
- SOFT_ERROR(PI_BAD_STOPBITS,
- "bad number of (half) stop bits (%d)", stop_bits);
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (numBytes > PI_WAVE_MAX_CHARS)
- SOFT_ERROR(PI_TOO_MANY_CHARS, "too many chars (%d)", numBytes);
-
- if (offset > PI_WAVE_MAX_MICROS)
- SOFT_ERROR(PI_BAD_SER_OFFSET, "offset too large (%d)", offset);
-
- if (data_bits > 8) numBytes /= 2;
- if (data_bits > 16) numBytes /= 2;
-
- if (!numBytes) return 0;
-
- waveBitDelay(baud, data_bits, stop_bits, bitDelay);
-
- p = 0;
-
- wf[2][p].gpioOn = (1< bitDelay[0]) wf[2][p].usDelay = offset;
- else wf[2][p].usDelay = bitDelay[0];
-
- for (i=0; i PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", spiSS);
-
- /*
- CPOL CPHA
- 0 0 read rising/write falling
- 0 1 read falling/write rising
- 1 0 read falling/write rising
- 1 1 read rising/write falling
- */
-
- if (spi->clk_pol) {rising_edge[0] = 0; rising_edge[1] = 1;}
- else {rising_edge[0] = 1; rising_edge[1] = 0;}
-
- if (spi->clk_pha) {read_cycle[0] = 0; read_cycle[1] = 1;}
- else {read_cycle[0] = 1; read_cycle[1] = 0;}
-
- p = 0;
-
- if (offset)
- {
- wf[2][p].gpioOn = 0;
- wf[2][p].gpioOff = 0;
- wf[2][p].flags = 0;
- wf[2][p].usDelay = offset;
- p++;
- }
-
- on_bits = 0;
- off_bits = 0;
-
- tx_bit_pos = 0;
-
- /* preset initial mosi bit */
-
- if (getBitInBytes(tx_bit_pos, buf, spiTxBits))
- {
- on_bits |= (1<<(spi->mosi));
- dbv = 1;
- }
- else
- {
- off_bits |= (1<<(spi->mosi));
- dbv = 0;
- }
-
- if (!spi->clk_pha) tx_bit_pos ++;
-
- if (spi->ss_pol) off_bits |= (1<clk_pol) on_bits |= (1<<(spi->clk));
- else off_bits |= (1<<(spi->clk));
-
- wf[2][p].gpioOn = on_bits;
- wf[2][p].gpioOff = off_bits;
- wf[2][p].flags = 0;
-
- if (spi->clk_us > spi->ss_us) wf[2][p].usDelay = spi->clk_us;
- else wf[2][p].usDelay = spi->ss_us;
-
- p++;
-
- for (bit=1; bit<=spiBits; bit++)
- {
- for (halfbit=0; halfbit<2; halfbit++)
- {
- wf[2][p].usDelay = spi->clk_us;
- wf[2][p].flags = 0;
-
- on_bits = 0;
- off_bits = 0;
-
- if (read_cycle[halfbit])
- {
- if ((bit>=spiBitFirst) && (bit<=spiBitLast))
- wf[2][p].flags = WAVE_FLAG_READ;
- }
- else
- {
- if (getBitInBytes(tx_bit_pos, buf, spiTxBits))
- {
- if (!dbv) on_bits |= (1<<(spi->mosi));
- dbv = 1;
- }
- else
- {
- if (dbv) off_bits |= (1<<(spi->mosi));
- dbv = 0;
- }
-
- ++tx_bit_pos;
- }
-
- if (rising_edge[halfbit]) on_bits |= (1<<(spi->clk));
- else off_bits |= (1<<(spi->clk));
-
- wf[2][p].gpioOn = on_bits;
- wf[2][p].gpioOff = off_bits;
-
- p++;
- }
- }
-
- on_bits = 0;
- off_bits = 0;
-
- if (spi->ss_pol) on_bits |= (1<= NUM_WAVE_CBS)
- return PI_TOO_MANY_CBS;
-
- if ((numBOOL+waveOutBotOOL) >= (waveOutTopOOL-numTOOL))
- return PI_TOO_MANY_OOL;
-
- if (wid >= PI_MAX_WAVES)
- return PI_NO_WAVEFORM_ID;
-
- wid = waveOutCount++;
-
- waveInfo[wid].botCB = waveOutBotCB;
- waveInfo[wid].topCB = waveOutBotCB + numCB -1;
- waveInfo[wid].botOOL = waveOutBotOOL;
- waveInfo[wid].topOOL = waveOutTopOOL;
- waveInfo[wid].numCB = numCB;
- waveInfo[wid].numBOOL = numBOOL;
- waveInfo[wid].numTOOL = numTOOL;
-
- waveOutBotCB += numCB;
- waveOutBotOOL += numBOOL;
- waveOutTopOOL -= numTOOL;
- }
-
- /* Must be room if got this far. */
-
- CB = waveInfo[wid].botCB;
- BOOL = waveInfo[wid].botOOL;
- TOOL = waveInfo[wid].topOOL;
-
- wave2Cbs(PI_WAVE_MODE_ONE_SHOT, &CB, &BOOL, &TOOL);
-
- /* Sanity check. */
-
- if ( (numCB != (CB-waveInfo[wid].botCB)) ||
- (numBOOL != (BOOL-waveInfo[wid].botOOL)) ||
- (numTOOL != (waveInfo[wid].topOOL-TOOL)) )
- {
- DBG(DBG_ALWAYS, "ERROR wid=%d CBs %d=%d BOOL %d=%d TOOL %d=%d", wid,
- numCB, CB-waveInfo[wid].botCB,
- numBOOL, BOOL-waveInfo[wid].botOOL,
- numTOOL, waveInfo[wid].topOOL-TOOL);
- }
-
- waveInfo[wid].deleted = 0;
-
- /* Consume waves. */
-
- wfc[0] = 0;
- wfc[1] = 0;
- wfc[2] = 0;
-
- wfcur = 0;
-
- return wid;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveDelete(unsigned wave_id)
-{
- DBG(DBG_USER, "wave id=%d", wave_id);
-
- CHECK_INITED;
-
- if ((wave_id >= waveOutCount) || waveInfo[wave_id].deleted)
- SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id);
-
- waveInfo[wave_id].deleted = 1;
-
- if (wave_id == (waveOutCount-1))
- {
- /* top wave deleted, garbage collect any other deleted waves */
-
- while ((wave_id > 0) && (waveInfo[wave_id-1].deleted)) --wave_id;
-
- waveOutBotCB = waveInfo[wave_id].botCB;
- waveOutBotOOL = waveInfo[wave_id].botOOL;
- waveOutTopOOL = waveInfo[wave_id].topOOL;
-
- waveOutCount = wave_id;
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveTxStart(unsigned wave_mode)
-{
- /* This function is deprecated and has been removed. */
-
- CHECK_INITED;
-
- SOFT_ERROR(PI_DEPRECATED, "deprected function removed");
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode)
-{
- rawCbs_t *p=NULL;
-
- DBG(DBG_USER, "wave_id=%d wave_mode=%d", wave_id, wave_mode);
-
- CHECK_INITED;
-
- if ((wave_id >= waveOutCount) || waveInfo[wave_id].deleted)
- SOFT_ERROR(PI_BAD_WAVE_ID, "bad wave id (%d)", wave_id);
-
- if (wave_mode > PI_WAVE_MODE_REPEAT_SYNC)
- SOFT_ERROR(PI_BAD_WAVE_MODE, "bad wave mode (%d)", wave_mode);
-
- if (!waveClockInited)
- {
- stopHardwarePWM();
- initClock(0); /* initialise secondary clock */
- waveClockInited = 1;
- PWMClockInited = 0;
- }
-
- p = rawWaveCBAdr(waveInfo[wave_id].topCB);
-
- if ((wave_mode & 1) == PI_WAVE_MODE_ONE_SHOT)
- p->next = 0;
- else
- p->next = waveCbPOadr(waveInfo[wave_id].botCB+1);
-
- if (waveEndPtr && (wave_mode > PI_WAVE_MODE_REPEAT))
- {
- *waveEndPtr = waveCbPOadr(waveInfo[wave_id].botCB+1);
-
- if (!dmaOut[DMA_CONBLK_AD])
- {
- initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB));
- }
- }
- else
- {
- initDMAgo((uint32_t *)dmaOut, waveCbPOadr(waveInfo[wave_id].botCB));
- }
-
- waveEndPtr = &p->next;
-
- /* for compatability with the deprecated gpioWaveTxStart return the
- number of cbs
- */
- return (waveInfo[wave_id].topCB - waveInfo[wave_id].botCB) + 1;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static int chainGetCB(int n)
-{
- int block, index;
-
- if (n < (WCB_CHAIN_CBS * PI_WAVE_COUNT_PAGES))
- {
- block = n / WCB_CHAIN_CBS;
- index = n % WCB_CHAIN_CBS;
- return (block*CBS_PER_OPAGE) + WCB_COUNTER_CBS + index;
- }
- return -1;
-}
-
-static void chainSetVal(int n, uint32_t val)
-{
- int block, index;
- uint32_t *p;
-
- if (n < (WCB_CHAIN_OOL * PI_WAVE_COUNT_PAGES))
- {
- block = n / WCB_CHAIN_OOL;
- index = n % WCB_CHAIN_OOL;
- p = (uint32_t *) dmaOVirt[block] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8;
- p[index] = val;
- }
-}
-
-static uint32_t chainGetValPadr(int n)
-{
- int block, index;
- uint32_t *p;
-
- if (n < (WCB_CHAIN_OOL * PI_WAVE_COUNT_PAGES))
- {
- block = n / WCB_CHAIN_OOL;
- index = n % WCB_CHAIN_OOL;
- p = (uint32_t *) dmaOBus[block] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8;
- return (uint32_t) (p + index);
- }
- return 0;
-}
-
-static uint32_t chainGetCntVal(int counter, int slot)
-{
- uint32_t *p;
- int page, offset;
- page = counter / 2;
- offset = (counter % 2 ? WCB_COUNTER_OOL : 0);
- p = (uint32_t *) dmaOVirt[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8;
- return p[WCB_CHAIN_OOL+ offset + slot];
-}
-
-static void chainSetCntVal(int counter, int slot, uint32_t value)
-{
- uint32_t *p;
- int page, offset;
- page = counter / 2;
- offset = (counter % 2 ? WCB_COUNTER_OOL : 0);
- p = (uint32_t *) dmaOVirt[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8;
- p[WCB_CHAIN_OOL + offset + slot] = value;
-}
-
-static uint32_t chainGetCntValPadr(int counter, int slot)
-{
- uint32_t *p;
- int page, offset;
- page = counter / 2;
- offset = (counter % 2 ? WCB_COUNTER_OOL : 0);
- p = (uint32_t *) dmaOBus[page] + (WCB_COUNTER_CBS+WCB_CHAIN_CBS) * 8;
- return (uint32_t)(p + WCB_CHAIN_OOL + offset + slot);
-}
-
-static int chainGetCntCB(int counter)
-{
- int page, offset;
- page = counter / 2;
- offset = (counter % 2 ? WCB_CNT_CBS : 0);
- return ((page * CBS_PER_OPAGE) + offset);
-}
-
-static void chainMakeCounter(
- unsigned counter,
- unsigned blklen,
- unsigned blocks,
- unsigned count,
- uint32_t repeat,
- uint32_t next)
-{
- rawCbs_t *p=NULL;
-
- int b, baseCB, dig;
- uint32_t nxt;
-
- int botCB;
-
- botCB = chainGetCntCB(counter);
-
- baseCB = botCB;
-
- /* set up all the OOLs */
- for (b=0; b < (blocks*(blklen+1)); b++) chainSetCntVal(counter, b, repeat);
-
- for (b=0; binfo = NORMAL_DMA;
-
- p->src = chainGetCntValPadr(counter, b*(blklen+1));
- p->dst = (waveCbPOadr(botCB+1) + 20);
-
- p->length = 4;
- p->next = waveCbPOadr(botCB);
-
- /* copy BOTTOM to TOP */
-
- p = rawWaveCBAdr(botCB++);
-
- p->info = NORMAL_DMA;
-
- p->src = chainGetCntValPadr(counter, b*(blklen+1));
- p->dst = chainGetCntValPadr(counter, (b*(blklen+1))+blklen);
-
- p->length = 4;
- p->next = waveCbPOadr(botCB);
-
- /* shift all down one */
-
- p = rawWaveCBAdr(botCB++);
-
- p->info = NORMAL_DMA|DMA_SRC_INC|DMA_DEST_INC;
-
- p->src = chainGetCntValPadr(counter, ((b*(blklen+1))+1));
- p->dst = chainGetCntValPadr(counter, ((b*(blklen+1))+0));
-
- p->length = blklen*4;
- p->next = repeat;
- }
-
- /* reset the counter */
-
- p = rawWaveCBAdr(botCB);
-
- p->info = NORMAL_DMA|DMA_SRC_INC|DMA_DEST_INC;
-
- p->src = chainGetCntValPadr(counter, blocks*(blklen+1));
- p->dst = chainGetCntValPadr(counter, 0);
-
- p->length = blocks*(blklen+1)*4;
- p->next = next;
-
- b = 0;
-
- while (count && (binfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
-
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = BPD * 20 / PI_WF_MICROS; /* 20 micros delay */
- p->next = waveCbPOadr(chainGetCB(cb));
-
- counters = 0;
- wid = -1;
-
- i = 0;
-
- while (i bufSize)
- SOFT_ERROR(PI_BAD_CHAIN_CMD,
- "incomplete chain command (at %d)", i);
-
- cmd = buf[i+1];
-
- if (cmd == 0) /* loop begin */
- {
- if (stk_lev >= (sizeof(stk_pos)/sizeof(int)))
- SOFT_ERROR(PI_CHAIN_NESTING,
- "chain counters nested too deep (at %d)", i);
-
- stk_pos[stk_lev++] = cb;
-
- i += 2;
- }
- else if (cmd == 1) /* loop end */
- {
- if (counters >= WCB_COUNTERS)
- SOFT_ERROR(PI_CHAIN_COUNTER,
- "too many chain counters (at %d)", i);
-
- if ((i+4) > bufSize)
- SOFT_ERROR(PI_BAD_CHAIN_CMD,
- "incomplete chain command (at %d)", i);
-
- loop = 0;
- if (--stk_lev >= 0) loop = stk_pos[stk_lev];
-
- if ((loop < 1) || (loop == cb))
- SOFT_ERROR(PI_BAD_CHAIN_LOOP,
- "empty chain loop (at %d)", i);
-
- cycles = ((unsigned)buf[i+3] << 8) + (unsigned)buf[i+2];
-
- i += 4;
-
- if (cycles > PI_MAX_WAVE_CYCLES)
- SOFT_ERROR(PI_CHAIN_LOOP_CNT,
- "bad chain loop count (%d)", cycles);
-
- if (cycles == 0)
- {
- /* Skip the complete loop block. Change
- the next pointing to the start of the
- loop block to the current cb.
- */
- p = rawWaveCBAdr(chainGetCB(loop));
- p->next = waveCbPOadr(chainGetCB(cb));
- }
- else if (cycles == 1)
- {
- /* Nothing to do, no need for a counter. */
- }
- else
- {
- chaincb = chainGetCB(cb++);
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- p = rawWaveCBAdr(chaincb);
-
- repeat = waveCbPOadr(chainGetCB(loop));
-
- /* Need to check next cb as well. */
-
- chaincb = chainGetCB(cb);
-
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- next = waveCbPOadr(chainGetCB(cb));
-
- /* dummy src and dest */
- p->info = NORMAL_DMA;
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->dst = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4;
- p->next = waveCbPOadr(chainGetCntCB(counters));
-
- chainMakeCounter(counters, blklen, blocks,
- cycles-1, repeat, next);
-
- counters++;
- }
- }
- else if (cmd == 2) /* delay us */
- {
- if ((i+4) > bufSize)
- SOFT_ERROR(PI_BAD_CHAIN_CMD,
- "incomplete chain command (at %d)", i);
-
- cycles = ((unsigned)buf[i+3] << 8) + (unsigned)buf[i+2];
-
- i += 4;
-
- if (cycles > PI_MAX_WAVE_DELAY)
- SOFT_ERROR(PI_BAD_CHAIN_DELAY,
- "bad chain delay micros (%d)", cycles);
-
- if (cycles)
- {
- delayLeft = cycles;
- delayCBs = waveDelayCBs(delayLeft);
- for (dcb=0; dcbinfo = NORMAL_DMA | TIMED_DMA(2);
- p->dst = PCM_TIMER;
- }
- else
- {
- p->info = NORMAL_DMA | TIMED_DMA(5);
- p->dst = PWM_TIMER;
- }
-
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
-
- p->length = BPD * delayLeft / PI_WF_MICROS;
-
- if ((gpioCfg.DMAsecondaryChannel >= DMA_LITE_FIRST) &&
- (p->length > DMA_LITE_MAX))
- {
- p->length = DMA_LITE_MAX;
- }
-
- delayLeft -= (p->length / BPD);
-
- p->next = waveCbPOadr(chainGetCB(cb));
- }
- }
- }
- else if (cmd == 3) /* repeat loop forever */
- {
- i += 2;
-
- loop = 0;
- if (--stk_lev >= 0) loop = stk_pos[stk_lev];
-
- if ((loop < 1) || (loop == cb))
- SOFT_ERROR(PI_BAD_CHAIN_LOOP,
- "empty chain loop (at %d)", i);
-
- chaincb = chainGetCB(cb++);
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- if (i < bufSize)
- SOFT_ERROR(PI_BAD_FOREVER,
- "loop forever must be last command");
-
- p = rawWaveCBAdr(chaincb);
-
- /* dummy src and dest */
- p->info = NORMAL_DMA;
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->dst = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4;
- p->next = waveCbPOadr(chainGetCB(loop));
- endPtr = &p->next;
- }
- else
- SOFT_ERROR(PI_BAD_CHAIN_CMD,
- "unknown chain command (255 %d)", cmd);
- }
- else if ((wid >= waveOutCount) || waveInfo[wid].deleted)
- SOFT_ERROR(PI_BAD_WAVE_ID, "undefined wave (%d)", wid);
- else
- {
- chaincb = chainGetCB(cb++);
-
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- p = rawWaveCBAdr(chaincb);
-
- chaincb = chainGetCB(cb);
-
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- chainSetVal(cb-1, waveCbPOadr(chaincb));
-
- /* patch next of wid topCB to next cb */
-
- p->info = NORMAL_DMA;
- p->src = chainGetValPadr(cb-1); /* this next */
- p->dst = waveCbPOadr(waveInfo[wid].topCB) + 20; /* wid next */
- p->length = 4;
- p->next = waveCbPOadr(waveInfo[wid].botCB+1);
-
- i += 1;
- }
- }
-
- chaincb = chainGetCB(cb++);
-
- if (chaincb < 0)
- SOFT_ERROR(PI_CHAIN_TOO_BIG, "chain is too long (%d)", cb);
-
- p = rawWaveCBAdr(chaincb);
-
- p->info = NORMAL_DMA;
- p->src = (uint32_t) (&dmaOBus[0]->periphData);
- p->dst = (uint32_t) (&dmaOBus[0]->periphData);
- p->length = 4;
- p->next = 0;
-
- if (!endPtr) endPtr = &p->next;
-
- initDMAgo((uint32_t *)dmaOut, waveCbPOadr(chainGetCB(0)));
-
- waveEndPtr = endPtr;
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int gpioWaveTxBusy(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- if (dmaOut[DMA_CONBLK_AD])
- return 1;
- else
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int gpioWaveTxAt(void)
-{
- int i, cb;
-
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- cb = dmaNowAtOCB();
-
- if (cb < 0) return -cb;
-
- for (i=0; i= waveInfo[i].botCB) &&
- (cb <= waveInfo[i].topCB) ) return i;
- }
-
- return PI_WAVE_NOT_FOUND;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveTxStop(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- dmaOut[DMA_CS] = DMA_CHANNEL_RESET;
- dmaOut[DMA_CONBLK_AD] = 0;
-
- waveEndPtr = NULL;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetMicros(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.micros;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetHighMicros(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.highMicros;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetMaxMicros(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.maxMicros;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetPulses(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.pulses;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetHighPulses(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.highPulses;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetMaxPulses(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.maxPulses;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetCbs(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.cbs;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetHighCbs(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.highCbs;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWaveGetMaxCbs(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return wfStats.maxCbs;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static int read_SDA(wfRx_t *w)
-{
- myGpioSetMode(w->I.SDA, PI_INPUT);
- return gpioRead(w->I.SDA);
-}
-
-static void set_SDA(wfRx_t *w)
-{
- myGpioSetMode(w->I.SDA, PI_INPUT);
-}
-
-static void clear_SDA(wfRx_t *w)
-{
- myGpioSetMode(w->I.SDA, PI_OUTPUT);
- myGpioWrite(w->I.SDA, 0);
-}
-
-static void clear_SCL(wfRx_t *w)
-{
- myGpioSetMode(w->I.SCL, PI_OUTPUT);
- myGpioWrite(w->I.SCL, 0);
-}
-
-static void I2C_delay(wfRx_t *w)
-{
- myGpioDelay(w->I.delay);
-}
-
-static void I2C_clock_stretch(wfRx_t *w)
-{
- uint32_t now, max_stretch=10000;
-
- myGpioSetMode(w->I.SCL, PI_INPUT);
- now = gpioTick();
- while ((gpioRead(w->I.SCL) == 0) && ((gpioTick()-now) < max_stretch));
-}
-
-static void I2CStart(wfRx_t *w)
-{
- if (w->I.started)
- {
- set_SDA(w);
- I2C_delay(w);
- I2C_clock_stretch(w);
- I2C_delay(w);
- }
-
- clear_SDA(w);
- I2C_delay(w);
- clear_SCL(w);
- I2C_delay(w);
-
- w->I.started = 1;
-}
-
-static void I2CStop(wfRx_t *w)
-{
- clear_SDA(w);
- I2C_delay(w);
- I2C_clock_stretch(w);
- I2C_delay(w);
- set_SDA(w);
- I2C_delay(w);
-
- w->I.started = 0;
-}
-
-static void I2CPutBit(wfRx_t *w, int bit)
-{
- if (bit) set_SDA(w);
- else clear_SDA(w);
-
- I2C_delay(w);
- I2C_clock_stretch(w);
- I2C_delay(w);
- clear_SCL(w);
-}
-
-static int I2CGetBit(wfRx_t *w)
-{
- int bit;
-
- set_SDA(w); /* let SDA float */
- I2C_delay(w);
- I2C_clock_stretch(w);
- bit = read_SDA(w);
- I2C_delay(w);
- clear_SCL(w);
-
- return bit;
-}
-
-static int I2CPutByte(wfRx_t *w, int byte)
-{
- int bit, nack;
-
- for(bit=0; bit<8; bit++)
- {
- I2CPutBit(w, byte & 0x80);
- byte <<= 1;
- }
-
- nack = I2CGetBit(w);
-
- return nack;
-}
-
-static uint8_t I2CGetByte(wfRx_t *w, int nack)
-{
- int bit, byte=0;
-
- for (bit=0; bit<8; bit++)
- {
- byte = (byte << 1) | I2CGetBit(w);
- }
-
- I2CPutBit(w, nack);
-
- return byte;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud)
-{
- DBG(DBG_USER, "SDA=%d SCL=%d baud=%d", SDA, SCL, baud);
-
- CHECK_INITED;
-
- if (SDA > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad SDA (%d)", SDA);
-
- if (SCL > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad SCL (%d)", SCL);
-
- if ((baud < PI_BB_I2C_MIN_BAUD) || (baud > PI_BB_I2C_MAX_BAUD))
- SOFT_ERROR(PI_BAD_I2C_BAUD,
- "SDA %d, bad baud rate (%d)", SDA, baud);
-
- if (wfRx[SDA].mode != PI_WFRX_NONE)
- SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", SDA);
-
- if ((wfRx[SCL].mode != PI_WFRX_NONE) || (SCL == SDA))
- SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", SCL);
-
- wfRx[SDA].gpio = SDA;
- wfRx[SDA].mode = PI_WFRX_I2C_SDA;
- wfRx[SDA].baud = baud;
-
- wfRx[SDA].I.started = 0;
- wfRx[SDA].I.SDA = SDA;
- wfRx[SDA].I.SCL = SCL;
- wfRx[SDA].I.delay = 500000 / baud;
- wfRx[SDA].I.SDAMode = gpioGetMode(SDA);
- wfRx[SDA].I.SCLMode = gpioGetMode(SCL);
-
- wfRx[SCL].gpio = SCL;
- wfRx[SCL].mode = PI_WFRX_I2C_SCL;
-
- myGpioSetMode(SDA, PI_INPUT);
- myGpioSetMode(SCL, PI_INPUT);
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int bbI2CClose(unsigned SDA)
-{
- DBG(DBG_USER, "SDA=%d", SDA);
-
- CHECK_INITED;
-
- if (SDA > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", SDA);
-
- switch(wfRx[SDA].mode)
- {
- case PI_WFRX_I2C_SDA:
-
- myGpioSetMode(wfRx[SDA].I.SDA, wfRx[SDA].I.SDAMode);
- myGpioSetMode(wfRx[SDA].I.SCL, wfRx[SDA].I.SCLMode);
-
- wfRx[wfRx[SDA].I.SDA].mode = PI_WFRX_NONE;
- wfRx[wfRx[SDA].I.SCL].mode = PI_WFRX_NONE;
-
- break;
-
- default:
-
- SOFT_ERROR(PI_NOT_I2C_GPIO, "no I2C on gpio (%d)", SDA);
-
- break;
-
- }
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int bbI2CZip(
- unsigned SDA,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen)
-{
- int i, ack, inPos, outPos, status, bytes;
- int addr, flags, esc, setesc;
- wfRx_t *w;
-
- DBG(DBG_USER, "gpio=%d inBuf=%s outBuf=%08X len=%d",
- SDA, myBuf2Str(inLen, (char *)inBuf), (int)outBuf, outLen);
-
- CHECK_INITED;
-
- if (SDA > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", SDA);
-
- if (wfRx[SDA].mode != PI_WFRX_I2C_SDA)
- SOFT_ERROR(PI_NOT_I2C_GPIO, "no I2C on gpio (%d)", SDA);
-
- if (!inBuf || !inLen)
- SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL");
-
- if (!outBuf && outLen)
- SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL");
-
- w = &wfRx[SDA];
-
- inPos = 0;
- outPos = 0;
- status = 0;
-
- addr = 0;
- flags = 0;
- esc = 0;
- setesc = 0;
-
- wfRx_lock(SDA);
-
- while (!status && (inPos < inLen))
- {
- DBG(DBG_INTERNAL, "status=%d inpos=%d inlen=%d cmd=%d addr=%d flags=%x",
- status, inPos, inLen, inBuf[inPos], addr, flags);
-
- switch (inBuf[inPos++])
- {
- case PI_I2C_END:
- status = 1;
- break;
-
- case PI_I2C_START:
- I2CStart(w);
- break;
-
- case PI_I2C_STOP:
- I2CStop(w);
- break;
-
- case PI_I2C_ADDR:
- addr = myI2CGetPar(inBuf, &inPos, inLen, &esc);
- if (addr < 0) status = PI_BAD_I2C_CMD;
- break;
-
- case PI_I2C_FLAGS:
- /* cheat to force two byte flags */
- esc = 1;
- flags = myI2CGetPar(inBuf, &inPos, inLen, &esc);
- if (flags < 0) status = PI_BAD_I2C_CMD;
- break;
-
- case PI_I2C_ESC:
- setesc = 1;
- break;
-
- case PI_I2C_READ:
-
- bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc);
-
- if (bytes >= 0) ack = I2CPutByte(w, (addr<<1)|1);
-
- if (bytes > 0)
- {
- if (!ack)
- {
- if ((bytes + outPos) < outLen)
- {
- for (i=0; i<(bytes-1); i++)
- {
- outBuf[outPos++] = I2CGetByte(w, 0);
- }
- outBuf[outPos++] = I2CGetByte(w, 1);
- }
- else status = PI_BAD_I2C_RLEN;
- }
- else status = PI_I2C_READ_FAILED;
- }
- else status = PI_BAD_I2C_CMD;
- break;
-
- case PI_I2C_WRITE:
-
- bytes = myI2CGetPar(inBuf, &inPos, inLen, &esc);
-
- if (bytes >= 0) ack = I2CPutByte(w, addr<<1);
-
- if (bytes > 0)
- {
- if (!ack)
- {
- if ((bytes + inPos) < inLen)
- {
- for (i=0; i<(bytes-1); i++)
- {
- ack = I2CPutByte(w, inBuf[inPos++]);
- if (ack) status = PI_I2C_WRITE_FAILED;
- }
- ack = I2CPutByte(w, inBuf[inPos++]);
- }
- else status = PI_BAD_I2C_RLEN;
- } else status = PI_I2C_WRITE_FAILED;
- }
- else status = PI_BAD_I2C_CMD;
- break;
-
- default:
- status = PI_BAD_I2C_CMD;
- }
-
- if (setesc) esc = 1; else esc = 0;
-
- setesc = 0;
- }
-
- wfRx_unlock(SDA);
-
- if (status >= 0) status = outPos;
-
- return status;
-}
-
-/* ----------------------------------------------------------------------- */
-
-static void set_CS(wfRx_t *w)
-{
- myGpioWrite(w->S.CS, PI_SPI_FLAGS_GET_CSPOL(w->S.spiFlags));
-}
-
-static void clear_CS(wfRx_t *w)
-{
- myGpioWrite(w->S.CS, !PI_SPI_FLAGS_GET_CSPOL(w->S.spiFlags));
-}
-
-static void set_SCLK(wfRx_t *w)
-{
- myGpioWrite(w->S.SCLK, !PI_SPI_FLAGS_GET_CPOL(w->S.spiFlags));
-}
-
-static void clear_SCLK(wfRx_t *w)
-{
- myGpioWrite(w->S.SCLK, PI_SPI_FLAGS_GET_CPOL(w->S.spiFlags));
-}
-
-static void SPI_delay(wfRx_t *w)
-{
- myGpioDelay(w->S.delay);
-}
-
-static void bbSPIStart(wfRx_t *w)
-{
- clear_SCLK(w);
-
- SPI_delay(w);
-
- set_CS(w);
-
- SPI_delay(w);
-}
-
-static void bbSPIStop(wfRx_t *w)
-{
- SPI_delay(w);
-
- clear_CS(w);
-
- SPI_delay(w);
-
- clear_SCLK(w);
-}
-
-static uint8_t bbSPIXferByte(wfRx_t *w, char txByte)
-{
- uint8_t bit, rxByte=0;
-
- if (PI_SPI_FLAGS_GET_CPHA(w->S.spiFlags))
- {
- /*
- CPHA = 1
- write on set clock
- read on clear clock
- */
-
- for (bit=0; bit<8; bit++)
- {
- set_SCLK(w);
-
- if (PI_SPI_FLAGS_GET_TX_LSB(w->S.spiFlags))
- {
- myGpioWrite(w->S.MOSI, txByte & 0x01);
- txByte >>= 1;
- }
- else
- {
- myGpioWrite(w->S.MOSI, txByte & 0x80);
- txByte <<= 1;
- }
-
- SPI_delay(w);
-
- clear_SCLK(w);
-
- if (PI_SPI_FLAGS_GET_RX_LSB(w->S.spiFlags))
- {
- rxByte = (rxByte >> 1) | myGpioRead(w->S.MISO) << 7;
- }
- else
- {
- rxByte = (rxByte << 1) | myGpioRead(w->S.MISO);
- }
-
- SPI_delay(w);
- }
- }
- else
- {
- /*
- CPHA = 0
- read on set clock
- write on clear clock
- */
-
- for (bit=0; bit<8; bit++)
- {
- if (PI_SPI_FLAGS_GET_TX_LSB(w->S.spiFlags))
- {
- myGpioWrite(w->S.MOSI, txByte & 0x01);
- txByte >>= 1;
- }
- else
- {
- myGpioWrite(w->S.MOSI, txByte & 0x80);
- txByte <<= 1;
- }
-
- SPI_delay(w);
-
- set_SCLK(w);
-
- if (PI_SPI_FLAGS_GET_RX_LSB(w->S.spiFlags))
- {
- rxByte = (rxByte >> 1) | myGpioRead(w->S.MISO) << 7;
- }
- else
- {
- rxByte = (rxByte << 1) | myGpioRead(w->S.MISO);
- }
-
- SPI_delay(w);
-
- clear_SCLK(w);
- }
- }
-
- return rxByte;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int bbSPIOpen(
- unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK,
- unsigned baud, unsigned spiFlags)
-{
- int valid;
- uint32_t bits;
-
- DBG(DBG_USER, "CS=%d MISO=%d MOSI=%d SCLK=%d baud=%d flags=%d",
- CS, MISO, MOSI, SCLK, baud, spiFlags);
-
- CHECK_INITED;
-
- if (CS > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad CS (%d)", CS);
-
- if (MISO > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad MISO (%d)", MISO);
-
- if (MOSI > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad MOSI (%d)", MOSI);
-
- if (SCLK > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad SCLK (%d)", SCLK);
-
- if ((baud < PI_BB_SPI_MIN_BAUD) || (baud > PI_BB_SPI_MAX_BAUD))
- SOFT_ERROR(PI_BAD_SPI_BAUD, "CS %d, bad baud (%d)", CS, baud);
-
- if (wfRx[CS].mode != PI_WFRX_NONE)
- SOFT_ERROR(PI_GPIO_IN_USE,
- "CS %d is already being used, mode %d", CS, wfRx[CS].mode);
-
- valid = 0;
-
- /* check all GPIO unique */
-
- bits = (1< PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", CS);
-
- switch(wfRx[CS].mode)
- {
- case PI_WFRX_SPI_CS:
-
- myGpioSetMode(wfRx[CS].S.CS, wfRx[CS].S.CSMode);
- wfRx[CS].mode = PI_WFRX_NONE;
-
- SCLK = wfRx[CS].S.SCLK;
-
- if (--wfRx[SCLK].S.usage <= 0)
- {
- myGpioSetMode(wfRx[SCLK].S.MISO, wfRx[SCLK].S.MISOMode);
- myGpioSetMode(wfRx[SCLK].S.MOSI, wfRx[SCLK].S.MOSIMode);
- myGpioSetMode(wfRx[SCLK].S.SCLK, wfRx[SCLK].S.SCLKMode);
-
- wfRx[wfRx[SCLK].S.MISO].mode = PI_WFRX_NONE;
- wfRx[wfRx[SCLK].S.MOSI].mode = PI_WFRX_NONE;
- wfRx[wfRx[SCLK].S.SCLK].mode = PI_WFRX_NONE;
- }
-
- break;
-
- default:
-
- SOFT_ERROR(PI_NOT_SPI_GPIO, "no SPI on gpio (%d)", CS);
-
- break;
-
- }
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int bbSPIXfer(
- unsigned CS,
- char *inBuf,
- char *outBuf,
- unsigned count)
-{
- int SCLK;
- int pos;
- wfRx_t *w;
-
- DBG(DBG_USER, "CS=%d inBuf=%s outBuf=%08X count=%d",
- CS, myBuf2Str(count, (char *)inBuf), (int)outBuf, count);
-
- CHECK_INITED;
-
- if (CS > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", CS);
-
- if (wfRx[CS].mode != PI_WFRX_SPI_CS)
- SOFT_ERROR(PI_NOT_SPI_GPIO, "no SPI on gpio (%d)", CS);
-
- if (!inBuf || !count)
- SOFT_ERROR(PI_BAD_POINTER, "input buffer can't be NULL");
-
- if (!outBuf && count)
- SOFT_ERROR(PI_BAD_POINTER, "output buffer can't be NULL");
-
- SCLK = wfRx[CS].S.SCLK;
-
- wfRx[SCLK].S.CS = CS;
- wfRx[SCLK].baud = wfRx[CS].baud;
- wfRx[SCLK].S.delay = wfRx[CS].S.delay;
- wfRx[SCLK].S.spiFlags = wfRx[CS].S.spiFlags;
-
- w = &wfRx[SCLK];
-
- wfRx_lock(SCLK);
-
- bbSPIStart(w);
-
- for (pos=0; pos < count; pos++)
- {
- outBuf[pos] = bbSPIXferByte(w, inBuf[pos]);
- }
-
- bbSPIStop(w);
-
- wfRx_unlock(SCLK);
-
- return count;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int gpioSerialReadOpen(unsigned gpio, unsigned baud, unsigned data_bits)
-{
- int bitTime, timeout;
-
- DBG(DBG_USER, "gpio=%d baud=%d data_bits=%d", gpio, baud, data_bits);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if ((baud < PI_BB_SER_MIN_BAUD) || (baud > PI_BB_SER_MAX_BAUD))
- SOFT_ERROR(PI_BAD_WAVE_BAUD,
- "gpio %d, bad baud rate (%d)", gpio, baud);
-
- if ((data_bits < PI_MIN_WAVE_DATABITS) ||
- (data_bits > PI_MAX_WAVE_DATABITS))
- SOFT_ERROR(PI_BAD_DATABITS,
- "gpio %d, bad data bits (%d)", gpio, data_bits);
-
- if (wfRx[gpio].mode != PI_WFRX_NONE)
- SOFT_ERROR(PI_GPIO_IN_USE, "gpio %d is already being used", gpio);
-
- bitTime = (1000 * MILLION) / baud; /* nanos */
-
- timeout = ((data_bits+2) * bitTime)/MILLION; /* millis */
-
- if (timeout < 1) timeout = 1;
-
- wfRx[gpio].gpio = gpio;
- wfRx[gpio].mode = PI_WFRX_SERIAL;
- wfRx[gpio].baud = baud;
-
- wfRx[gpio].s.buf = malloc(SRX_BUF_SIZE);
- wfRx[gpio].s.bufSize = SRX_BUF_SIZE;
- wfRx[gpio].s.timeout = timeout;
- wfRx[gpio].s.fullBit = bitTime; /* nanos */
- wfRx[gpio].s.halfBit = (bitTime/2)+500; /* nanos (500 for rounding) */
- wfRx[gpio].s.readPos = 0;
- wfRx[gpio].s.writePos = 0;
- wfRx[gpio].s.bit = -1;
- wfRx[gpio].s.dataBits = data_bits;
- wfRx[gpio].s.invert = PI_BB_SER_NORMAL;
-
- if (data_bits < 9) wfRx[gpio].s.bytes = 1;
- else if (data_bits < 17) wfRx[gpio].s.bytes = 2;
- else wfRx[gpio].s.bytes = 4;
-
- gpioSetAlertFunc(gpio, waveRxBit);
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int gpioSerialReadInvert(unsigned gpio, unsigned invert)
-{
- DBG(DBG_USER, "gpio=%d invert=%d", gpio, invert);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (wfRx[gpio].mode != PI_WFRX_SERIAL)
- SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio);
-
- if ((invert < PI_BB_SER_NORMAL) ||
- (invert > PI_BB_SER_INVERT))
- SOFT_ERROR(PI_BAD_SER_INVERT,
- "bad invert level for gpio %d (%d)", gpio, invert);
-
- wfRx[gpio].s.invert = invert;
-
- return 0;
-}
-
-/*-------------------------------------------------------------------------*/
-
-int gpioSerialRead(unsigned gpio, void *buf, size_t bufSize)
-{
- unsigned bytes=0, wpos;
- volatile wfRx_t *w;
-
- DBG(DBG_USER, "gpio=%d buf=%08X bufSize=%d", gpio, (int)buf, bufSize);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (bufSize == 0)
- SOFT_ERROR(PI_BAD_SERIAL_COUNT, "buffer size can't be zero");
-
- if (wfRx[gpio].mode != PI_WFRX_SERIAL)
- SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio);
-
- w = &wfRx[gpio];
-
- if (w->s.readPos != w->s.writePos)
- {
- wpos = w->s.writePos;
-
- if (wpos > w->s.readPos) bytes = wpos - w->s.readPos;
- else bytes = w->s.bufSize - w->s.readPos;
-
- if (bytes > bufSize) bytes = bufSize;
-
- /* copy in multiples of the data size in bytes */
-
- bytes = (bytes / w->s.bytes) * w->s.bytes;
-
- if (buf) memcpy(buf, w->s.buf+w->s.readPos, bytes);
-
- w->s.readPos += bytes;
-
- if (w->s.readPos >= w->s.bufSize) w->s.readPos = 0;
- }
- return bytes;
-}
-
-
-/*-------------------------------------------------------------------------*/
-
-int gpioSerialReadClose(unsigned gpio)
-{
- DBG(DBG_USER, "gpio=%d", gpio);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- switch(wfRx[gpio].mode)
- {
- case PI_WFRX_NONE:
-
- SOFT_ERROR(PI_NOT_SERIAL_GPIO, "no serial read on gpio (%d)", gpio);
-
- break;
-
- case PI_WFRX_SERIAL:
-
- free(wfRx[gpio].s.buf);
-
- gpioSetWatchdog(gpio, 0); /* switch off timeouts */
-
- gpioSetAlertFunc(gpio, NULL); /* cancel alert */
-
- wfRx[gpio].mode = PI_WFRX_NONE;
-
- break;
- }
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static int intGpioSetAlertFunc(
- unsigned gpio,
- void * f,
- int user,
- void * userdata)
-{
- DBG(DBG_INTERNAL, "gpio=%d function=%08X, user=%d, userdata=%08X",
- gpio, (uint32_t)f, user, (uint32_t)userdata);
-
- gpioAlert[gpio].ex = user;
- gpioAlert[gpio].userdata = userdata;
-
- gpioAlert[gpio].func = f;
-
- if (f)
- {
- alertBits |= BIT;
- }
- else
- {
- alertBits &= ~BIT;
- }
-
- monitorBits = alertBits | notifyBits | scriptBits | gpioGetSamples.bits;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetAlertFunc(unsigned gpio, gpioAlertFunc_t f)
-{
- DBG(DBG_USER, "gpio=%d function=%08X", gpio, (uint32_t)f);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- intGpioSetAlertFunc(gpio, f, 0, NULL);
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetAlertFuncEx(unsigned gpio, gpioAlertFuncEx_t f, void *userdata)
-{
- DBG(DBG_USER, "gpio=%d function=%08X userdata=%08X",
- gpio, (uint32_t)f, (uint32_t)userdata);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- intGpioSetAlertFunc(gpio, f, 1, userdata);
-
- return 0;
-}
-
-static void *pthISRThread(void *x)
-{
- gpioISR_t *isr = x;
- int fd;
- int retval;
- uint32_t tick;
- int level;
- uint32_t levels;
- struct pollfd pfd;
- char buf[64];
-
- DBG(DBG_USER, "gpio=%d edge=%d timeout=%d f=%x u=%d data=%x",
- isr->gpio, isr->edge, isr->timeout, (uint32_t)isr->func,
- isr->ex, (uint32_t)isr->userdata);
-
- sprintf(buf, "/sys/class/gpio/gpio%d/value", isr->gpio);
-
- if ((fd = open(buf, O_RDONLY)) < 0)
- {
- DBG(DBG_ALWAYS, "gpio %d not exported", isr->gpio);
- return NULL;
- }
-
- pfd.fd = fd;
-
- pfd.events = POLLPRI;
-
- lseek(fd, 0, SEEK_SET); /* consume any prior interrupt */
- read(fd, buf, sizeof buf);
-
- while (1)
- {
- retval = poll(&pfd, 1, isr->timeout); /* wait for interrupt */
-
- tick = systReg[SYST_CLO];
-
- levels = *(gpioReg + GPLEV0);
-
- if (retval >= 0)
- {
- lseek(fd, 0, SEEK_SET); /* consume interrupt */
- read(fd, buf, sizeof buf);
- if (retval)
- {
- if (levels & (1<gpio)) level = PI_ON; else level = PI_OFF;
- }
- else level = PI_TIMEOUT;
-
- if (isr->ex) (isr->func)(isr->gpio, level, tick, isr->userdata);
- else (isr->func)(isr->gpio, level, tick);
- }
- }
-
- return NULL;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-static int intGpioSetISRFunc(
- unsigned gpio,
- unsigned edge,
- int timeout,
- void *f,
- int user,
- void *userdata)
-{
- char buf[64];
-
- char *edge_str[]={"rising\n", "falling\n", "both\n"};
- int fd;
- int err;
-
- DBG(DBG_INTERNAL,
- "gpio=%d edge=%d timeout=%d function=%08X user=%d userdata=%08X",
- gpio, edge, timeout, (uint32_t)f, user, (uint32_t)userdata);
-
- if (f)
- {
- if (!gpioISR[gpio].inited) /* export gpio if unexported */
- {
- fd = open("/sys/class/gpio/export", O_WRONLY);
- if (fd < 0) return PI_BAD_ISR_INIT;
-
- /* ignore write fail if already exported */
- sprintf(buf, "%d\n", gpio);
- err = write(fd, buf, strlen(buf));
- close(fd);
-
- sprintf(buf, "/sys/class/gpio/gpio%d/direction", gpio);
- fd = open(buf, O_WRONLY);
- if (fd < 0) return PI_BAD_ISR_INIT;
-
- err = write(fd, "in\n", 3);
- close(fd);
- if (err != 3) return PI_BAD_ISR_INIT;
-
- gpioISR[gpio].gpio = gpio;
- gpioISR[gpio].edge = -1;
- gpioISR[gpio].timeout = -1;
-
- gpioISR[gpio].inited = 1;
- }
-
- if (gpioISR[gpio].edge != edge)
- {
- sprintf(buf, "/sys/class/gpio/gpio%d/edge", gpio);
- fd = open(buf, O_WRONLY);
- if (fd < 0) return PI_BAD_ISR_INIT;
-
- err = write(fd, edge_str[edge], strlen(edge_str[edge]));
- close(fd);
- if (err != strlen(edge_str[edge])) return PI_BAD_ISR_INIT;
-
- gpioISR[gpio].edge = edge;
-
- if (gpioISR[gpio].pth != NULL)
- pthread_kill(*gpioISR[gpio].pth, SIGCHLD);
- }
-
- if (timeout <= 0) timeout = -1;
- if (gpioISR[gpio].timeout != timeout)
- {
- gpioISR[gpio].timeout = timeout;
-
- if (gpioISR[gpio].pth != NULL)
- pthread_kill(*gpioISR[gpio].pth, SIGCHLD);
- }
-
- gpioISR[gpio].func = f;
- gpioISR[gpio].ex = user;
- gpioISR[gpio].userdata = userdata;
-
- if (gpioISR[gpio].pth == NULL)
- gpioISR[gpio].pth = gpioStartThread(pthISRThread, &gpioISR[gpio]);
- }
- else /* null function, delete ISR, unexport gpio */
- {
- if (gpioISR[gpio].pth) /* delete any existing ISR */
- {
- gpioStopThread(gpioISR[gpio].pth);
- gpioISR[gpio].func = NULL;
- gpioISR[gpio].pth = NULL;
- }
-
- if (gpioISR[gpio].inited) /* unexport the gpio */
- {
- fd = open("/sys/class/gpio/unexport", O_WRONLY);
- if (fd < 0) return PI_BAD_ISR_INIT;
- sprintf(buf, "%d\n", gpio);
- err = write(fd, buf, strlen(buf));
- close(fd);
- if (err != strlen(buf)) return PI_BAD_ISR_INIT;
- gpioISR[gpio].inited = 0;
- }
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetISRFunc(
- unsigned gpio,
- unsigned edge,
- int timeout,
- gpioISRFunc_t f)
-{
- DBG(DBG_USER, "gpio=%d edge=%d timeout=%d function=%08X",
- gpio, edge, timeout, (uint32_t)f);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (edge > EITHER_EDGE)
- SOFT_ERROR(PI_BAD_EDGE, "bad ISR edge (%d)", edge);
-
- return intGpioSetISRFunc(gpio, edge, timeout, f, 0, NULL);
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetISRFuncEx(
- unsigned gpio,
- unsigned edge,
- int timeout,
- gpioAlertFuncEx_t f,
- void *userdata)
-{
- DBG(DBG_USER, "gpio=%d edge=%d timeout=%d function=%08X userdata=%08X",
- gpio, edge, timeout, (uint32_t)f, (uint32_t)userdata);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (edge > EITHER_EDGE)
- SOFT_ERROR(PI_BAD_EDGE, "bad ISR edge (%d)", edge);
-
- return intGpioSetISRFunc(gpio, edge, timeout, f, 1, userdata);
-}
-
-static void closeOrphanedNotifications(int slot, int fd)
-{
- int i;
-
- /* Check for and close any orphaned notifications. */
-
- for (i=0; i= PI_NOTIFY_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- gpioNotify[handle].bits = bits;
-
- gpioNotify[handle].state = PI_NOTIFY_RUNNING;
-
- intNotifyBits();
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioNotifyPause (unsigned handle)
-{
- DBG(DBG_USER, "handle=%d", handle);
-
- CHECK_INITED;
-
- if (handle >= PI_NOTIFY_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- gpioNotify[handle].bits = 0;
-
- gpioNotify[handle].state = PI_NOTIFY_PAUSED;
-
- intNotifyBits();
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioNotifyClose(unsigned handle)
-{
- DBG(DBG_USER, "handle=%d", handle);
-
- CHECK_INITED;
-
- if (handle >= PI_NOTIFY_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (gpioNotify[handle].state <= PI_NOTIFY_CLOSING)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- gpioNotify[handle].bits = 0;
-
- gpioNotify[handle].state = PI_NOTIFY_CLOSING;
-
- intNotifyBits();
-
- /* actual close done in alert thread */
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioTrigger(unsigned gpio, unsigned pulseLen, unsigned level)
-{
- DBG(DBG_USER, "gpio=%d pulseLen=%d level=%d", gpio, pulseLen, level);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (level > PI_ON)
- SOFT_ERROR(PI_BAD_LEVEL, "gpio %d, bad level (%d)", gpio, level);
-
- if ((pulseLen > PI_MAX_BUSY_DELAY) || (!pulseLen))
- SOFT_ERROR(PI_BAD_PULSELEN,
- "gpio %d, bad pulseLen (%d)", gpio, pulseLen);
-
- if (level == PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
- else *(gpioReg + GPSET0 + BANK) = BIT;
-
- myGpioDelay(pulseLen);
-
- if (level != PI_OFF) *(gpioReg + GPCLR0 + BANK) = BIT;
- else *(gpioReg + GPSET0 + BANK) = BIT;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetWatchdog(unsigned gpio, unsigned timeout)
-{
- DBG(DBG_USER, "gpio=%d timeout=%d", gpio, timeout);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (timeout > PI_MAX_WDOG_TIMEOUT)
- SOFT_ERROR(PI_BAD_WDOG_TIMEOUT,
- "gpio %d, bad timeout (%d)", gpio, timeout);
-
- gpioAlert[gpio].wdTick = systReg[SYST_CLO];
- gpioAlert[gpio].wdSteadyUs = timeout*1000;
-
- if (timeout) wdogBits |= (1< PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (steady > PI_MAX_STEADY)
- SOFT_ERROR(PI_BAD_FILTER, "bad steady (%d)", steady);
-
- if (active > PI_MAX_ACTIVE)
- SOFT_ERROR(PI_BAD_FILTER, "bad active (%d)", active);
-
- gpioAlert[gpio].nfTick1 = systReg[SYST_CLO];
- gpioAlert[gpio].nfTick2 = gpioAlert[gpio].nfTick1;
- gpioAlert[gpio].nfSteadyUs = steady;
- gpioAlert[gpio].nfActiveUs = active;
- gpioAlert[gpio].nfActive = 0;
-
- if (steady) nFilterBits |= (1< PI_MAX_USER_GPIO)
- SOFT_ERROR(PI_BAD_USER_GPIO, "bad gpio (%d)", gpio);
-
- if (steady > PI_MAX_STEADY)
- SOFT_ERROR(PI_BAD_FILTER, "bad steady (%d)", steady);
-
- if (steady)
- {
- gpioAlert[gpio].gfTick = systReg[SYST_CLO];
-
- if (gpioRead_Bits_0_31() & (1< PI_MAX_TIMER)
- SOFT_ERROR(PI_BAD_TIMER, "bad timer id (%d)", id);
-
- if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS))
- SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis);
-
- intGpioSetTimerFunc(id, millis, f, 0, NULL);
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetTimerFuncEx(unsigned id, unsigned millis, gpioTimerFuncEx_t f,
- void * userdata)
-{
- DBG(DBG_USER, "id=%d millis=%d function=%08X, userdata=%08X",
- id, millis, (uint32_t)f, (uint32_t)userdata);
-
- CHECK_INITED;
-
- if (id > PI_MAX_TIMER)
- SOFT_ERROR(PI_BAD_TIMER, "bad timer id (%d)", id);
-
- if ((millis < PI_MIN_MS) || (millis > PI_MAX_MS))
- SOFT_ERROR(PI_BAD_MS, "timer %d, bad millis (%d)", id, millis);
-
- intGpioSetTimerFunc(id, millis, f, 1, userdata);
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-pthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata)
-{
- pthread_t *pth;
- pthread_attr_t pthAttr;
-
- DBG(DBG_USER, "f=%08X, userdata=%08X", (uint32_t)f, (uint32_t)userdata);
-
- CHECK_INITED_RET_NULL_PTR;
-
- pth = malloc(sizeof(pthread_t));
-
- if (pth)
- {
- if (pthread_attr_init(&pthAttr))
- {
- free(pth);
- SOFT_ERROR(NULL, "pthread_attr_init failed");
- }
-
- if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE))
- {
- free(pth);
- SOFT_ERROR(NULL, "pthread_attr_setstacksize failed");
- }
-
- if (pthread_create(pth, &pthAttr, f, userdata))
- {
- free(pth);
- SOFT_ERROR(NULL, "pthread_create failed");
- }
- }
- return pth;
-}
-
-/* ----------------------------------------------------------------------- */
-
-void gpioStopThread(pthread_t *pth)
-{
- DBG(DBG_USER, "pth=%08X", (uint32_t)pth);
-
- CHECK_INITED_RET_NIL;
-
- if (pth)
- {
- pthread_cancel(*pth);
- pthread_join(*pth, NULL);
- free(pth);
- }
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioStoreScript(char *script)
-{
- gpioScript_t *s;
- int status, slot, i;
-
- DBG(DBG_USER, "script=[%s]", script);
-
- CHECK_INITED;
-
- slot = -1;
-
- for (i=0; iscript, 0);
-
- if (status == 0)
- {
- s->request = PI_SCRIPT_HALT;
- s->run_state = PI_SCRIPT_INITING;
-
- pthread_cond_init(&s->pthCond, NULL);
- pthread_mutex_init(&s->pthMutex, NULL);
-
- s->id = slot;
-
- gpioScript[slot].state = PI_SCRIPT_IN_USE;
-
- s->pthIdp = gpioStartThread(pthScript, s);
-
- status = slot;
-
- }
- else
- {
- if (s->script.par) free(s->script.par);
- s->script.par = NULL;
- gpioScript[slot].state = PI_SCRIPT_FREE;
- }
-
- return status;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioRunScript(unsigned script_id, unsigned numParam, uint32_t *param)
-{
- int status = 0;
-
- DBG(DBG_USER, "script_id=%d numParam=%d param=%08X",
- script_id, numParam, (uint32_t)param);
-
- CHECK_INITED;
-
- if (script_id >= PI_MAX_SCRIPTS)
- SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id);
-
- if (numParam > PI_MAX_SCRIPT_PARAMS)
- SOFT_ERROR(PI_TOO_MANY_PARAM, "bad number of parameters(%d)", numParam);
-
- if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
- {
- pthread_mutex_lock(&gpioScript[script_id].pthMutex);
-
- if (gpioScript[script_id].run_state != PI_SCRIPT_INITING)
- {
- if ((numParam > 0) && (param != 0))
- {
- memcpy(gpioScript[script_id].script.par, param,
- sizeof(uint32_t) * numParam);
- }
-
- gpioScript[script_id].request = PI_SCRIPT_RUN;
-
- pthread_cond_signal(&gpioScript[script_id].pthCond);
- }
- else
- {
- status = PI_SCRIPT_NOT_READY;
- }
-
- pthread_mutex_unlock(&gpioScript[script_id].pthMutex);
-
- return status;
- }
- else
- {
- return PI_BAD_SCRIPT_ID;
- }
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioScriptStatus(unsigned script_id, uint32_t *param)
-{
- DBG(DBG_USER, "script_id=%d param=%08X", script_id, (uint32_t)param);
-
- CHECK_INITED;
-
- if (script_id >= PI_MAX_SCRIPTS)
- SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id);
-
- if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
- {
- if (param != NULL)
- {
- memcpy(param, gpioScript[script_id].script.par,
- sizeof(uint32_t) * PI_MAX_SCRIPT_PARAMS);
- }
-
- return gpioScript[script_id].run_state;
- }
- else return PI_BAD_SCRIPT_ID;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioStopScript(unsigned script_id)
-{
- DBG(DBG_USER, "script_id=%d", script_id);
-
- CHECK_INITED;
-
- if (script_id >= PI_MAX_SCRIPTS)
- SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id);
-
- if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
- {
- pthread_mutex_lock(&gpioScript[script_id].pthMutex);
-
- gpioScript[script_id].request = PI_SCRIPT_HALT;
-
- if (gpioScript[script_id].run_state == PI_SCRIPT_WAITING)
- {
- pthread_cond_signal(&gpioScript[script_id].pthCond);
- }
-
- pthread_mutex_unlock(&gpioScript[script_id].pthMutex);
-
- return 0;
- }
- else return PI_BAD_SCRIPT_ID;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioDeleteScript(unsigned script_id)
-{
- DBG(DBG_USER, "script_id=%d", script_id);
-
- CHECK_INITED;
-
- if (script_id >= PI_MAX_SCRIPTS)
- SOFT_ERROR(PI_BAD_SCRIPT_ID, "bad script id(%d)", script_id);
-
- if (gpioScript[script_id].state == PI_SCRIPT_IN_USE)
- {
- gpioScript[script_id].state = PI_SCRIPT_DYING;
-
- pthread_mutex_lock(&gpioScript[script_id].pthMutex);
-
- gpioScript[script_id].request = PI_SCRIPT_HALT;
-
- if (gpioScript[script_id].run_state == PI_SCRIPT_WAITING)
- {
- pthread_cond_signal(&gpioScript[script_id].pthCond);
- }
-
- pthread_mutex_unlock(&gpioScript[script_id].pthMutex);
-
- while (gpioScript[script_id].run_state == PI_SCRIPT_RUNNING)
- {
- myGpioSleep(0, 5000); /* give script time to halt */
- }
-
- gpioStopThread(gpioScript[script_id].pthIdp);
-
- if (gpioScript[script_id].script.par)
- free(gpioScript[script_id].script.par);
-
- gpioScript[script_id].script.par = NULL;
-
- gpioScript[script_id].state = PI_SCRIPT_FREE;
-
- return 0;
- }
- else return PI_BAD_SCRIPT_ID;
-}
-
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f)
-{
- DBG(DBG_USER, "signum=%d function=%08X", signum, (uint32_t)f);
-
- CHECK_INITED;
-
- if (signum > PI_MAX_SIGNUM)
- SOFT_ERROR(PI_BAD_SIGNUM, "bad signum (%d)", signum);
-
- gpioSignal[signum].ex = 0;
- gpioSignal[signum].userdata = NULL;
-
- gpioSignal[signum].func = f;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSetSignalFuncEx(unsigned signum, gpioSignalFuncEx_t f,
- void *userdata)
-{
- DBG(DBG_USER, "signum=%d function=%08X userdata=%08X",
- signum, (uint32_t)f, (uint32_t)userdata);
-
- CHECK_INITED;
-
- if (signum > PI_MAX_SIGNUM)
- SOFT_ERROR(PI_BAD_SIGNUM, "bad signum (%d)", signum);
-
- gpioSignal[signum].ex = 1;
- gpioSignal[signum].userdata = userdata;
-
- gpioSignal[signum].func = f;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t gpioRead_Bits_0_31(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return (*(gpioReg + GPLEV0));
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t gpioRead_Bits_32_53(void)
-{
- DBG(DBG_USER, "");
-
- CHECK_INITED;
-
- return (*(gpioReg + GPLEV1));
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWrite_Bits_0_31_Clear(uint32_t bits)
-{
- DBG(DBG_USER, "bits=%08X", bits);
-
- CHECK_INITED;
-
- *(gpioReg + GPCLR0) = bits;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWrite_Bits_32_53_Clear(uint32_t bits)
-{
- DBG(DBG_USER, "bits=%08X", bits);
-
- CHECK_INITED;
-
- *(gpioReg + GPCLR1) = bits;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWrite_Bits_0_31_Set(uint32_t bits)
-{
- DBG(DBG_USER, "bits=%08X", bits);
-
- CHECK_INITED;
-
- *(gpioReg + GPSET0) = bits;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioWrite_Bits_32_53_Set(uint32_t bits)
-{
- DBG(DBG_USER, "bits=%08X", bits);
-
- CHECK_INITED;
-
- *(gpioReg + GPSET1) = bits;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioHardwareClock(unsigned gpio, unsigned frequency)
-{
- int cctl[] = {CLK_GP0_CTL, CLK_GP1_CTL, CLK_GP2_CTL};
- int cdiv[] = {CLK_GP0_DIV, CLK_GP1_DIV, CLK_GP2_DIV};
- int csrc[CLK_SRCS] = {CLK_CTL_SRC_OSC, CLK_CTL_SRC_PLLD};
- uint32_t cfreq[CLK_SRCS]={CLK_OSC_FREQ, CLK_PLLD_FREQ};
- unsigned clock, mode, mash;
- int password = 0;
- double f;
- clkInf_t clkInf={0,0,0};
-
- DBG(DBG_USER, "gpio=%d frequency=%d", gpio, frequency);
-
- CHECK_INITED;
-
- if ((gpio >> 24) == 0x5A) password = 1;
-
- gpio &= 0xFFFFFF;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if (!clkDef[gpio])
- SOFT_ERROR(PI_NOT_HCLK_GPIO, "bad gpio for clock (%d)", gpio);
-
- if (((frequency < PI_HW_CLK_MIN_FREQ) ||
- (frequency > PI_HW_CLK_MAX_FREQ)) &&
- (frequency))
- SOFT_ERROR(PI_BAD_HCLK_FREQ,
- "bad hardware clock frequency (%d)", frequency);
-
- clock = (clkDef[gpio] >> 4) & 3;
-
- if ((clock == 1) && (!password))
- SOFT_ERROR(PI_BAD_HCLK_PASS,
- "Need password to use clock 1 (%d)", gpio);
-
- mode = clkDef[gpio] & 7;
- mash = frequency < PI_MASH_MAX_FREQ ? 1 : 0;
-
- if (frequency)
- {
- if (chooseBestClock(&clkInf, frequency, CLK_SRCS, cfreq))
- {
- if (clkInf.frac == 0) mash = 0;
-
- initHWClk(cctl[clock], cdiv[clock],
- csrc[clkInf.clock], clkInf.div, clkInf.frac, mash);
-
- myGpioSetMode(gpio, mode);
-
- gpioInfo[gpio].is = GPIO_HW_CLK;
-
- f = (double) cfreq[clkInf.clock] /
- ((double)clkInf.div + ((double)clkInf.frac / 4096.0));
-
- hw_clk_freq[clock] = (f + 0.5);
-
- DBG(DBG_USER, "cf=%d div=%d frac=%d mash=%d",
- cfreq[clkInf.clock], clkInf.div, clkInf.frac, mash);
- }
- else
- {
- SOFT_ERROR(PI_BAD_HCLK_FREQ,
- "bad hardware clock frequency (%d)", frequency);
- }
- }
- else
- {
- /* frequency 0, stop clock */
- clkReg[cctl[clock]] = BCM_PASSWD | CLK_CTL_KILL;
-
- if (gpioInfo[gpio].is == GPIO_HW_CLK)
- gpioInfo[gpio].is = GPIO_UNDEFINED;
- }
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioHardwarePWM(
- unsigned gpio, unsigned frequency, unsigned dutycycle)
-{
- uint32_t old_PWM_CTL;
- unsigned pwm, mode;
- uint32_t real_range, real_dutycycle;
-
- DBG(DBG_USER, "gpio=%d frequency=%d dutycycle=%d",
- gpio, frequency, dutycycle);
-
- CHECK_INITED;
-
- if (gpio > PI_MAX_GPIO)
- SOFT_ERROR(PI_BAD_GPIO, "bad gpio (%d)", gpio);
-
- if (!PWMDef[gpio])
- SOFT_ERROR(PI_NOT_HPWM_GPIO, "bad gpio for PWM (%d)", gpio);
-
- if (dutycycle > PI_HW_PWM_RANGE)
- SOFT_ERROR(PI_BAD_HPWM_DUTY, "bad PWM dutycycle (%d)", dutycycle);
-
- if (((frequency < PI_HW_PWM_MIN_FREQ) ||
- (frequency > PI_HW_PWM_MAX_FREQ)) &&
- (frequency))
- SOFT_ERROR(PI_BAD_HPWM_FREQ,
- "bad hardware PWM frequency (%d)", frequency);
-
- if (gpioCfg.clockPeriph == PI_CLOCK_PWM)
- SOFT_ERROR(PI_HPWM_ILLEGAL, "illegal, PWM in use for main clock");
-
- pwm = (PWMDef[gpio] >> 4) & 3;
- mode = PWMDef[gpio] & 7;
-
- if (frequency)
- {
- real_range = ((double)CLK_PLLD_FREQ / (2.0 * frequency)) + 0.5;
- real_dutycycle = ((uint64_t)dutycycle * real_range) / PI_HW_PWM_RANGE;
-
- /* record the set PWM frequency and dutycycle */
-
- hw_pwm_freq[pwm] =
- ((double)CLK_PLLD_FREQ / ( 2.0 * real_range)) + 0.5;
-
- hw_pwm_duty[pwm] = dutycycle;
-
- hw_pwm_real_range[pwm] = real_range;
-
- /* Abort any waveform transmission in progress */
-
- if (gpioWaveTxBusy()) gpioWaveTxStop();
-
- waveClockInited = 0;
-
- /* preserve channel enable only and mark space mode */
-
- old_PWM_CTL = pwmReg[PWM_CTL] &
- (PWM_CTL_PWEN1 | PWM_CTL_MSEN1 | PWM_CTL_PWEN2 | PWM_CTL_MSEN2);
-
- if (!PWMClockInited)
- {
- pwmReg[PWM_CTL] = 0;
-
- myGpioDelay(10);
-
- initHWClk(CLK_PWMCTL, CLK_PWMDIV, CLK_CTL_SRC_PLLD, 2, 0, 0);
-
- PWMClockInited = 1;
- }
-
- if (pwm == 0)
- {
- pwmReg[PWM_RNG1] = real_range;
- myGpioDelay(10);
- pwmReg[PWM_DAT1] = real_dutycycle;
- myGpioDelay(10);
-
- pwmReg[PWM_CTL] = (old_PWM_CTL | PWM_CTL_PWEN1 | PWM_CTL_MSEN1);
- }
- else
- {
- pwmReg[PWM_RNG2] = real_range;
- myGpioDelay(10);
- pwmReg[PWM_DAT2] = real_dutycycle;
- myGpioDelay(10);
-
- pwmReg[PWM_CTL] = (old_PWM_CTL | PWM_CTL_PWEN2 | PWM_CTL_MSEN2);
- }
-
- if (gpioInfo[gpio].is != GPIO_HW_PWM)
- {
- switchFunctionOff(gpio);
-
- myGpioSetMode(gpio, mode);
-
- gpioInfo[gpio].is = GPIO_HW_PWM;
- }
- }
- else
- {
- /* frequency 0, stop PWM */
-
- if (gpioInfo[gpio].is == GPIO_HW_PWM)
- {
- if (pwm == 0) pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN1);
- else pwmReg[PWM_CTL] &= (~PWM_CTL_PWEN2);
-
- gpioInfo[gpio].is = GPIO_UNDEFINED;
- }
- }
-
- return 0;
-}
-
-
-int gpioSetPad(unsigned pad, unsigned padStrength)
-{
- DBG(DBG_USER, "pad=%d padStrength=%d", pad, padStrength);
-
- CHECK_INITED;
-
- if (pad > PI_MAX_PAD)
- SOFT_ERROR(PI_BAD_PAD, "bad pad number (%d)", pad);
-
- if ((padStrength < PI_MIN_PAD_STRENGTH) ||
- (padStrength > PI_MAX_PAD_STRENGTH))
- SOFT_ERROR(PI_BAD_STRENGTH, "bad pad drive strength (%d)", pad);
-
- /* 1-16 -> 0-7 */
-
- padStrength += 1;
- padStrength /= 2;
- padStrength -= 1;
-
- padsReg[11+pad] = BCM_PASSWD | 0x18 | (padStrength & 7) ;
-
- return 0;
-}
-
-int gpioGetPad(unsigned pad)
-{
- int strength;
-
- DBG(DBG_USER, "pad=%d", pad);
-
- CHECK_INITED;
-
- if (pad > PI_MAX_PAD)
- SOFT_ERROR(PI_BAD_PAD, "bad pad (%d)", pad);
-
- strength = padsReg[11+pad] & 7;
-
- strength *= 2;
- strength += 2;
-
- return strength;
-}
-
-int shell(char *scriptName, char *scriptString)
-{
- int status;
- char buf[4096];
-
- DBG(DBG_USER, "name=%s string=%s", scriptName, scriptString);
-
- CHECK_INITED;
-
- if (!myScriptNameValid(scriptName))
- SOFT_ERROR(PI_BAD_SCRIPT_NAME, "bad script name (%s)", scriptName);
-
- snprintf(buf, sizeof(buf),
- "/opt/pigpio/cgi/%s %s", scriptName, scriptString);
-
- DBG(DBG_USER, "%s", buf);
-
- status = system(buf);
-
- if (status < 0) status = PI_BAD_SHELL_STATUS;
-
- return status;
-}
-
-
-int fileApprove(char *filename)
-{
- char match[PI_MAX_PATH];
- char buffer[PI_MAX_PATH];
- char line[PI_MAX_PATH];
- char mperm;
- char perm;
- char term;
- FILE *f;
-
- buffer[0] = 0;
- match[0] = 0;
-
- f = fopen("/opt/pigpio/access", "r");
-
- if (!f) return PI_FILE_NONE;
-
- while (!feof(f))
- {
- buffer[0] = 0;
- perm = 0;
- term = 0;
- if (fgets(line, sizeof(line), f))
- {
- sscanf(line, " %511s %c%c", buffer, &perm, &term);
- if (term == 10)
- {
- if (myPathBad(buffer)) continue; /* disallow risky lines */
-
- if (fnmatch(buffer, filename, 0) == 0)
- {
- if (match[0])
- {
- if (fnmatch(match, buffer, 0) == 0)
- {
- strcpy(match, buffer);
- mperm = perm;
- }
- }
- else
- {
- strcpy(match, buffer);
- mperm = perm;
- }
- }
- }
- }
- }
-
- fclose(f);
-
- if (match[0])
- {
- switch (toupper(mperm))
- {
- case 'R': return PI_FILE_READ;
- case 'W': return PI_FILE_WRITE;
- case 'U': return PI_FILE_RW;
- default : return PI_FILE_NONE;
- }
- }
-
- return PI_FILE_NONE;
-}
-
-int fileOpen(char *file, unsigned mode)
-{
- int fd=-1;
- int i, slot, oflag, omode;
- struct stat statbuf;
-
- DBG(DBG_USER, "file=%s mode=%d", file, mode);
-
- CHECK_INITED;
-
- if ( (mode < PI_FILE_MIN) ||
- (mode > PI_FILE_MAX) ||
- ((mode & PI_FILE_RW) == 0) )
- SOFT_ERROR(PI_BAD_FILE_MODE, "bad mode (%d)", mode);
-
- if ((fileApprove(file) & mode) == PI_FILE_NONE)
- SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", file);
-
- slot = -1;
-
- for (i=0; i= PI_FILE_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (fileInfo[handle].state != PI_FILE_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (fileInfo[handle].fd >= 0) close(fileInfo[handle].fd);
-
- fileInfo[handle].fd = -1;
- fileInfo[handle].state = PI_FILE_CLOSED;
-
- return 0;
-}
-
-int fileWrite(unsigned handle, char *buf, unsigned count)
-{
- int w;
-
- DBG(DBG_USER, "handle=%d count=%d [%s]",
- handle, count, myBuf2Str(count, buf));
-
- CHECK_INITED;
-
- if (handle >= PI_FILE_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (fileInfo[handle].state != PI_FILE_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (!count)
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- if (!(fileInfo[handle].mode & PI_FILE_WRITE))
- SOFT_ERROR(PI_FILE_NOT_WOPEN, "file not opened for write");
-
- w = write(fileInfo[handle].fd, buf, count);
-
- if (w != count)
- {
- if (w == -1) DBG(DBG_USER, "write failed with errno %d", errno);
-
- return PI_BAD_FILE_WRITE;
- }
- return 0;
-}
-
-int fileRead(unsigned handle, char *buf, unsigned count)
-{
- int r;
-
- DBG(DBG_USER, "handle=%d count=%d buf=0x%X", handle, count, (unsigned)buf);
-
- CHECK_INITED;
-
- if (handle >= PI_FILE_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (fileInfo[handle].state != PI_FILE_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (!count)
- SOFT_ERROR(PI_BAD_PARAM, "bad count (%d)", count);
-
- if (!(fileInfo[handle].mode & PI_FILE_READ))
- SOFT_ERROR(PI_FILE_NOT_ROPEN, "file not opened for read");
-
- r = read(fileInfo[handle].fd, buf, count);
-
- if (r == -1)
- {
- DBG(DBG_USER, "read failed with errno %d", errno);
- return PI_BAD_FILE_READ;
- }
- else
- {
- buf[r] = 0;
- return r;
- }
-}
-
-
-int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom)
-{
- int whence, s;
-
- DBG(DBG_USER, "handle=%d offset=%d from=%d",
- handle, seekOffset, seekFrom);
-
- CHECK_INITED;
-
- if (handle >= PI_FILE_SLOTS)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- if (fileInfo[handle].state != PI_FILE_OPENED)
- SOFT_ERROR(PI_BAD_HANDLE, "bad handle (%d)", handle);
-
- switch (seekFrom)
- {
- case PI_FROM_START:
- whence = SEEK_SET;
- break;
-
- case PI_FROM_CURRENT:
- whence = SEEK_CUR;
- break;
-
- case PI_FROM_END:
- whence = SEEK_END;
- break;
-
- default:
- SOFT_ERROR(PI_BAD_FILE_SEEK, "bad seek from (%d)", seekFrom);
- }
-
- s = lseek(fileInfo[handle].fd, seekOffset, whence);
-
- if (s == -1)
- {
- DBG(DBG_USER, "seek failed with errno %d", errno);
- return PI_BAD_FILE_SEEK;
- }
-
- return s;
-}
-
-int fileList(char *fpat, char *buf, unsigned count)
-{
- int len, bufpos;
- glob_t pglob;
- int i;
-
- DBG(DBG_USER, "fpat=%s count=%d buf=%x", fpat, count, (unsigned)buf);
-
- CHECK_INITED;
-
- if (fileApprove(fpat) == PI_FILE_NONE)
- SOFT_ERROR(PI_NO_FILE_ACCESS, "no permission to access file (%s)", fpat);
-
- bufpos = 0;
-
- if (glob(fpat, GLOB_MARK, NULL, &pglob) == 0)
- {
- for (i=0; i PI_TIME_ABSOLUTE)
- SOFT_ERROR(PI_BAD_TIMETYPE, "bad timetype (%d)", timetype);
-
- if (timetype == PI_TIME_ABSOLUTE)
- {
- clock_gettime(CLOCK_REALTIME, &ts);
- *seconds = ts.tv_sec;
- *micros = ts.tv_nsec/1000;
- }
- else
- {
- clock_gettime(CLOCK_REALTIME, &ts);
-
- TIMER_SUB(&ts, &libStarted, &ts);
-
- *seconds = ts.tv_sec;
- *micros = ts.tv_nsec/1000;
- }
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioSleep(unsigned timetype, int seconds, int micros)
-{
- struct timespec ts, rem;
-
- DBG(DBG_USER, "timetype=%d seconds=%d micros=%d",
- timetype, seconds, micros);
-
- CHECK_INITED;
-
- if (timetype > PI_TIME_ABSOLUTE)
- SOFT_ERROR(PI_BAD_TIMETYPE, "bad timetype (%d)", timetype);
-
- if (seconds < 0)
- SOFT_ERROR(PI_BAD_SECONDS, "bad seconds (%d)", seconds);
-
- if ((micros < 0) || (micros > 999999))
- SOFT_ERROR(PI_BAD_MICROS, "bad micros (%d)", micros);
-
- ts.tv_sec = seconds;
- ts.tv_nsec = micros * 1000;
-
- if (timetype == PI_TIME_ABSOLUTE)
- {
- while (clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &ts, &rem));
- }
- else
- {
- while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem))
- {
- /* copy remaining time to ts */
- ts.tv_sec = rem.tv_sec;
- ts.tv_nsec = rem.tv_nsec;
- }
- }
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t gpioDelay(uint32_t micros)
-{
- uint32_t start;
-
- DBG(DBG_USER, "microseconds=%u", micros);
-
- CHECK_INITED;
-
- start = systReg[SYST_CLO];
-
- if (micros <= PI_MAX_BUSY_DELAY)
- while ((systReg[SYST_CLO] - start) <= micros);
- else
- gpioSleep(PI_TIME_RELATIVE, (micros/MILLION), (micros%MILLION));
-
- return (systReg[SYST_CLO] - start);
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-uint32_t gpioTick(void)
-{
- CHECK_INITED;
-
- return systReg[SYST_CLO];
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-unsigned gpioVersion(void)
-{
- DBG(DBG_USER, "");
-
- return PIGPIO_VERSION;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-/*
-2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
-5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
-
-W W S M M M B B B B P P P P T T T T T T T T R R R R
-
-W warranty void if either bit is set
-
-S 0=old (bits 0-22 are revision number) 1=new (following fields apply)
-
-M 0=256 1=512 2=1024
-
-B 0=Sony 1=Egoman 2=Embest 3=Unknown 4=Embest
-
-P 0=2835, 1=2836, 2=2837
-
-T 0=A 1=B 2=A+ 3=B+ 4=Pi2B 5=Alpha 6=Compute Module 7=Unknown 8=Pi3B 9=Zero
-
-R PCB board revision
-
-*/
-
-unsigned gpioHardwareRevision(void)
-{
- static unsigned rev = 0;
-
- FILE * filp;
- char buf[512];
- char term;
-
- DBG(DBG_USER, "");
-
- if (rev) return rev;
-
- piCores = 0;
-
- filp = fopen ("/proc/cpuinfo", "r");
-
- if (filp != NULL)
- {
- while (fgets(buf, sizeof(buf), filp) != NULL)
- {
- if (piCores == 0)
- {
- if (!strncasecmp("model name", buf, 10))
- {
- if (strstr (buf, "ARMv6") != NULL)
- {
- piCores = 1;
- pi_peri_phys = 0x20000000;
- pi_dram_bus = 0x40000000;
- pi_mem_flag = 0x0C;
- }
- else if (strstr (buf, "ARMv7") != NULL)
- {
- piCores = 4;
- pi_peri_phys = 0x3F000000;
- pi_dram_bus = 0xC0000000;
- pi_mem_flag = 0x04;
- }
- else if (strstr (buf, "ARMv8") != NULL)
- {
- piCores = 4;
- pi_peri_phys = 0x3F000000;
- pi_dram_bus = 0xC0000000;
- pi_mem_flag = 0x04;
- }
- }
- }
-
- if (!strncasecmp("revision\t:", buf, 10))
- {
- if (sscanf(buf+10, "%x%c", &rev, &term) == 2)
- {
- if (term != '\n') rev = 0;
- else rev &= 0xFFFFFF; /* mask out warranty bit */
- }
- }
- }
-
- fclose(filp);
- }
- return rev;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgBufferSize(unsigned millis)
-{
- DBG(DBG_USER, "millis=%d", millis);
-
- CHECK_NOT_INITED;
-
- if ((millis < PI_BUF_MILLIS_MIN) || (millis > PI_BUF_MILLIS_MAX))
- SOFT_ERROR(PI_BAD_BUF_MILLIS, "bad millis (%d)", millis);
-
- gpioCfg.bufferMilliseconds = millis;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgClock(unsigned micros, unsigned peripheral, unsigned source)
-{
- DBG(DBG_USER, "micros=%d peripheral=%d", micros, peripheral);
-
- CHECK_NOT_INITED;
-
- if ((micros < 1) || (micros > 10))
- SOFT_ERROR(PI_BAD_CLK_MICROS, "bad micros (%d)", micros);
-
- if (!clkCfg[micros].valid)
- SOFT_ERROR(PI_BAD_CLK_MICROS, "bad micros (%d)", micros);
-
- if (peripheral > PI_CLOCK_PCM)
- SOFT_ERROR(PI_BAD_CLK_PERIPH, "bad peripheral (%d)", peripheral);
-
- gpioCfg.clockMicros = micros;
- gpioCfg.clockPeriph = peripheral;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgDMAchannel(unsigned DMAchannel)
-{
- DBG(DBG_USER, "channel=%d", DMAchannel);
-
- CHECK_NOT_INITED;
-
- if ((DMAchannel < PI_MIN_DMA_CHANNEL) || (DMAchannel > PI_MAX_DMA_CHANNEL))
- SOFT_ERROR(PI_BAD_CHANNEL, "bad channel (%d)", DMAchannel);
-
- gpioCfg.DMAprimaryChannel = DMAchannel;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgDMAchannels(unsigned primaryChannel, unsigned secondaryChannel)
-{
- DBG(DBG_USER, "primary channel=%d, secondary channel=%d",
- primaryChannel, secondaryChannel);
-
- CHECK_NOT_INITED;
-
- if (primaryChannel > PI_MAX_DMA_CHANNEL)
- SOFT_ERROR(PI_BAD_PRIM_CHANNEL, "bad primary channel (%d)",
- primaryChannel);
-
- if ((secondaryChannel > PI_MAX_DMA_CHANNEL) ||
- (secondaryChannel == primaryChannel))
- SOFT_ERROR(PI_BAD_SECO_CHANNEL, "bad secondary channel (%d)",
- secondaryChannel);
-
- gpioCfg.DMAprimaryChannel = primaryChannel;
- gpioCfg.DMAsecondaryChannel = secondaryChannel;
-
- return 0;
-}
-
-
-/*-------------------------------------------------------------------------*/
-
-int gpioCfgPermissions(uint64_t updateMask)
-{
- DBG(DBG_USER, "gpio update mask=%llX", updateMask);
-
- CHECK_NOT_INITED;
-
- gpioMask = updateMask;
-
- gpioMaskSet = 1;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgInterfaces(unsigned ifFlags)
-{
- DBG(DBG_USER, "ifFlags=%X", ifFlags);
-
- CHECK_NOT_INITED;
-
- if (ifFlags > 7)
- SOFT_ERROR(PI_BAD_IF_FLAGS, "bad ifFlags (%X)", ifFlags);
-
- gpioCfg.ifFlags = ifFlags;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgSocketPort(unsigned port)
-{
- DBG(DBG_USER, "port=%d", port);
-
- CHECK_NOT_INITED;
-
- if ((port < PI_MIN_SOCKET_PORT) || (port > PI_MAX_SOCKET_PORT))
- SOFT_ERROR(PI_BAD_SOCKET_PORT, "bad port (%d)", port);
-
- gpioCfg.socketPort = port;
-
- return 0;
-}
-
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgMemAlloc(unsigned memAllocMode)
-{
- DBG(DBG_USER, "memAllocMode=%d", memAllocMode);
-
- CHECK_NOT_INITED;
-
- if (memAllocMode > PI_MEM_ALLOC_MAILBOX)
- SOFT_ERROR(
- PI_BAD_MALLOC_MODE, "bad mem alloc mode (%d)", memAllocMode);
-
- gpioCfg.memAllocMode = memAllocMode;
-
- return 0;
-}
-
-/* ----------------------------------------------------------------------- */
-
-int gpioCfgNetAddr(int numSockAddr, uint32_t *sockAddr)
-{
- int i;
-
- DBG(DBG_USER, "numSockAddr=%d sockAddr=%08X",
- numSockAddr, (unsigned)sockAddr);
-
- CHECK_NOT_INITED;
-
- if (numSockAddr <= 0) numSockNetAddr = 0;
- else
- {
- if (numSockAddr >= MAX_CONNECT_ADDRESSES)
- numSockAddr = MAX_CONNECT_ADDRESSES;
-
- for (i=0; i>4) & 0xF;
- return 0;
-}
-
-int gpioCfgInternals(unsigned cfgWhat, unsigned cfgVal)
-{
- int retVal = PI_BAD_CFG_INTERNAL;
-
- DBG(DBG_USER, "cfgWhat=%u, cfgVal=%d", cfgWhat, cfgVal);
-
- switch(cfgWhat)
- {
- case 562484977:
-
- if (cfgVal) gpioCfg.internals |= PI_CFG_STATS;
- else gpioCfg.internals &= (~PI_CFG_STATS);
-
- DBG(DBG_ALWAYS, "show stats is %u", cfgVal);
-
- retVal = 0;
-
- break;
-
- case 984762879:
-
- if ((cfgVal >= DBG_ALWAYS) && (cfgVal <= DBG_MAX_LEVEL))
- {
-
- gpioCfg.dbgLevel = cfgVal;
- gpioCfg.internals = (gpioCfg.internals & (~0xF)) | cfgVal;
-
- DBG(DBG_ALWAYS, "Debug level is %u", cfgVal);
-
- retVal = 0;
- }
-
- break;
- }
-
- return retVal;
-}
-
-
-/* include any user customisations */
-
-#include "custom.cext"
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.h b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.h
deleted file mode 100644
index 0822e189f..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.h
+++ /dev/null
@@ -1,5942 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-#ifndef PIGPIO_H
-#define PIGPIO_H
-
-#include
-#include
-
-#define PIGPIO_VERSION 56
-
-/*TEXT
-
-pigpio is a C library for the Raspberry which allows control of the GPIO.
-
-*Features*
-
-o hardware timed PWM on any of GPIO 0-31
-
-o hardware timed servo pulses on any of GPIO 0-31
-
-o callbacks when any of GPIO 0-31 change state
-
-o callbacks at timed intervals
-
-o reading/writing all of the GPIO in a bank as one operation
-
-o individually setting GPIO modes, reading and writing
-
-o notifications when any of GPIO 0-31 change state
-
-o the construction of output waveforms with microsecond timing
-
-o rudimentary permission control over GPIO
-
-o a simple interface to start and stop new threads
-
-o I2C, SPI, and serial link wrappers
-
-o creating and running scripts
-
-*GPIO*
-
-ALL GPIO are identified by their Broadcom number.
-
-*Credits*
-
-The PWM and servo pulses are timed using the DMA and PWM peripherals.
-
-This use was inspired by Richard Hirst's servoblaster kernel module.
-
-See [[https://github.com/richardghirst/PiBits/tree/master/ServoBlaster]]
-
-*Usage*
-
-Include in your source files.
-
-Assuming your source is in prog.c use the following command to build and
-run the executable.
-
-. .
-gcc -Wall -pthread -o prog prog.c -lpigpio -lrt
-sudo ./prog
-. .
-
-For examples of usage see the C programs within the pigpio archive file.
-
-*Notes*
-
-All the functions which return an int return < 0 on error.
-
-[*gpioInitialise*] must be called before all other library functions
-with the following exceptions:
-
-. .
-[*gpioCfg**]
-[*gpioVersion*]
-[*gpioHardwareRevision*]
-. .
-
-If the library is not initialised all but the [*gpioCfg**],
-[*gpioVersion*], and [*gpioHardwareRevision*] functions will
-return error PI_NOT_INITIALISED.
-
-If the library is initialised the [*gpioCfg**] functions will return
-error PI_INITIALISED.
-
-TEXT*/
-
-/*OVERVIEW
-
-ESSENTIAL
-
-gpioInitialise Initialise library
-gpioTerminate Stop library
-
-BEGINNER
-
-gpioSetMode Set a GPIO mode
-gpioGetMode Get a GPIO mode
-
-gpioSetPullUpDown Set/clear GPIO pull up/down resistor
-
-gpioRead Read a GPIO
-gpioWrite Write a GPIO
-
-gpioPWM Start/stop PWM pulses on a GPIO
-gpioGetPWMdutycycle Get dutycycle setting on a GPIO
-
-gpioServo Start/stop servo pulses on a GPIO
-gpioGetServoPulsewidth Get pulsewidth setting on a GPIO
-
-gpioDelay Delay for a number of microseconds
-
-gpioSetAlertFunc Request a GPIO level change callback
-
-gpioSetTimerFunc Request a regular timed callback
-
-INTERMEDIATE
-
-gpioTrigger Send a trigger pulse to a GPIO.
-
-gpioSetWatchdog Set a watchdog on a GPIO.
-
-gpioSetPWMrange Configure PWM range for a GPIO
-gpioGetPWMrange Get configured PWM range for a GPIO
-
-gpioSetPWMfrequency Configure PWM frequency for a GPIO
-gpioGetPWMfrequency Get configured PWM frequency for a GPIO
-
-gpioRead_Bits_0_31 Read all GPIO in bank 1
-gpioRead_Bits_32_53 Read all GPIO in bank 2
-
-gpioWrite_Bits_0_31_Clear Clear selected GPIO in bank 1
-gpioWrite_Bits_32_53_Clear Clear selected GPIO in bank 2
-
-gpioWrite_Bits_0_31_Set Set selected GPIO in bank 1
-gpioWrite_Bits_32_53_Set Set selected GPIO in bank 2
-
-gpioStartThread Start a new thread
-gpioStopThread Stop a previously started thread
-
-ADVANCED
-
-gpioGetPWMrealRange Get underlying PWM range for a GPIO
-
-gpioSetAlertFuncEx Request a GPIO change callback, extended
-
-gpioSetISRFunc Request a GPIO interrupt callback
-gpioSetISRFuncEx Request a GPIO interrupt callback, extended
-
-gpioSetSignalFunc Request a signal callback
-gpioSetSignalFuncEx Request a signal callback, extended
-
-gpioSetGetSamplesFunc Requests a GPIO samples callback
-gpioSetGetSamplesFuncEx Requests a GPIO samples callback, extended
-
-gpioSetTimerFuncEx Request a regular timed callback, extended
-
-gpioNotifyOpen Request a notification handle
-gpioNotifyOpenWithSize Request a notification handle with sized pipe
-gpioNotifyBegin Start notifications for selected GPIO
-gpioNotifyPause Pause notifications
-gpioNotifyClose Close a notification
-
-gpioSerialReadOpen Opens a GPIO for bit bang serial reads
-gpioSerialReadInvert Configures normal/inverted for serial reads
-gpioSerialRead Reads bit bang serial data from a GPIO
-gpioSerialReadClose Closes a GPIO for bit bang serial reads
-
-gpioHardwareClock Start hardware clock on supported GPIO
-gpioHardwarePWM Start hardware PWM on supported GPIO
-
-gpioGlitchFilter Set a glitch filter on a GPIO
-gpioNoiseFilter Set a noise filter on a GPIO
-
-gpioGetPad Gets a pads drive strength
-gpioSetPad Sets a pads drive strength
-
-shell Executes a shell command
-
-SCRIPTS
-
-gpioStoreScript Store a script
-gpioRunScript Run a stored script
-gpioScriptStatus Get script status and parameters
-gpioStopScript Stop a running script
-gpioDeleteScript Delete a stored script
-
-WAVES
-
-gpioWaveClear Deletes all waveforms
-
-gpioWaveAddNew Starts a new waveform
-gpioWaveAddGeneric Adds a series of pulses to the waveform
-gpioWaveAddSerial Adds serial data to the waveform
-
-gpioWaveCreate Creates a waveform from added data
-gpioWaveDelete Deletes a waveform
-
-gpioWaveTxSend Transmits a waveform
-
-gpioWaveChain Transmits a chain of waveforms
-
-gpioWaveTxAt Returns the current transmitting waveform
-
-gpioWaveTxBusy Checks to see if the waveform has ended
-gpioWaveTxStop Aborts the current waveform
-
-gpioWaveGetMicros Length in microseconds of the current waveform
-gpioWaveGetHighMicros Length of longest waveform so far
-gpioWaveGetMaxMicros Absolute maximum allowed micros
-
-gpioWaveGetPulses Length in pulses of the current waveform
-gpioWaveGetHighPulses Length of longest waveform so far
-gpioWaveGetMaxPulses Absolute maximum allowed pulses
-
-gpioWaveGetCbs Length in control blocks of the current waveform
-gpioWaveGetHighCbs Length of longest waveform so far
-gpioWaveGetMaxCbs Absolute maximum allowed control blocks
-
-I2C
-
-i2cOpen Opens an I2C device
-i2cClose Closes an I2C device
-
-i2cWriteQuick SMBus write quick
-i2cWriteByte SMBus write byte
-i2cReadByte SMBus read byte
-i2cWriteByteData SMBus write byte data
-i2cWriteWordData SMBus write word data
-i2cReadByteData SMBus read byte data
-i2cReadWordData SMBus read word data
-i2cProcessCall SMBus process call
-i2cWriteBlockData SMBus write block data
-i2cReadBlockData SMBus read block data
-i2cBlockProcessCall SMBus block process call
-
-i2cWriteI2CBlockData SMBus write I2C block data
-i2cReadI2CBlockData SMBus read I2C block data
-
-i2cReadDevice Reads the raw I2C device
-i2cWriteDevice Writes the raw I2C device
-
-i2cSwitchCombined Sets or clears the combined flag
-
-i2cSegments Performs multiple I2C transactions
-
-i2cZip Performs multiple I2C transactions
-
-bbI2COpen Opens GPIO for bit banging I2C
-bbI2CClose Closes GPIO for bit banging I2C
-bbI2CZip Performs multiple bit banged I2C transactions
-
-SPI
-
-spiOpen Opens a SPI device
-spiClose Closes a SPI device
-
-spiRead Reads bytes from a SPI device
-spiWrite Writes bytes to a SPI device
-spiXfer Transfers bytes with a SPI device
-
-bbSPIOpen Opens GPIO for bit banging SPI
-bbSPIClose Closes GPIO for bit banging SPI
-bbSPIXfer Performs multiple bit banged SPI transactions
-
-SERIAL
-
-serOpen Opens a serial device
-serClose Closes a serial device
-
-serReadByte Reads a byte from a serial device
-serWriteByte Writes a byte to a serial device
-serRead Reads bytes from a serial device
-serWrite Writes bytes to a serial device
-
-serDataAvailable Returns number of bytes ready to be read
-
-FILES
-
-fileOpen Opens a file
-fileClose Closes a file
-fileRead Reads bytes from a file
-fileWrite Writes bytes to a file
-fileSeek Seeks to a position within a file
-fileList List files which match a pattern
-
-CONFIGURATION
-
-gpioCfgBufferSize Configure the GPIO sample buffer size
-gpioCfgClock Configure the GPIO sample rate
-gpioCfgDMAchannel Configure the DMA channel (DEPRECATED)
-gpioCfgDMAchannels Configure the DMA channels
-gpioCfgPermissions Configure the GPIO access permissions
-gpioCfgInterfaces Configure user interfaces
-gpioCfgSocketPort Configure socket port
-gpioCfgMemAlloc Configure DMA memory allocation mode
-gpioCfgNetAddr Configure allowed network addresses
-
-gpioCfgInternals Configure miscellaneous internals (DEPRECATED)
-gpioCfgGetInternals Get internal configuration settings
-gpioCfgSetInternals Set internal configuration settings
-
-CUSTOM
-
-gpioCustom1 User custom function 1
-gpioCustom2 User custom function 2
-
-UTILITIES
-
-gpioTick Get current tick (microseconds)
-
-gpioHardwareRevision Get hardware revision
-gpioVersion Get the pigpio version
-
-getBitInBytes Get the value of a bit
-putBitInBytes Set the value of a bit
-
-gpioTime Get current time
-gpioSleep Sleep for specified time
-
-time_sleep Sleeps for a float number of seconds
-time_time Float number of seconds since the epoch
-
-EXPERT
-
-rawWaveAddSPI Not intended for general use
-rawWaveAddGeneric Not intended for general use
-rawWaveCB Not intended for general use
-rawWaveCBAdr Not intended for general use
-rawWaveGetOOL Not intended for general use
-rawWaveSetOOL Not intended for general use
-rawWaveGetOut Not intended for general use
-rawWaveSetOut Not intended for general use
-rawWaveGetIn Not intended for general use
-rawWaveSetIn Not intended for general use
-rawWaveInfo Not intended for general use
-rawDumpWave Not intended for general use
-rawDumpScript Not intended for general use
-
-OVERVIEW*/
-
-#define PI_INPFIFO "/dev/pigpio"
-#define PI_OUTFIFO "/dev/pigout"
-#define PI_ERRFIFO "/dev/pigerr"
-
-#define PI_ENVPORT "PIGPIO_PORT"
-#define PI_ENVADDR "PIGPIO_ADDR"
-
-#define PI_LOCKFILE "/var/run/pigpio.pid"
-
-#define PI_I2C_COMBINED "/sys/module/i2c_bcm2708/parameters/combined"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct
-{
- uint16_t func;
- uint16_t size;
-} gpioHeader_t;
-
-typedef struct
-{
- size_t size;
- void *ptr;
- uint32_t data;
-} gpioExtent_t;
-
-typedef struct
-{
- uint32_t tick;
- uint32_t level;
-} gpioSample_t;
-
-typedef struct
-{
- uint16_t seqno;
- uint16_t flags;
- uint32_t tick;
- uint32_t level;
-} gpioReport_t;
-
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
-} gpioPulse_t;
-
-#define WAVE_FLAG_READ 1
-#define WAVE_FLAG_TICK 2
-
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
- uint32_t flags;
-} rawWave_t;
-
-/*
-CBs are used in order from the lowest numbered CB up to
-the maximum NUM_WAVE_CBS.
-
-OOLS are used from the bottom climbing up and from
-the top climbing down.
-
-The GPIO on and off settings climb up from the bottom (botOOL/numBOOL).
-
-The level and tick read values are stored in descending locations
-from the top (topOOL/numTOOL).
-*/
-
-typedef struct
-{
- uint16_t botCB; /* first CB used by wave */
- uint16_t topCB; /* last CB used by wave */
- uint16_t botOOL; /* first bottom OOL used by wave */
- /* botOOL to botOOL + numBOOL - 1 are in use */
- uint16_t topOOL; /* last top OOL used by wave */
- /* topOOL - numTOOL to topOOL are in use.*/
- uint16_t deleted;
- uint16_t numCB;
- uint16_t numBOOL;
- uint16_t numTOOL;
-} rawWaveInfo_t;
-
-typedef struct
-{
- int clk; /* GPIO for clock */
- int mosi; /* GPIO for MOSI */
- int miso; /* GPIO for MISO */
- int ss_pol; /* slave select off state */
- int ss_us; /* delay after slave select */
- int clk_pol; /* clock off state */
- int clk_pha; /* clock phase */
- int clk_us; /* clock micros */
-} rawSPI_t;
-
-typedef struct { /* linux/arch/arm/mach-bcm2708/include/mach/dma.h */
- uint32_t info;
- uint32_t src;
- uint32_t dst;
- uint32_t length;
- uint32_t stride;
- uint32_t next;
- uint32_t pad[2];
-} rawCbs_t;
-
-typedef struct
-{
- uint16_t addr; /* slave address */
- uint16_t flags;
- uint16_t len; /* msg length */
- uint8_t *buf; /* pointer to msg data */
-} pi_i2c_msg_t;
-
-typedef void (*gpioAlertFunc_t) (int gpio,
- int level,
- uint32_t tick);
-
-typedef void (*gpioAlertFuncEx_t) (int gpio,
- int level,
- uint32_t tick,
- void *userdata);
-
-typedef void (*gpioISRFunc_t) (int gpio,
- int level,
- uint32_t tick);
-
-typedef void (*gpioISRFuncEx_t) (int gpio,
- int level,
- uint32_t tick,
- void *userdata);
-
-typedef void (*gpioTimerFunc_t) (void);
-
-typedef void (*gpioTimerFuncEx_t) (void *userdata);
-
-typedef void (*gpioSignalFunc_t) (int signum);
-
-typedef void (*gpioSignalFuncEx_t) (int signum,
- void *userdata);
-
-typedef void (*gpioGetSamplesFunc_t) (const gpioSample_t *samples,
- int numSamples);
-
-typedef void (*gpioGetSamplesFuncEx_t) (const gpioSample_t *samples,
- int numSamples,
- void *userdata);
-
-typedef void *(gpioThreadFunc_t) (void *);
-
-
-/* gpio: 0-53 */
-
-#define PI_MIN_GPIO 0
-#define PI_MAX_GPIO 53
-
-/* user_gpio: 0-31 */
-
-#define PI_MAX_USER_GPIO 31
-
-/* level: 0-1 */
-
-#define PI_OFF 0
-#define PI_ON 1
-
-#define PI_CLEAR 0
-#define PI_SET 1
-
-#define PI_LOW 0
-#define PI_HIGH 1
-
-/* level: only reported for GPIO time-out, see gpioSetWatchdog */
-
-#define PI_TIMEOUT 2
-
-/* mode: 0-7 */
-
-#define PI_INPUT 0
-#define PI_OUTPUT 1
-#define PI_ALT0 4
-#define PI_ALT1 5
-#define PI_ALT2 6
-#define PI_ALT3 7
-#define PI_ALT4 3
-#define PI_ALT5 2
-
-/* pud: 0-2 */
-
-#define PI_PUD_OFF 0
-#define PI_PUD_DOWN 1
-#define PI_PUD_UP 2
-
-/* dutycycle: 0-range */
-
-#define PI_DEFAULT_DUTYCYCLE_RANGE 255
-
-/* range: 25-40000 */
-
-#define PI_MIN_DUTYCYCLE_RANGE 25
-#define PI_MAX_DUTYCYCLE_RANGE 40000
-
-/* pulsewidth: 0, 500-2500 */
-
-#define PI_SERVO_OFF 0
-#define PI_MIN_SERVO_PULSEWIDTH 500
-#define PI_MAX_SERVO_PULSEWIDTH 2500
-
-/* hardware PWM */
-
-#define PI_HW_PWM_MIN_FREQ 1
-#define PI_HW_PWM_MAX_FREQ 125000000
-#define PI_HW_PWM_RANGE 1000000
-
-/* hardware clock */
-
-#define PI_HW_CLK_MIN_FREQ 4689
-#define PI_HW_CLK_MAX_FREQ 250000000
-
-#define PI_NOTIFY_SLOTS 32
-
-#define PI_NTFY_FLAGS_ALIVE (1 <<6)
-#define PI_NTFY_FLAGS_WDOG (1 <<5)
-#define PI_NTFY_FLAGS_BIT(x) (((x)<<0)&31)
-
-#define PI_WAVE_BLOCKS 4
-#define PI_WAVE_MAX_PULSES (PI_WAVE_BLOCKS * 3000)
-#define PI_WAVE_MAX_CHARS (PI_WAVE_BLOCKS * 300)
-
-#define PI_BB_I2C_MIN_BAUD 50
-#define PI_BB_I2C_MAX_BAUD 500000
-
-#define PI_BB_SPI_MIN_BAUD 50
-#define PI_BB_SPI_MAX_BAUD 250000
-
-#define PI_BB_SER_MIN_BAUD 50
-#define PI_BB_SER_MAX_BAUD 250000
-
-#define PI_BB_SER_NORMAL 0
-#define PI_BB_SER_INVERT 1
-
-#define PI_WAVE_MIN_BAUD 50
-#define PI_WAVE_MAX_BAUD 1000000
-
-#define PI_SPI_MIN_BAUD 32000
-#define PI_SPI_MAX_BAUD 125000000
-
-#define PI_MIN_WAVE_DATABITS 1
-#define PI_MAX_WAVE_DATABITS 32
-
-#define PI_MIN_WAVE_HALFSTOPBITS 2
-#define PI_MAX_WAVE_HALFSTOPBITS 8
-
-#define PI_WAVE_MAX_MICROS (30 * 60 * 1000000) /* half an hour */
-
-#define PI_MAX_WAVES 250
-
-#define PI_MAX_WAVE_CYCLES 65535
-#define PI_MAX_WAVE_DELAY 65535
-
-#define PI_WAVE_COUNT_PAGES 10
-
-/* wave tx mode */
-
-#define PI_WAVE_MODE_ONE_SHOT 0
-#define PI_WAVE_MODE_REPEAT 1
-#define PI_WAVE_MODE_ONE_SHOT_SYNC 2
-#define PI_WAVE_MODE_REPEAT_SYNC 3
-
-/* special wave at return values */
-
-#define PI_WAVE_NOT_FOUND 9998 /* Transmitted wave not found. */
-#define PI_NO_TX_WAVE 9999 /* No wave being transmitted. */
-
-/* Files, I2C, SPI, SER */
-
-#define PI_FILE_SLOTS 8
-#define PI_I2C_SLOTS 32
-#define PI_SPI_SLOTS 16
-#define PI_SER_SLOTS 8
-
-#define PI_MAX_I2C_ADDR 0x7F
-
-#define PI_NUM_AUX_SPI_CHANNEL 3
-#define PI_NUM_STD_SPI_CHANNEL 2
-
-#define PI_MAX_I2C_DEVICE_COUNT (1<<16)
-#define PI_MAX_SPI_DEVICE_COUNT (1<<16)
-
-/* max pi_i2c_msg_t per transaction */
-
-#define PI_I2C_RDRW_IOCTL_MAX_MSGS 42
-
-/* flags for i2cTransaction, pi_i2c_msg_t */
-
-#define PI_I2C_M_WR 0x0000 /* write data */
-#define PI_I2C_M_RD 0x0001 /* read data */
-#define PI_I2C_M_TEN 0x0010 /* ten bit chip address */
-#define PI_I2C_M_RECV_LEN 0x0400 /* length will be first received byte */
-#define PI_I2C_M_NO_RD_ACK 0x0800 /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define PI_I2C_M_IGNORE_NAK 0x1000 /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define PI_I2C_M_REV_DIR_ADDR 0x2000 /* if I2C_FUNC_PROTOCOL_MANGLING */
-#define PI_I2C_M_NOSTART 0x4000 /* if I2C_FUNC_PROTOCOL_MANGLING */
-
-/* bbI2CZip and i2cZip commands */
-
-#define PI_I2C_END 0
-#define PI_I2C_ESC 1
-#define PI_I2C_START 2
-#define PI_I2C_COMBINED_ON 2
-#define PI_I2C_STOP 3
-#define PI_I2C_COMBINED_OFF 3
-#define PI_I2C_ADDR 4
-#define PI_I2C_FLAGS 5
-#define PI_I2C_READ 6
-#define PI_I2C_WRITE 7
-
-/* SPI */
-
-#define PI_SPI_FLAGS_BITLEN(x) ((x&63)<<16)
-#define PI_SPI_FLAGS_RX_LSB(x) ((x&1)<<15)
-#define PI_SPI_FLAGS_TX_LSB(x) ((x&1)<<14)
-#define PI_SPI_FLAGS_3WREN(x) ((x&15)<<10)
-#define PI_SPI_FLAGS_3WIRE(x) ((x&1)<<9)
-#define PI_SPI_FLAGS_AUX_SPI(x) ((x&1)<<8)
-#define PI_SPI_FLAGS_RESVD(x) ((x&7)<<5)
-#define PI_SPI_FLAGS_CSPOLS(x) ((x&7)<<2)
-#define PI_SPI_FLAGS_MODE(x) ((x&3))
-
-/* Longest busy delay */
-
-#define PI_MAX_BUSY_DELAY 100
-
-/* timeout: 0-60000 */
-
-#define PI_MIN_WDOG_TIMEOUT 0
-#define PI_MAX_WDOG_TIMEOUT 60000
-
-/* timer: 0-9 */
-
-#define PI_MIN_TIMER 0
-#define PI_MAX_TIMER 9
-
-/* millis: 10-60000 */
-
-#define PI_MIN_MS 10
-#define PI_MAX_MS 60000
-
-#define PI_MAX_SCRIPTS 32
-
-#define PI_MAX_SCRIPT_TAGS 50
-#define PI_MAX_SCRIPT_VARS 150
-#define PI_MAX_SCRIPT_PARAMS 10
-
-/* script status */
-
-#define PI_SCRIPT_INITING 0
-#define PI_SCRIPT_HALTED 1
-#define PI_SCRIPT_RUNNING 2
-#define PI_SCRIPT_WAITING 3
-#define PI_SCRIPT_FAILED 4
-
-/* signum: 0-63 */
-
-#define PI_MIN_SIGNUM 0
-#define PI_MAX_SIGNUM 63
-
-/* timetype: 0-1 */
-
-#define PI_TIME_RELATIVE 0
-#define PI_TIME_ABSOLUTE 1
-
-#define PI_MAX_MICS_DELAY 1000000 /* 1 second */
-#define PI_MAX_MILS_DELAY 60000 /* 60 seconds */
-
-/* cfgMillis */
-
-#define PI_BUF_MILLIS_MIN 100
-#define PI_BUF_MILLIS_MAX 10000
-
-/* cfgMicros: 1, 2, 4, 5, 8, or 10 */
-
-/* cfgPeripheral: 0-1 */
-
-#define PI_CLOCK_PWM 0
-#define PI_CLOCK_PCM 1
-
-/* DMA channel: 0-14 */
-
-#define PI_MIN_DMA_CHANNEL 0
-#define PI_MAX_DMA_CHANNEL 14
-
-/* port */
-
-#define PI_MIN_SOCKET_PORT 1024
-#define PI_MAX_SOCKET_PORT 32000
-
-
-/* ifFlags: */
-
-#define PI_DISABLE_FIFO_IF 1
-#define PI_DISABLE_SOCK_IF 2
-#define PI_LOCALHOST_SOCK_IF 4
-
-/* memAllocMode */
-
-#define PI_MEM_ALLOC_AUTO 0
-#define PI_MEM_ALLOC_PAGEMAP 1
-#define PI_MEM_ALLOC_MAILBOX 2
-
-/* filters */
-
-#define PI_MAX_STEADY 300000
-#define PI_MAX_ACTIVE 1000000
-
-/* gpioCfgInternals */
-
-#define PI_CFG_DBG_LEVEL 0 /* bits 0-3 */
-#define PI_CFG_ALERT_FREQ 4 /* bits 4-7 */
-#define PI_CFG_RT_PRIORITY (1<<8)
-#define PI_CFG_STATS (1<<9)
-
-#define PI_CFG_ILLEGAL_VAL (1<<10)
-
-/* gpioISR */
-
-#define RISING_EDGE 0
-#define FALLING_EDGE 1
-#define EITHER_EDGE 2
-
-
-/* pads */
-
-#define PI_MAX_PAD 2
-
-#define PI_MIN_PAD_STRENGTH 1
-#define PI_MAX_PAD_STRENGTH 16
-
-/* files */
-
-#define PI_FILE_NONE 0
-#define PI_FILE_MIN 1
-#define PI_FILE_READ 1
-#define PI_FILE_WRITE 2
-#define PI_FILE_RW 3
-#define PI_FILE_APPEND 4
-#define PI_FILE_CREATE 8
-#define PI_FILE_TRUNC 16
-#define PI_FILE_MAX 31
-
-#define PI_FROM_START 0
-#define PI_FROM_CURRENT 1
-#define PI_FROM_END 2
-
-/* Allowed socket connect addresses */
-
-#define MAX_CONNECT_ADDRESSES 256
-
-/*F*/
-int gpioInitialise(void);
-/*D
-Initialises the library.
-
-Returns the pigpio version number if OK, otherwise PI_INIT_FAILED.
-
-gpioInitialise must be called before using the other library functions
-with the following exceptions:
-
-. .
-[*gpioCfg**]
-[*gpioVersion*]
-[*gpioHardwareRevision*]
-. .
-
-...
-if (gpioInitialise() < 0)
-{
- // pigpio initialisation failed.
-}
-else
-{
- // pigpio initialised okay.
-}
-...
-D*/
-
-
-/*F*/
-void gpioTerminate(void);
-/*D
-Terminates the library.
-
-Returns nothing.
-
-Call before program exit.
-
-This function resets the used DMA channels, releases memory, and
-terminates any running threads.
-
-...
-gpioTerminate();
-...
-D*/
-
-
-/*F*/
-int gpioSetMode(unsigned gpio, unsigned mode);
-/*D
-Sets the GPIO mode, typically input or output.
-
-. .
-gpio: 0-53
-mode: 0-7
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_MODE.
-
-Arduino style: pinMode.
-
-...
-gpioSetMode(17, PI_INPUT); // Set GPIO17 as input.
-
-gpioSetMode(18, PI_OUTPUT); // Set GPIO18 as output.
-
-gpioSetMode(22,PI_ALT0); // Set GPIO22 to alternative mode 0.
-...
-D*/
-
-
-/*F*/
-int gpioGetMode(unsigned gpio);
-/*D
-Gets the GPIO mode.
-
-. .
-gpio: 0-53
-. .
-
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-
-...
-if (gpioGetMode(17) != PI_ALT0)
-{
- gpioSetMode(17, PI_ALT0); // set GPIO17 to ALT0
-}
-...
-D*/
-
-
-/*F*/
-int gpioSetPullUpDown(unsigned gpio, unsigned pud);
-/*D
-Sets or clears resistor pull ups or downs on the GPIO.
-
-. .
-gpio: 0-53
- pud: 0-2
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_PUD.
-
-...
-gpioSetPullUpDown(17, PI_PUD_UP); // Sets a pull-up.
-
-gpioSetPullUpDown(18, PI_PUD_DOWN); // Sets a pull-down.
-
-gpioSetPullUpDown(23, PI_PUD_OFF); // Clear any pull-ups/downs.
-...
-D*/
-
-
-/*F*/
-int gpioRead (unsigned gpio);
-/*D
-Reads the GPIO level, on or off.
-
-. .
-gpio: 0-53
-. .
-
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-
-Arduino style: digitalRead.
-
-...
-printf("GPIO24 is level %d", gpioRead(24));
-...
-D*/
-
-
-/*F*/
-int gpioWrite(unsigned gpio, unsigned level);
-/*D
-Sets the GPIO level, on or off.
-
-. .
- gpio: 0-53
-level: 0-1
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO or PI_BAD_LEVEL.
-
-If PWM or servo pulses are active on the GPIO they are switched off.
-
-Arduino style: digitalWrite
-
-...
-gpioWrite(24, 1); // Set GPIO24 high.
-...
-D*/
-
-
-/*F*/
-int gpioPWM(unsigned user_gpio, unsigned dutycycle);
-/*D
-Starts PWM on the GPIO, dutycycle between 0 (off) and range (fully on).
-Range defaults to 255.
-
-. .
-user_gpio: 0-31
-dutycycle: 0-range
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYCYCLE.
-
-Arduino style: analogWrite
-
-This and the servo functionality use the DMA and PWM or PCM peripherals
-to control and schedule the pulse lengths and dutycycles.
-
-The [*gpioSetPWMrange*] function may be used to change the default
-range of 255.
-
-...
-gpioPWM(17, 255); // Sets GPIO17 full on.
-
-gpioPWM(18, 128); // Sets GPIO18 half on.
-
-gpioPWM(23, 0); // Sets GPIO23 full off.
-...
-D*/
-
-
-/*F*/
-int gpioGetPWMdutycycle(unsigned user_gpio);
-/*D
-Returns the PWM dutycycle setting for the GPIO.
-
-. .
-user_gpio: 0-31
-. .
-
-Returns between 0 (off) and range (fully on) if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see [*gpioGetPWMrange*]).
-
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-
-Normal PWM range defaults to 255.
-D*/
-
-
-/*F*/
-int gpioSetPWMrange(unsigned user_gpio, unsigned range);
-/*D
-Selects the dutycycle range to be used for the GPIO. Subsequent calls
-to gpioPWM will use a dutycycle between 0 (off) and range (fully on).
-
-. .
-user_gpio: 0-31
- range: 25-40000
-. .
-
-Returns the real range for the given GPIO's frequency if OK,
-otherwise PI_BAD_USER_GPIO or PI_BAD_DUTYRANGE.
-
-If PWM is currently active on the GPIO its dutycycle will be scaled
-to reflect the new range.
-
-The real range, the number of steps between fully off and fully
-on for each frequency, is given in the following table.
-
-. .
- 25, 50, 100, 125, 200, 250, 400, 500, 625,
- 800, 1000, 1250, 2000, 2500, 4000, 5000, 10000, 20000
-. .
-
-The real value set by [*gpioPWM*] is (dutycycle * real range) / range.
-
-...
-gpioSetPWMrange(24, 2000); // Now 2000 is fully on
- // 1000 is half on
- // 500 is quarter on, etc.
-...
-D*/
-
-
-/*F*/
-int gpioGetPWMrange(unsigned user_gpio);
-/*D
-Returns the dutycycle range used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-. .
-user_gpio: 0-31
-. .
-
-If a hardware clock or hardware PWM is active on the GPIO
-the reported range will be 1000000 (1M).
-
-...
-r = gpioGetPWMrange(23);
-...
-D*/
-
-
-/*F*/
-int gpioGetPWMrealRange(unsigned user_gpio);
-/*D
-Returns the real range used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-. .
-user_gpio: 0-31
-. .
-
-If a hardware clock is active on the GPIO the reported real
-range will be 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-...
-rr = gpioGetPWMrealRange(17);
-...
-D*/
-
-
-/*F*/
-int gpioSetPWMfrequency(unsigned user_gpio, unsigned frequency);
-/*D
-Sets the frequency in hertz to be used for the GPIO.
-
-. .
-user_gpio: 0-31
-frequency: >=0
-. .
-
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO.
-
-If PWM is currently active on the GPIO it will be
-switched off and then back on at the new frequency.
-
-Each GPIO can be independently set to one of 18 different PWM
-frequencies.
-
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5).
-
-The frequencies for each sample rate are:
-
-. .
- Hertz
-
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
- 1250 1000 800 500 400 250 200 100 50
-
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
- 625 500 400 250 200 125 100 50 25
-
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
- 313 250 200 125 100 63 50 25 13
-sample
- rate
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
- 250 200 160 100 80 50 40 20 10
-
- 8: 5000 2500 1250 1000 625 500 313 250 200
- 156 125 100 63 50 31 25 13 6
-
- 10: 4000 2000 1000 800 500 400 250 200 160
- 125 100 80 50 40 25 20 10 5
-. .
-
-...
-gpioSetPWMfrequency(23, 0); // Set GPIO23 to lowest frequency.
-
-gpioSetPWMfrequency(24, 500); // Set GPIO24 to 500Hz.
-
-gpioSetPWMfrequency(25, 100000); // Set GPIO25 to highest frequency.
-...
-D*/
-
-
-/*F*/
-int gpioGetPWMfrequency(unsigned user_gpio);
-/*D
-Returns the frequency (in hertz) used for the GPIO if OK, otherwise
-PI_BAD_USER_GPIO.
-
-. .
-user_gpio: 0-31
-. .
-
-For normal PWM the frequency will be that defined for the GPIO by
-[*gpioSetPWMfrequency*].
-
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by [*gpioHardwareClock*].
-
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by [*gpioHardwarePWM*].
-
-...
-f = gpioGetPWMfrequency(23); // Get frequency used for GPIO23.
-...
-D*/
-
-
-/*F*/
-int gpioServo(unsigned user_gpio, unsigned pulsewidth);
-/*D
-Starts servo pulses on the GPIO, 0 (off), 500 (most anti-clockwise) to
-2500 (most clockwise).
-
-. .
- user_gpio: 0-31
-pulsewidth: 0, 500-2500
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_PULSEWIDTH.
-
-The range supported by servos varies and should probably be determined
-by experiment. A value of 1500 should always be safe and represents
-the mid-point of rotation. You can DAMAGE a servo if you command it
-to move beyond its limits.
-
-The following causes an on pulse of 1500 microseconds duration to be
-transmitted on GPIO 17 at a rate of 50 times per second. This will
-command a servo connected to GPIO 17 to rotate to its mid-point.
-
-...
-gpioServo(17, 1000); // Move servo to safe position anti-clockwise.
-
-gpioServo(23, 1500); // Move servo to centre position.
-
-gpioServo(25, 2000); // Move servo to safe position clockwise.
-...
-
-OTHER UPDATE RATES:
-
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-. .
-PWM Hz 50 100 200 400 500
-1E6/Hz 20000 10000 5000 2500 2000
-. .
-
-Firstly set the desired PWM frequency using [*gpioSetPWMfrequency*].
-
-Then set the PWM range using [*gpioSetPWMrange*] to 1E6/frequency.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-E.g. If you want to update a servo connected to GPIO25 at 400Hz
-
-. .
-gpioSetPWMfrequency(25, 400);
-
-gpioSetPWMrange(25, 2500);
-. .
-
-Thereafter use the PWM command to move the servo,
-e.g. gpioPWM(25, 1500) will set a 1500 us pulse.
-D*/
-
-
-/*F*/
-int gpioGetServoPulsewidth(unsigned user_gpio);
-/*D
-Returns the servo pulsewidth setting for the GPIO.
-
-. .
-user_gpio: 0-31
-. .
-
-Returns 0 (off), 500 (most anti-clockwise) to 2500 (most clockwise)
-if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-D*/
-
-
-/*F*/
-int gpioSetAlertFunc(unsigned user_gpio, gpioAlertFunc_t f);
-/*D
-Registers a function to be called (a callback) when the specified
-GPIO changes state.
-
-. .
-user_gpio: 0-31
- f: the callback function
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-
-One function may be registered per GPIO.
-
-The function is passed the GPIO, the new level, and the tick.
-
-The alert may be cancelled by passing NULL as the function.
-
-The GPIO are sampled at a rate set when the library is started.
-
-If a value isn't specifically set the default of 5 us is used.
-
-The number of samples per second is given in the following table.
-
-. .
- samples
- per sec
-
- 1 1,000,000
- 2 500,000
-sample 4 250,000
-rate 5 200,000
-(us) 8 125,000
- 10 100,000
-. .
-
-Level changes shorter than the sample rate may be missed.
-
-The thread which calls the alert functions is triggered nominally
-1000 times per second. The active alert functions will be called
-once per level change since the last time the thread was activated.
-i.e. The active alert functions will get all level changes but there
-will be a latency.
-
-The tick value is the time stamp of the sample in microseconds, see
-[*gpioTick*] for more details.
-
-...
-void aFunction(int gpio, int level, uint32_t tick)
-{
- printf("GPIO %d became %d at %d", gpio, level, tick);
-}
-
-// call aFunction whenever GPIO 4 changes state
-
-gpioSetAlertFunc(4, aFunction);
-...
-D*/
-
-
-/*F*/
-int gpioSetAlertFuncEx(
- unsigned user_gpio, gpioAlertFuncEx_t f, void *userdata);
-/*D
-Registers a function to be called (a callback) when the specified
-GPIO changes state.
-
-. .
-user_gpio: 0-31
- f: the callback function
- userdata: pointer to arbitrary user data
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO.
-
-One function may be registered per GPIO.
-
-The function is passed the GPIO, the new level, the tick, and
-the userdata pointer.
-
-Only one of [*gpioSetAlertFunc*] or [*gpioSetAlertFuncEx*] can be
-registered per GPIO.
-
-See [*gpioSetAlertFunc*] for further details.
-D*/
-
-
-/*F*/
-int gpioSetISRFunc(
- unsigned user_gpio, unsigned edge, int timeout, gpioISRFunc_t f);
-/*D
-Registers a function to be called (a callback) whenever the specified
-GPIO interrupt occurs.
-
-. .
-user_gpio: 0-31
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE
- timeout: interrupt timeout in milliseconds (<=0 to cancel)
- f: the callback function
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
-or PI_BAD_ISR_INIT.
-
-One function may be registered per GPIO.
-
-The function is passed the GPIO, the current level, and the
-current tick. The level will be PI_TIMEOUT if the optional
-interrupt timeout expires.
-
-The underlying Linux sysfs GPIO interface is used to provide
-the interrupt services.
-
-The first time the function is called, with a non-NULL f, the
-GPIO is exported, set to be an input, and set to interrupt
-on the given edge and timeout.
-
-Subsequent calls, with a non-NULL f, can vary one or more of the
-edge, timeout, or function.
-
-The ISR may be cancelled by passing a NULL f, in which case the
-GPIO is unexported.
-
-The tick is that read at the time the process was informed of
-the interrupt. This will be a variable number of microseconds
-after the interrupt occurred. Typically the latency will be of
-the order of 50 microseconds. The latency is not guaranteed
-and will vary with system load.
-
-The level is that read at the time the process was informed of
-the interrupt, or PI_TIMEOUT if the optional interrupt timeout
-expired. It may not be the same as the expected edge as
-interrupts happening in rapid succession may be missed by the
-kernel (i.e. this mechanism can not be used to capture several
-interrupts only a few microseconds apart).
-D*/
-
-
-/*F*/
-int gpioSetISRFuncEx(
- unsigned user_gpio,
- unsigned edge,
- int timeout,
- gpioISRFuncEx_t f,
- void *userdata);
-/*D
-Registers a function to be called (a callback) whenever the specified
-GPIO interrupt occurs.
-
-. .
-user_gpio: 0-31
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE
- timeout: interrupt timeout in milliseconds (<=0 to cancel)
- f: the callback function
- userdata: pointer to arbitrary user data
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_EDGE,
-or PI_BAD_ISR_INIT.
-
-The function is passed the GPIO, the current level, the
-current tick, and the userdata pointer.
-
-Only one of [*gpioSetISRFunc*] or [*gpioSetISRFuncEx*] can be
-registered per GPIO.
-
-See [*gpioSetISRFunc*] for further details.
-D*/
-
-
-/*F*/
-int gpioNotifyOpen(void);
-/*D
-This function requests a free notification handle.
-
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-A notification is a method for being notified of GPIO state changes
-via a pipe or socket.
-
-Pipe notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number). E.g. if the
-function returns 15 then the notifications must be read
-from /dev/pigpio15.
-
-Socket notifications are returned to the socket which requested the
-handle.
-
-...
-h = gpioNotifyOpen();
-
-if (h >= 0)
-{
- sprintf(str, "/dev/pigpio%d", h);
-
- fd = open(str, O_RDONLY);
-
- if (fd >= 0)
- {
- // Okay.
- }
- else
- {
- // Error.
- }
-}
-else
-{
- // Error.
-}
-...
-D*/
-
-
-/*F*/
-int gpioNotifyOpenWithSize(int bufSize);
-/*D
-This function requests a free notification handle.
-
-It differs from [*gpioNotifyOpen*] in that the pipe size may be
-specified, whereas [*gpioNotifyOpen*] uses the default pipe size.
-
-See [*gpioNotifyOpen*] for further details.
-D*/
-
-
-/*F*/
-int gpioNotifyBegin(unsigned handle, uint32_t bits);
-/*D
-This function starts notifications on a previously opened handle.
-
-. .
-handle: >=0, as returned by [*gpioNotifyOpen*]
- bits: a bit mask indicating the GPIO of interest
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-The notification sends state changes for each GPIO whose corresponding
-bit in bits is set.
-
-Each notification occupies 12 bytes in the fifo and has the
-following structure.
-
-. .
-typedef struct
-{
- uint16_t seqno;
- uint16_t flags;
- uint32_t tick;
- uint32_t level;
-} gpioReport_t;
-. .
-
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-level: indicates the level of each GPIO. If bit 1<=0, as returned by [*gpioNotifyOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-Notifications for the handle are suspended until [*gpioNotifyBegin*]
-is called again.
-
-...
-gpioNotifyPause(h);
-...
-D*/
-
-
-/*F*/
-int gpioNotifyClose(unsigned handle);
-/*D
-This function stops notifications on a previously opened handle
-and releases the handle for reuse.
-
-. .
-handle: >=0, as returned by [*gpioNotifyOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-...
-gpioNotifyClose(h);
-...
-D*/
-
-
-/*F*/
-int gpioWaveClear(void);
-/*D
-This function clears all waveforms and any data added by calls to the
-[*gpioWaveAdd**] functions.
-
-Returns 0 if OK.
-
-...
-gpioWaveClear();
-...
-D*/
-
-
-/*F*/
-int gpioWaveAddNew(void);
-/*D
-This function starts a new empty waveform.
-
-You wouldn't normally need to call this function as it is automatically
-called after a waveform is created with the [*gpioWaveCreate*] function.
-
-Returns 0 if OK.
-
-...
-gpioWaveAddNew();
-...
-D*/
-
-
-/*F*/
-int gpioWaveAddGeneric(unsigned numPulses, gpioPulse_t *pulses);
-/*D
-This function adds a number of pulses to the current waveform.
-
-. .
-numPulses: the number of pulses
- pulses: an array of pulses
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist of a delay.
-
-...
-// Construct and send a 30 microsecond square wave.
-
-gpioSetMode(gpio, PI_OUTPUT);
-
-pulse[0].gpioOn = (1<= 0)
-{
- gpioWaveTxSend(wave_id, PI_WAVE_MODE_REPEAT);
-
- // Transmit for 30 seconds.
-
- sleep(30);
-
- gpioWaveTxStop();
-}
-else
-{
- // Wave create failed.
-}
-...
-D*/
-
-
-/*F*/
-int gpioWaveAddSerial
- (unsigned user_gpio,
- unsigned baud,
- unsigned data_bits,
- unsigned stop_bits,
- unsigned offset,
- unsigned numBytes,
- char *str);
-/*D
-This function adds a waveform representing serial data to the
-existing waveform (if any). The serial data starts offset
-microseconds from the start of the waveform.
-
-. .
-user_gpio: 0-31
- baud: 50-1000000
-data_bits: 1-32
-stop_bits: 2-8
- offset: >=0
- numBytes: >=1
- str: an array of chars (which may contain nulls)
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOPBITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-NOTES:
-
-The serial data is formatted as one start bit, data_bits data bits, and
-stop_bits/2 stop bits.
-
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-numBytes is the number of bytes of data in str.
-
-The bytes required for each character depend upon data_bits.
-
-For data_bits 1-8 there will be one byte per character.
-For data_bits 9-16 there will be two bytes per character.
-For data_bits 17-32 there will be four bytes per character.
-
-...
-#define MSG_LEN 8
-
-int i;
-char *str;
-char data[MSG_LEN];
-
-str = "Hello world!";
-
-gpioWaveAddSerial(4, 9600, 8, 2, 0, strlen(str), str);
-
-for (i=0; i=0, as returned by [*gpioWaveCreate*]
-. .
-
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-D*/
-
-
-/*F*/
-int gpioWaveTxSend(unsigned wave_id, unsigned wave_mode);
-/*D
-This function transmits the waveform with id wave_id. The mode
-determines whether the waveform is sent once or cycles endlessly.
-The SYNC variants wait for the current waveform to reach the
-end of a cycle or finish before starting the new waveform.
-
-WARNING: bad things may happen if you delete the previous
-waveform before it has been synced to the new waveform.
-
-NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled.
-
-. .
- wave_id: >=0, as returned by [*gpioWaveCreate*]
-wave_mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
- PI_WAVE_MODE_ONE_SHOT_SYNC, PI_WAVE_MODE_REPEAT_SYNC
-. .
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-
-/*F*/
-int gpioWaveChain(char *buf, unsigned bufSize);
-/*D
-This function transmits a chain of waveforms.
-
-NOTE: Any hardware PWM started by [*gpioHardwarePWM*] will be cancelled.
-
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of [*wave_id*]s and optional command
-codes and related data.
-
-. .
- buf: pointer to the wave_ids and optional command codes
-bufSize: the number of bytes in buf
-. .
-
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-Delays between waves may be added with the delay command.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-Loop Start @ 255 0 @ Identify start of a wave block
-Loop Repeat @ 255 1 x y @ loop x + y*256 times
-Delay @ 255 2 x y @ delay x + y*256 microseconds
-Loop Forever @ 255 3 @ loop forever
-
-If present Loop Forever must be the last entry in the chain.
-
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-...
-#include
-#include
-
-#define WAVES 5
-#define GPIO 4
-
-int main(int argc, char *argv[])
-{
- int i, wid[WAVES];
-
- if (gpioInitialise()<0) return -1;
-
- gpioSetMode(GPIO, PI_OUTPUT);
-
- printf("start piscope, press return"); getchar();
-
- for (i=0; i=0
-. .
-
-Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
-or PI_NOT_SERIAL_GPIO.
-
-The bytes returned for each character depend upon the number of
-data bits [*data_bits*] specified in the [*gpioSerialReadOpen*] command.
-
-For [*data_bits*] 1-8 there will be one byte per character.
-For [*data_bits*] 9-16 there will be two bytes per character.
-For [*data_bits*] 17-32 there will be four bytes per character.
-D*/
-
-
-/*F*/
-int gpioSerialReadClose(unsigned user_gpio);
-/*D
-This function closes a GPIO for bit bang reading of serial data.
-
-. .
-user_gpio: 0-31, previously opened with [*gpioSerialReadOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
-D*/
-
-/*F*/
-int i2cOpen(unsigned i2cBus, unsigned i2cAddr, unsigned i2cFlags);
-/*D
-This returns a handle for the device at the address on the I2C bus.
-
-. .
- i2cBus: >=0
- i2cAddr: 0-0x7F
-i2cFlags: 0
-. .
-
-No flags are currently defined. This parameter should be set to zero.
-
-Physically buses 0 and 1 are available on the Pi. Higher numbered buses
-will be available if a kernel supported bus multiplexor is being used.
-
-Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
-PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
-
-For the SMBus commands the low level transactions are shown at the end
-of the function description. The following abbreviations are used.
-
-. .
-S (1 bit) : Start bit
-P (1 bit) : Stop bit
-Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
-A, NA (1 bit) : Accept and not accept bit.
-Addr (7 bits): I2C 7 bit address.
-i2cReg (8 bits): Command byte, a byte which often selects a register.
-Data (8 bits): A data byte.
-Count (8 bits): A byte defining the length of a block operation.
-
-[..]: Data sent by the device.
-. .
-D*/
-
-
-/*F*/
-int i2cClose(unsigned handle);
-/*D
-This closes the I2C device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-
-/*F*/
-int i2cWriteQuick(unsigned handle, unsigned bit);
-/*D
-This sends a single bit (in the Rd/Wr bit) to the device associated
-with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- bit: 0-1, the value to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Quick command. SMBus 2.0 5.5.1
-. .
-S Addr bit [A] P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteByte(unsigned handle, unsigned bVal);
-/*D
-This sends a single byte to the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- bVal: 0-0xFF, the value to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Send byte. SMBus 2.0 5.5.2
-. .
-S Addr Wr [A] bVal [A] P
-. .
-D*/
-
-
-/*F*/
-int i2cReadByte(unsigned handle);
-/*D
-This reads a single byte from the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-. .
-
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-or PI_I2C_READ_FAILED.
-
-Receive byte. SMBus 2.0 5.5.3
-. .
-S Addr Rd [A] [Data] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteByteData(unsigned handle, unsigned i2cReg, unsigned bVal);
-/*D
-This writes a single byte to the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write
- bVal: 0-0xFF, the value to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Write byte. SMBus 2.0 5.5.4
-. .
-S Addr Wr [A] i2cReg [A] bVal [A] P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteWordData(unsigned handle, unsigned i2cReg, unsigned wVal);
-/*D
-This writes a single 16 bit word to the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write
- wVal: 0-0xFFFF, the value to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Write word. SMBus 2.0 5.5.4
-. .
-S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A] P
-. .
-D*/
-
-
-/*F*/
-int i2cReadByteData(unsigned handle, unsigned i2cReg);
-/*D
-This reads a single byte from the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to read
-. .
-
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Read byte. SMBus 2.0 5.5.5
-. .
-S Addr Wr [A] i2cReg [A] S Addr Rd [A] [Data] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cReadWordData(unsigned handle, unsigned i2cReg);
-/*D
-This reads a single 16 bit word from the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to read
-. .
-
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Read word. SMBus 2.0 5.5.5
-. .
-S Addr Wr [A] i2cReg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cProcessCall(unsigned handle, unsigned i2cReg, unsigned wVal);
-/*D
-This writes 16 bits of data to the specified register of the device
-associated with handle and reads 16 bits of data in return.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write/read
- wVal: 0-0xFFFF, the value to write
-. .
-
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Process call. SMBus 2.0 5.5.6
-. .
-S Addr Wr [A] i2cReg [A] wValLow [A] wValHigh [A]
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteBlockData(
-unsigned handle, unsigned i2cReg, char *buf, unsigned count);
-/*D
-This writes up to 32 bytes to the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write
- buf: an array with the data to send
- count: 1-32, the number of bytes to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Block write. SMBus 2.0 5.5.7
-. .
-S Addr Wr [A] i2cReg [A] count [A]
- buf0 [A] buf1 [A] ... [A] bufn [A] P
-. .
-D*/
-
-
-/*F*/
-int i2cReadBlockData(unsigned handle, unsigned i2cReg, char *buf);
-/*D
-This reads a block of up to 32 bytes from the specified register of
-the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to read
- buf: an array to receive the read data
-. .
-
-The amount of returned data is set by the device.
-
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Block read. SMBus 2.0 5.5.7
-. .
-S Addr Wr [A] i2cReg [A]
- S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cBlockProcessCall(
-unsigned handle, unsigned i2cReg, char *buf, unsigned count);
-/*D
-This writes data bytes to the specified register of the device
-associated with handle and reads a device specified number
-of bytes of data in return.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write/read
- buf: an array with the data to send and to receive the read data
- count: 1-32, the number of bytes to write
-. .
-
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-The SMBus 2.0 documentation states that a minimum of 1 byte may be
-sent and a minimum of 1 byte may be received. The total number of
-bytes sent/received must be 32 or less.
-
-Block write-block read. SMBus 2.0 5.5.8
-. .
-S Addr Wr [A] i2cReg [A] count [A] buf0 [A] ... bufn [A]
- S Addr Rd [A] [Count] A [buf0] A ... [bufn] A P
-. .
-D*/
-
-
-/*F*/
-int i2cReadI2CBlockData(
-unsigned handle, unsigned i2cReg, char *buf, unsigned count);
-/*D
-This reads count bytes from the specified register of the device
-associated with handle . The count may be 1-32.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to read
- buf: an array to receive the read data
- count: 1-32, the number of bytes to read
-. .
-
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-. .
-S Addr Wr [A] i2cReg [A]
- S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteI2CBlockData(
-unsigned handle, unsigned i2cReg, char *buf, unsigned count);
-/*D
-This writes 1 to 32 bytes to the specified register of the device
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
-i2cReg: 0-255, the register to write
- buf: the data to write
- count: 1-32, the number of bytes to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-. .
-S Addr Wr [A] i2cReg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-. .
-D*/
-
-/*F*/
-int i2cReadDevice(unsigned handle, char *buf, unsigned count);
-/*D
-This reads count bytes from the raw device into buf.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- buf: an array to receive the read data bytes
- count: >0, the number of bytes to read
-. .
-
-Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_READ_FAILED.
-
-. .
-S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-. .
-D*/
-
-
-/*F*/
-int i2cWriteDevice(unsigned handle, char *buf, unsigned count);
-/*D
-This writes count bytes from buf to the raw device.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- buf: an array containing the data bytes to write
- count: >0, the number of bytes to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-. .
-S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-. .
-D*/
-
-/*F*/
-void i2cSwitchCombined(int setting);
-/*D
-This sets the I2C (i2c-bcm2708) module "use combined transactions"
-parameter on or off.
-
-. .
-setting: 0 to set the parameter off, non-zero to set it on
-. .
-
-
-NOTE: when the flag is on a write followed by a read to the same
-slave address will use a repeated start (rather than a stop/start).
-D*/
-
-/*F*/
-int i2cSegments(unsigned handle, pi_i2c_msg_t *segs, unsigned numSegs);
-/*D
-This function executes multiple I2C segments in one transaction by
-calling the I2C_RDWR ioctl.
-
-. .
- handle: >=0, as returned by a call to [*i2cOpen*]
- segs: an array of I2C segments
-numSegs: >0, the number of I2C segments
-. .
-
-Returns the number of segments if OK, otherwise PI_BAD_I2C_SEG.
-D*/
-
-/*F*/
-int i2cZip(
- unsigned handle,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen);
-/*D
-This function executes a sequence of I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- inBuf: pointer to the concatenated I2C commands, see below
- inLen: size of command buffer
-outBuf: pointer to buffer to hold returned data
-outLen: size of output buffer
-. .
-
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN.
-PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-End @ 0 @ No more commands
-Escape @ 1 @ Next P is two bytes
-On @ 2 @ Switch combined flag on
-Off @ 3 @ Switch combined flag off
-Address @ 4 P @ Set I2C address to P
-Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
-Read @ 6 P @ Read P bytes of data
-Write @ 7 P ... @ Write P bytes of data
-
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-The address defaults to that associated with the handle.
-The flags default to 0. The address and flags maintain their
-previous value until updated.
-
-The returned I2C data is stored in consecutive locations of outBuf.
-
-...
-Set address 0x53, write 0x32, read 6 bytes
-Set address 0x1E, write 0x03, read 6 bytes
-Set address 0x68, write 0x1B, read 8 bytes
-End
-
-0x04 0x53 0x07 0x01 0x32 0x06 0x06
-0x04 0x1E 0x07 0x01 0x03 0x06 0x06
-0x04 0x68 0x07 0x01 0x1B 0x06 0x08
-0x00
-...
-D*/
-
-/*F*/
-int bbI2COpen(unsigned SDA, unsigned SCL, unsigned baud);
-/*D
-This function selects a pair of GPIO for bit banging I2C at a
-specified baud rate.
-
-Bit banging I2C allows for certain operations which are not possible
-with the standard I2C driver.
-
-o baud rates as low as 50
-o repeated starts
-o clock stretching
-o I2C on any pair of spare GPIO
-
-. .
- SDA: 0-31
- SCL: 0-31
-baud: 50-500000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
-PI_GPIO_IN_USE.
-
-NOTE:
-
-The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
-a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-D*/
-
-/*F*/
-int bbI2CClose(unsigned SDA);
-/*D
-This function stops bit banging I2C on a pair of GPIO previously
-opened with [*bbI2COpen*].
-
-. .
-SDA: 0-31, the SDA GPIO used in a prior call to [*bbI2COpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-D*/
-
-/*F*/
-int bbI2CZip(
- unsigned SDA,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen);
-/*D
-This function executes a sequence of bit banged I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-. .
- SDA: 0-31 (as used in a prior call to [*bbI2COpen*])
- inBuf: pointer to the concatenated I2C commands, see below
- inLen: size of command buffer
-outBuf: pointer to buffer to hold returned data
-outLen: size of output buffer
-. .
-
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER,
-PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN,
-PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-End @ 0 @ No more commands
-Escape @ 1 @ Next P is two bytes
-Start @ 2 @ Start condition
-Stop @ 3 @ Stop condition
-Address @ 4 P @ Set I2C address to P
-Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
-Read @ 6 P @ Read P bytes of data
-Write @ 7 P ... @ Write P bytes of data
-
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-The address and flags default to 0. The address and flags maintain
-their previous value until updated.
-
-No flags are currently defined.
-
-The returned I2C data is stored in consecutive locations of outBuf.
-
-...
-Set address 0x53
-start, write 0x32, (re)start, read 6 bytes, stop
-Set address 0x1E
-start, write 0x03, (re)start, read 6 bytes, stop
-Set address 0x68
-start, write 0x1B, (re)start, read 8 bytes, stop
-End
-
-0x04 0x53
-0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-
-0x04 0x1E
-0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-
-0x04 0x68
-0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-
-0x00
-...
-D*/
-
-/*F*/
-int bbSPIOpen(
- unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK,
- unsigned baud, unsigned spiFlags);
-/*D
-This function selects a set of GPIO for bit banging SPI with
-a specified baud rate and mode.
-
-. .
- CS: 0-31
- MISO: 0-31
- MOSI: 0-31
- SCLK: 0-31
- baud: 50-250000
-spiFlags: see below
-. .
-
-spiFlags consists of the least significant 22 bits.
-
-. .
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
-. .
-
-mm defines the SPI mode, defaults to 0
-
-. .
-Mode CPOL CPHA
- 0 0 0
- 1 0 1
- 2 1 0
- 3 1 1
-. .
-
-p is 0 if CS is active low (default) and 1 for active high.
-
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first.
-
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first.
-
-The other bits in flags should be set to zero.
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or
-PI_GPIO_IN_USE.
-
-If more than one device is connected to the SPI bus (defined by
-SCLK, MOSI, and MISO) each must have its own CS.
-
-...
-bbSPIOpen(10, MISO, MOSI, SCLK, 10000, 0); // device 1
-bbSPIOpen(11, MISO, MOSI, SCLK, 20000, 3); // device 2
-...
-D*/
-
-/*F*/
-int bbSPIClose(unsigned CS);
-/*D
-This function stops bit banging SPI on a set of GPIO
-opened with [*bbSPIOpen*].
-
-. .
-CS: 0-31, the CS GPIO used in a prior call to [*bbSPIOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO.
-D*/
-
-/*F*/
-int bbSPIXfer(
- unsigned CS,
- char *inBuf,
- char *outBuf,
- unsigned count);
-/*D
-This function executes a bit banged SPI transfer.
-
-. .
- CS: 0-31 (as used in a prior call to [*bbSPIOpen*])
- inBuf: pointer to buffer to hold data to be sent
-outBuf: pointer to buffer to hold returned data
- count: size of data transfer
-. .
-
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER.
-
-...
-// gcc -Wall -pthread -o bbSPIx_test bbSPIx_test.c -lpigpio
-// sudo ./bbSPIx_test
-
-
-#include
-
-#include "pigpio.h"
-
-#define CE0 5
-#define CE1 6
-#define MISO 13
-#define MOSI 19
-#define SCLK 12
-
-int main(int argc, char *argv[])
-{
- int i, count, set_val, read_val;
- unsigned char inBuf[3];
- char cmd1[] = {0, 0};
- char cmd2[] = {12, 0};
- char cmd3[] = {1, 128, 0};
-
- if (gpioInitialise() < 0)
- {
- fprintf(stderr, "pigpio initialisation failed.\n");
- return 1;
- }
-
- bbSPIOpen(CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC
- bbSPIOpen(CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC
-
- for (i=0; i<256; i++)
- {
- cmd1[1] = i;
-
- count = bbSPIXfer(CE0, cmd1, (char *)inBuf, 2); // > DAC
-
- if (count == 2)
- {
- count = bbSPIXfer(CE0, cmd2, (char *)inBuf, 2); // < DAC
-
- if (count == 2)
- {
- set_val = inBuf[1];
-
- count = bbSPIXfer(CE1, cmd3, (char *)inBuf, 3); // < ADC
-
- if (count == 3)
- {
- read_val = ((inBuf[1]&3)<<8) | inBuf[2];
- printf("%d %d\n", set_val, read_val);
- }
- }
- }
- }
-
- bbSPIClose(CE0);
- bbSPIClose(CE1);
-
- gpioTerminate();
-
- return 0;
-}
-...
-D*/
-
-/*F*/
-int spiOpen(unsigned spiChan, unsigned baud, unsigned spiFlags);
-/*D
-This function returns a handle for the SPI device on the channel.
-Data will be transferred at baud bits per second. The flags may
-be used to modify the default behaviour of 4-wire operation, mode 0,
-active low chip select.
-
-An auxiliary SPI device is available on all models but the
-A and B and may be selected by setting the A bit in the flags.
-The auxiliary device has 3 chip selects and a selectable word
-size in bits.
-
-. .
- spiChan: 0-1 (0-2 for the auxiliary SPI device)
- baud: 32K-125M (values above 30M are unlikely to work)
-spiFlags: see below
-. .
-
-Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
-PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
-
-spiFlags consists of the least significant 22 bits.
-
-. .
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
-. .
-
-mm defines the SPI mode.
-
-Warning: modes 1 and 3 do not appear to work on the auxiliary device.
-
-. .
-Mode POL PHA
- 0 0 0
- 1 0 1
- 2 1 0
- 3 1 1
-. .
-
-px is 0 if CEx is active low (default) and 1 for active high.
-
-ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-
-A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
-W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
-SPI device only.
-
-nnnn defines the number of bytes (0-15) to write before switching
-the MOSI line to MISO to read data. This field is ignored
-if W is not set. Standard SPI device only.
-
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first. Auxiliary SPI
-device only.
-
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first. Auxiliary SPI
-device only.
-
-bbbbbb defines the word size in bits (0-32). The default (0)
-sets 8 bits per word. Auxiliary SPI device only.
-
-The [*spiRead*], [*spiWrite*], and [*spiXfer*] functions
-transfer data packed into 1, 2, or 4 bytes according to
-the word size in bits.
-
-For bits 1-8 there will be one byte per character.
-For bits 9-16 there will be two bytes per character.
-For bits 17-32 there will be four bytes per character.
-
-E.g. to transfer 32 12-bit words buf should contain 64 bytes
-and count should be 64.
-
-The other bits in flags should be set to zero.
-D*/
-
-/*F*/
-int spiClose(unsigned handle);
-/*D
-This functions closes the SPI device identified by the handle.
-
-. .
-handle: >=0, as returned by a call to [*spiOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-
-/*F*/
-int spiRead(unsigned handle, char *buf, unsigned count);
-/*D
-This function reads count bytes of data from the SPI
-device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*spiOpen*]
- buf: an array to receive the read data bytes
- count: the number of bytes to read
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-
-/*F*/
-int spiWrite(unsigned handle, char *buf, unsigned count);
-/*D
-This function writes count bytes of data from buf to the SPI
-device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*spiOpen*]
- buf: the data bytes to write
- count: the number of bytes to write
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-/*F*/
-int spiXfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count);
-/*D
-This function transfers count bytes of data from txBuf to the SPI
-device associated with the handle. Simultaneously count bytes of
-data are read from the device and placed in rxBuf.
-
-. .
-handle: >=0, as returned by a call to [*spiOpen*]
- txBuf: the data bytes to write
- rxBuf: the received data bytes
- count: the number of bytes to transfer
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-
-/*F*/
-int serOpen(char *sertty, unsigned baud, unsigned serFlags);
-/*D
-This function opens a serial device at a specified baud rate
-and with specified flags. The device name must start with
-/dev/tty or /dev/serial.
-
-. .
- sertty: the serial device to open
- baud: the baud rate in bits per second, see below
-serFlags: 0
-. .
-
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
-PI_SER_OPEN_FAILED.
-
-The baud rate must be one of 50, 75, 110, 134, 150,
-200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
-38400, 57600, 115200, or 230400.
-
-No flags are currently defined. This parameter should be set to zero.
-D*/
-
-
-/*F*/
-int serClose(unsigned handle);
-/*D
-This function closes the serial device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int serWriteByte(unsigned handle, unsigned bVal);
-/*D
-This function writes bVal to the serial port associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-D*/
-
-/*F*/
-int serReadByte(unsigned handle);
-/*D
-This function reads a byte from the serial port associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
-. .
-
-Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
-D*/
-
-/*F*/
-int serWrite(unsigned handle, char *buf, unsigned count);
-/*D
-This function writes count bytes from buf to the the serial port
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
- buf: the array of bytes to write
- count: the number of bytes to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-D*/
-
-
-/*F*/
-int serRead(unsigned handle, char *buf, unsigned count);
-/*D
-This function reads up count bytes from the the serial port
-associated with handle and writes them to buf.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
- buf: an array to receive the read data
- count: the maximum number of bytes to read
-. .
-
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_SER_READ_NO_DATA.
-D*/
-
-
-/*F*/
-int serDataAvailable(unsigned handle);
-/*D
-This function returns the number of bytes available
-to be read from the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serOpen*]
-. .
-
-Returns the number of bytes of data available (>=0) if OK,
-otherwise PI_BAD_HANDLE.
-D*/
-
-
-/*F*/
-int gpioTrigger(unsigned user_gpio, unsigned pulseLen, unsigned level);
-/*D
-This function sends a trigger pulse to a GPIO. The GPIO is set to
-level for pulseLen microseconds and then reset to not level.
-
-. .
-user_gpio: 0-31
- pulseLen: 1-100
- level: 0,1
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL,
-or PI_BAD_PULSELEN.
-D*/
-
-
-/*F*/
-int gpioSetWatchdog(unsigned user_gpio, unsigned timeout);
-/*D
-Sets a watchdog for a GPIO.
-
-. .
-user_gpio: 0-31
- timeout: 0-60000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_BAD_WDOG_TIMEOUT.
-
-The watchdog is nominally in milliseconds.
-
-One watchdog may be registered per GPIO.
-
-The watchdog may be cancelled by setting timeout to 0.
-
-If no level change has been detected for the GPIO for timeout
-milliseconds:-
-
-1) any registered alert function for the GPIO is called with
- the level set to PI_TIMEOUT.
-2) any notification for the GPIO has a report written to the
- fifo with the flags set to indicate a watchdog timeout.
-
-...
-void aFunction(int gpio, int level, uint32_t tick)
-{
- printf("GPIO %d became %d at %d", gpio, level, tick);
-}
-
-// call aFunction whenever GPIO 4 changes state
-gpioSetAlertFunc(4, aFunction);
-
-// or approximately every 5 millis
-gpioSetWatchdog(4, 5);
-...
-D*/
-
-
-/*F*/
-int gpioNoiseFilter(unsigned user_gpio, unsigned steady, unsigned active);
-/*D
-Sets a noise filter on a GPIO.
-
-Level changes on the GPIO are ignored until a level which has
-been stable for [*steady*] microseconds is detected. Level changes
-on the GPIO are then reported for [*active*] microseconds after
-which the process repeats.
-
-. .
-user_gpio: 0-31
- steady: 0-300000
- active: 0-1000000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-Note, level changes before and after the active period may
-be reported. Your software must be designed to cope with
-such reports.
-D*/
-
-
-/*F*/
-int gpioGlitchFilter(unsigned user_gpio, unsigned steady);
-/*D
-Sets a glitch filter on a GPIO.
-
-Level changes on the GPIO are not reported unless the level
-has been stable for at least [*steady*] microseconds. The
-level is then reported. Level changes of less than [*steady*]
-microseconds are ignored.
-
-. .
-user_gpio: 0-31
- steady: 0-300000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-Note, each (stable) edge will be timestamped [*steady*] microseconds
-after it was first detected.
-D*/
-
-
-/*F*/
-int gpioSetGetSamplesFunc(gpioGetSamplesFunc_t f, uint32_t bits);
-/*D
-Registers a function to be called (a callback) every millisecond
-with the latest GPIO samples.
-
-. .
- f: the function to call
-bits: the GPIO of interest
-. .
-
-Returns 0 if OK.
-
-The function is passed a pointer to the samples (an array of
-[*gpioSample_t*]), and the number of samples.
-
-Only one function can be registered.
-
-The callback may be cancelled by passing NULL as the function.
-
-The samples returned will be the union of bits, plus any active alerts,
-plus any active notifications.
-
-e.g. if there are alerts for GPIO 7, 8, and 9, notifications for GPIO
-8, 10, 23, 24, and bits is (1<<23)|(1<<17) then samples for GPIO
-7, 8, 9, 10, 17, 23, and 24 will be reported.
-D*/
-
-
-/*F*/
-int gpioSetGetSamplesFuncEx(
- gpioGetSamplesFuncEx_t f, uint32_t bits, void *userdata);
-/*D
-Registers a function to be called (a callback) every millisecond
-with the latest GPIO samples.
-
-. .
- f: the function to call
- bits: the GPIO of interest
-userdata: a pointer to arbitrary user data
-. .
-
-Returns 0 if OK.
-
-The function is passed a pointer to the samples (an array of
-[*gpioSample_t*]), the number of samples, and the userdata pointer.
-
-Only one of [*gpioGetSamplesFunc*] or [*gpioGetSamplesFuncEx*] can be
-registered.
-
-See [*gpioSetGetSamplesFunc*] for further details.
-D*/
-
-
-/*F*/
-int gpioSetTimerFunc(unsigned timer, unsigned millis, gpioTimerFunc_t f);
-/*D
-Registers a function to be called (a callback) every millis milliseconds.
-
-. .
- timer: 0-9
-millis: 10-60000
- f: the function to call
-. .
-
-Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
-
-10 timers are supported numbered 0 to 9.
-
-One function may be registered per timer.
-
-The timer may be cancelled by passing NULL as the function.
-
-...
-void bFunction(void)
-{
- printf("two seconds have elapsed");
-}
-
-// call bFunction every 2000 milliseconds
-gpioSetTimerFunc(0, 2000, bFunction);
-...
-D*/
-
-
-/*F*/
-int gpioSetTimerFuncEx(
- unsigned timer, unsigned millis, gpioTimerFuncEx_t f, void *userdata);
-/*D
-Registers a function to be called (a callback) every millis milliseconds.
-
-. .
- timer: 0-9.
- millis: 10-60000
- f: the function to call
-userdata: a pointer to arbitrary user data
-. .
-
-Returns 0 if OK, otherwise PI_BAD_TIMER, PI_BAD_MS, or PI_TIMER_FAILED.
-
-The function is passed the userdata pointer.
-
-Only one of [*gpioSetTimerFunc*] or [*gpioSetTimerFuncEx*] can be
-registered per timer.
-
-See [*gpioSetTimerFunc*] for further details.
-D*/
-
-
-/*F*/
-pthread_t *gpioStartThread(gpioThreadFunc_t f, void *userdata);
-/*D
-Starts a new thread of execution with f as the main routine.
-
-. .
- f: the main function for the new thread
-userdata: a pointer to arbitrary user data
-. .
-
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-The function is passed the single argument arg.
-
-The thread can be cancelled by passing the pointer to pthread_t to
-[*gpioStopThread*].
-
-...
-#include
-#include
-
-void *myfunc(void *arg)
-{
- while (1)
- {
- printf("%s", arg);
- sleep(1);
- }
-}
-
-int main(int argc, char *argv[])
-{
- pthread_t *p1, *p2, *p3;
-
- if (gpioInitialise() < 0) return 1;
-
- p1 = gpioStartThread(myfunc, "thread 1"); sleep(3);
-
- p2 = gpioStartThread(myfunc, "thread 2"); sleep(3);
-
- p3 = gpioStartThread(myfunc, "thread 3"); sleep(3);
-
- gpioStopThread(p3); sleep(3);
-
- gpioStopThread(p2); sleep(3);
-
- gpioStopThread(p1); sleep(3);
-
- gpioTerminate();
-}
-...
-D*/
-
-
-/*F*/
-void gpioStopThread(pthread_t *pth);
-/*D
-Cancels the thread pointed at by pth.
-
-. .
-pth: a thread pointer returned by [*gpioStartThread*]
-. .
-
-No value is returned.
-
-The thread to be stopped should have been started with [*gpioStartThread*].
-D*/
-
-
-/*F*/
-int gpioStoreScript(char *script);
-/*D
-This function stores a null terminated script for later execution.
-
-See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for details.
-
-. .
-script: the text of the script
-. .
-
-The function returns a script id if the script is valid,
-otherwise PI_BAD_SCRIPT.
-D*/
-
-
-/*F*/
-int gpioRunScript(unsigned script_id, unsigned numPar, uint32_t *param);
-/*D
-This function runs a stored script.
-
-. .
-script_id: >=0, as returned by [*gpioStoreScript*]
- numPar: 0-10, the number of parameters
- param: an array of parameters
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
-PI_TOO_MANY_PARAM.
-
-param is an array of up to 10 parameters which may be referenced in
-the script as p0 to p9.
-D*/
-
-
-/*F*/
-int gpioScriptStatus(unsigned script_id, uint32_t *param);
-/*D
-This function returns the run status of a stored script as well as
-the current values of parameters 0 to 9.
-
-. .
-script_id: >=0, as returned by [*gpioStoreScript*]
- param: an array to hold the returned 10 parameters
-. .
-
-The function returns greater than or equal to 0 if OK,
-otherwise PI_BAD_SCRIPT_ID.
-
-The run status may be
-
-. .
-PI_SCRIPT_INITING
-PI_SCRIPT_HALTED
-PI_SCRIPT_RUNNING
-PI_SCRIPT_WAITING
-PI_SCRIPT_FAILED
-. .
-
-The current value of script parameters 0 to 9 are returned in param.
-D*/
-
-
-/*F*/
-int gpioStopScript(unsigned script_id);
-/*D
-This function stops a running script.
-
-. .
-script_id: >=0, as returned by [*gpioStoreScript*]
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-D*/
-
-
-/*F*/
-int gpioDeleteScript(unsigned script_id);
-/*D
-This function deletes a stored script.
-
-. .
-script_id: >=0, as returned by [*gpioStoreScript*]
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-D*/
-
-
-/*F*/
-int gpioSetSignalFunc(unsigned signum, gpioSignalFunc_t f);
-/*D
-Registers a function to be called (a callback) when a signal occurs.
-
-. .
-signum: 0-63
- f: the callback function
-. .
-
-Returns 0 if OK, otherwise PI_BAD_SIGNUM.
-
-The function is passed the signal number.
-
-One function may be registered per signal.
-
-The callback may be cancelled by passing NULL.
-
-By default all signals are treated as fatal and cause the library
-to call gpioTerminate and then exit.
-D*/
-
-
-/*F*/
-int gpioSetSignalFuncEx(
- unsigned signum, gpioSignalFuncEx_t f, void *userdata);
-/*D
-Registers a function to be called (a callback) when a signal occurs.
-
-. .
- signum: 0-63
- f: the callback function
-userdata: a pointer to arbitrary user data
-. .
-
-Returns 0 if OK, otherwise PI_BAD_SIGNUM.
-
-The function is passed the signal number and the userdata pointer.
-
-Only one of gpioSetSignalFunc or gpioSetSignalFuncEx can be
-registered per signal.
-
-See gpioSetSignalFunc for further details.
-D*/
-
-
-/*F*/
-uint32_t gpioRead_Bits_0_31(void);
-/*D
-Returns the current level of GPIO 0-31.
-D*/
-
-
-/*F*/
-uint32_t gpioRead_Bits_32_53(void);
-/*D
-Returns the current level of GPIO 32-53.
-D*/
-
-
-/*F*/
-int gpioWrite_Bits_0_31_Clear(uint32_t bits);
-/*D
-Clears GPIO 0-31 if the corresponding bit in bits is set.
-
-. .
-bits: a bit mask of GPIO to clear
-. .
-
-Returns 0 if OK.
-
-...
-// To clear (set to 0) GPIO 4, 7, and 15
-gpioWrite_Bits_0_31_Clear( (1<<4) | (1<<7) | (1<<15) );
-...
-D*/
-
-
-/*F*/
-int gpioWrite_Bits_32_53_Clear(uint32_t bits);
-/*D
-Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-. .
-bits: a bit mask of GPIO to clear
-. .
-
-Returns 0 if OK.
-D*/
-
-
-/*F*/
-int gpioWrite_Bits_0_31_Set(uint32_t bits);
-/*D
-Sets GPIO 0-31 if the corresponding bit in bits is set.
-
-. .
-bits: a bit mask of GPIO to set
-. .
-
-Returns 0 if OK.
-D*/
-
-
-/*F*/
-int gpioWrite_Bits_32_53_Set(uint32_t bits);
-/*D
-Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-. .
-bits: a bit mask of GPIO to set
-. .
-
-Returns 0 if OK.
-
-...
-// To set (set to 1) GPIO 32, 40, and 53
-gpioWrite_Bits_32_53_Set((1<<(32-32)) | (1<<(40-32)) | (1<<(53-32)));
-...
-D*/
-
-/*F*/
-int gpioHardwareClock(unsigned gpio, unsigned clkfreq);
-/*D
-Starts a hardware clock on a GPIO at the specified frequency.
-Frequencies above 30MHz are unlikely to work.
-
-. .
- gpio: see description
-clkfreq: 0 (off) or 4689-250000000 (250M)
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HCLK_GPIO,
-PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-
-The same clock is available on multiple GPIO. The latest
-frequency setting will be used by all GPIO which share a clock.
-
-The GPIO must be one of the following.
-
-. .
-4 clock 0 All models
-5 clock 1 All models but A and B (reserved for system use)
-6 clock 2 All models but A and B
-20 clock 0 All models but A and B
-21 clock 1 All models but A and Rev.2 B (reserved for system use)
-
-32 clock 0 Compute module only
-34 clock 0 Compute module only
-42 clock 1 Compute module only (reserved for system use)
-43 clock 2 Compute module only
-44 clock 1 Compute module only (reserved for system use)
-. .
-
-Access to clock 1 is protected by a password as its use will likely
-crash the Pi. The password is given by or'ing 0x5A000000 with the
-GPIO number.
-D*/
-
-/*F*/
-int gpioHardwarePWM(unsigned gpio, unsigned PWMfreq, unsigned PWMduty);
-/*D
-Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
-Frequencies above 30MHz are unlikely to work.
-
-NOTE: Any waveform started by [*gpioWaveTxSend*], or
-[*gpioWaveChain*] will be cancelled.
-
-This function is only valid if the pigpio main clock is PCM. The
-main clock defaults to PCM but may be overridden by a call to
-[*gpioCfgClock*].
-
-. .
- gpio: see description
-PWMfreq: 0 (off) or 1-125000000 (125M)
-PWMduty: 0 (off) to 1000000 (1M)(fully on)
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_NOT_HPWM_GPIO,
-PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ, or PI_HPWM_ILLEGAL.
-
-The same PWM channel is available on multiple GPIO. The latest
-frequency and dutycycle setting will be used by all GPIO which
-share a PWM channel.
-
-The GPIO must be one of the following.
-
-. .
-12 PWM channel 0 All models but A and B
-13 PWM channel 1 All models but A and B
-18 PWM channel 0 All models
-19 PWM channel 1 All models but A and B
-
-40 PWM channel 0 Compute module only
-41 PWM channel 1 Compute module only
-45 PWM channel 1 Compute module only
-52 PWM channel 0 Compute module only
-53 PWM channel 1 Compute module only
-. .
-
-The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
-
-The actual frequency set is 250 million / steps.
-
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
-frequencies will have fewer steps. PWMduty is
-automatically scaled to take this into account.
-D*/
-
-/*F*/
-int gpioTime(unsigned timetype, int *seconds, int *micros);
-/*D
-Updates the seconds and micros variables with the current time.
-
-. .
-timetype: 0 (relative), 1 (absolute)
- seconds: a pointer to an int to hold seconds
- micros: a pointer to an int to hold microseconds
-. .
-
-Returns 0 if OK, otherwise PI_BAD_TIMETYPE.
-
-If timetype is PI_TIME_ABSOLUTE updates seconds and micros with the
-number of seconds and microseconds since the epoch (1st January 1970).
-
-If timetype is PI_TIME_RELATIVE updates seconds and micros with the
-number of seconds and microseconds since the library was initialised.
-
-...
-int secs, mics;
-
-// print the number of seconds since the library was started
-gpioTime(PI_TIME_RELATIVE, &secs, &mics);
-printf("library started %d.%03d seconds ago", secs, mics/1000);
-...
-D*/
-
-
-/*F*/
-int gpioSleep(unsigned timetype, int seconds, int micros);
-/*D
-Sleeps for the number of seconds and microseconds specified by seconds
-and micros.
-
-. .
-timetype: 0 (relative), 1 (absolute)
- seconds: seconds to sleep
- micros: microseconds to sleep
-. .
-
-Returns 0 if OK, otherwise PI_BAD_TIMETYPE, PI_BAD_SECONDS,
-or PI_BAD_MICROS.
-
-If timetype is PI_TIME_ABSOLUTE the sleep ends when the number of seconds
-and microseconds since the epoch (1st January 1970) has elapsed. System
-clock changes are taken into account.
-
-If timetype is PI_TIME_RELATIVE the sleep is for the specified number
-of seconds and microseconds. System clock changes do not effect the
-sleep length.
-
-For short delays (say, 50 microseonds or less) use [*gpioDelay*].
-
-...
-gpioSleep(PI_TIME_RELATIVE, 2, 500000); // sleep for 2.5 seconds
-
-gpioSleep(PI_TIME_RELATIVE, 0, 100000); // sleep for 0.1 seconds
-
-gpioSleep(PI_TIME_RELATIVE, 60, 0); // sleep for one minute
-...
-D*/
-
-
-/*F*/
-uint32_t gpioDelay(uint32_t micros);
-/*D
-Delays for at least the number of microseconds specified by micros.
-
-. .
-micros: the number of microseconds to sleep
-. .
-
-Returns the actual length of the delay in microseconds.
-
-Delays of 100 microseconds or less use busy waits.
-D*/
-
-
-/*F*/
-uint32_t gpioTick(void);
-/*D
-Returns the current system tick.
-
-Tick is the number of microseconds since system boot.
-
-As tick is an unsigned 32 bit quantity it wraps around after
-2^32 microseconds, which is approximately 1 hour 12 minutes.
-
-You don't need to worry about the wrap around as long as you
-take a tick (uint32_t) from another tick, i.e. the following
-code will always provide the correct difference.
-
-...
-uint32_t startTick, endTick;
-int diffTick;
-
-startTick = gpioTick();
-
-// do some processing
-
-endTick = gpioTick();
-
-diffTick = endTick - startTick;
-
-printf("some processing took %d microseconds", diffTick);
-...
-D*/
-
-
-/*F*/
-unsigned gpioHardwareRevision(void);
-/*D
-Returns the hardware revision.
-
-If the hardware revision can not be found or is not a valid hexadecimal
-number the function returns 0.
-
-The hardware revision is the last few characters on the Revision line of
-/proc/cpuinfo.
-
-The revision number can be used to determine the assignment of GPIO
-to pins (see [*gpio*]).
-
-There are at least three types of board.
-
-Type 1 boards have hardware revision numbers of 2 and 3.
-
-Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
-
-Type 3 boards have hardware revision numbers of 16 or greater.
-
-for "Revision : 0002" the function returns 2.
-for "Revision : 000f" the function returns 15.
-for "Revision : 000g" the function returns 0.
-D*/
-
-
-/*F*/
-unsigned gpioVersion(void);
-/*D
-Returns the pigpio version.
-D*/
-
-
-/*F*/
-int gpioGetPad(unsigned pad);
-/*D
-This function returns the pad drive strength in mA.
-
-. .
-pad: 0-2, the pad to get
-. .
-
-Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
-
-Pad @ GPIO
-0 @ 0-27
-1 @ 28-45
-2 @ 46-53
-
-...
-strength = gpioGetPad(1); // get pad 1 strength
-...
-D*/
-
-
-/*F*/
-int gpioSetPad(unsigned pad, unsigned padStrength);
-/*D
-This function sets the pad drive strength in mA.
-
-. .
- pad: 0-2, the pad to set
-padStrength: 1-16 mA
-. .
-
-Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
-
-Pad @ GPIO
-0 @ 0-27
-1 @ 28-45
-2 @ 46-53
-
-...
-gpioSetPad(0, 16); // set pad 0 strength to 16 mA
-...
-D*/
-
-
-/*F*/
-int shell(char *scriptName, char *scriptString);
-/*D
-This function uses the system call to execute a shell script
-with the given string as its parameter.
-
-. .
- scriptName: the name of the script, only alphanumeric characters,
- '-' and '_' are allowed in the name
-scriptString: the string to pass to the script
-. .
-
-The exit status of the system call is returned if OK, otherwise
-PI_BAD_SHELL_STATUS.
-
-scriptName must exist in /opt/pigpio/cgi and must be executable.
-
-The returned exit status is normally 256 times that set by the
-shell script exit function. If the script can't be found 32512 will
-be returned.
-
-The following table gives some example returned statuses.
-
-Script exit status @ Returned system call status
-1 @ 256
-5 @ 1280
-10 @ 2560
-200 @ 51200
-script not found @ 32512
-
-...
-// pass two parameters, hello and world
-status = shell("scr1", "hello world");
-
-// pass three parameters, hello, string with spaces, and world
-status = shell("scr1", "hello 'string with spaces' world");
-
-// pass one parameter, hello string with spaces world
-status = shell("scr1", "\"hello string with spaces world\"");
-...
-D*/
-
-#pragma GCC diagnostic push
-
-#pragma GCC diagnostic ignored "-Wcomment"
-
-/*F*/
-int fileOpen(char *file, unsigned mode);
-/*D
-This function returns a handle to a file opened in a specified mode.
-
-. .
-file: the file to open
-mode: the file open mode
-. .
-
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
-PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
-
-File
-
-A file may only be opened if permission is granted by an entry in
-/opt/pigpio/access. This is intended to allow remote access to files
-in a more or less controlled manner.
-
-Each entry in /opt/pigpio/access takes the form of a file path
-which may contain wildcards followed by a single letter permission.
-The permission may be R for read, W for write, U for read/write,
-and N for no access.
-
-Where more than one entry matches a file the most specific rule
-applies. If no entry matches a file then access is denied.
-
-Suppose /opt/pigpio/access contains the following entries
-
-. .
-/home/* n
-/home/pi/shared/dir_1/* w
-/home/pi/shared/dir_2/* r
-/home/pi/shared/dir_3/* u
-/home/pi/shared/dir_1/file.txt n
-. .
-
-Files may be written in directory dir_1 with the exception
-of file.txt.
-
-Files may be read in directory dir_2.
-
-Files may be read and written in directory dir_3.
-
-If a directory allows read, write, or read/write access then files may
-be created in that directory.
-
-In an attempt to prevent risky permissions the following paths are
-ignored in /opt/pigpio/access.
-
-. .
-a path containing ..
-a path containing only wildcards (*?)
-a path containing less than two non-wildcard parts
-. .
-
-Mode
-
-The mode may have the following values.
-
-Macro @ Value @ Meaning
-PI_FILE_READ @ 1 @ open file for reading
-PI_FILE_WRITE @ 2 @ open file for writing
-PI_FILE_RW @ 3 @ open file for reading and writing
-
-The following values may be or'd into the mode.
-
-Macro @ Value @ Meaning
-PI_FILE_APPEND @ 4 @ Writes append data to the end of the file
-PI_FILE_CREATE @ 8 @ The file is created if it doesn't exist
-PI_FILE_TRUNC @ 16 @ The file is truncated
-
-Newly created files are owned by root with permissions owner read and write.
-
-...
-#include
-#include
-
-int main(int argc, char *argv[])
-{
- int handle, c;
- char buf[60000];
-
- if (gpioInitialise() < 0) return 1;
-
- // assumes /opt/pigpio/access contains the following line
- // /ram/*.c r
-
- handle = fileOpen("/ram/pigpio.c", PI_FILE_READ);
-
- if (handle >= 0)
- {
- while ((c=fileRead(handle, buf, sizeof(buf)-1)))
- {
- buf[c] = 0;
- printf("%s", buf);
- }
-
- fileClose(handle);
- }
-
- gpioTerminate();
-}
-...
-D*/
-
-#pragma GCC diagnostic pop
-
-/*F*/
-int fileClose(unsigned handle);
-/*D
-This function closes the file associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*fileOpen*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-...
-fileClose(h);
-...
-D*/
-
-
-/*F*/
-int fileWrite(unsigned handle, char *buf, unsigned count);
-/*D
-This function writes count bytes from buf to the the file
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*fileOpen*]
- buf: the array of bytes to write
- count: the number of bytes to write
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
-PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
-
-...
-status = fileWrite(h, buf, count);
-if (status == 0)
-{
- // okay
-}
-else
-{
- // error
-}
-...
-D*/
-
-
-/*F*/
-int fileRead(unsigned handle, char *buf, unsigned count);
-/*D
-This function reads up to count bytes from the the file
-associated with handle and writes them to buf.
-
-. .
-handle: >=0, as returned by a call to [*fileOpen*]
- buf: an array to receive the read data
- count: the maximum number of bytes to read
-. .
-
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
-
-...
-if (fileRead(h, buf, sizeof(buf)) > 0)
-{
- // process read data
-}
-...
-D*/
-
-
-/*F*/
-int fileSeek(unsigned handle, int32_t seekOffset, int seekFrom);
-/*D
-This function seeks to a position within the file associated
-with handle.
-
-. .
- handle: >=0, as returned by a call to [*fileOpen*]
-seekOffset: the number of bytes to move. Positive offsets
- move forward, negative offsets backwards.
- seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
- or PI_FROM_END (2)
-. .
-
-Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
-
-...
-fileSeek(0, 20, PI_FROM_START); // Seek to start plus 20
-
-size = fileSeek(0, 0, PI_FROM_END); // Seek to end, return size
-
-pos = fileSeek(0, 0, PI_FROM_CURRENT); // Return current position
-...
-D*/
-
-#pragma GCC diagnostic push
-
-#pragma GCC diagnostic ignored "-Wcomment"
-
-/*F*/
-int fileList(char *fpat, char *buf, unsigned count);
-/*D
-This function returns a list of files which match a pattern. The
-pattern may contain wildcards.
-
-. .
- fpat: file pattern to match
- buf: an array to receive the matching file names
-count: the maximum number of bytes to read
-. .
-
-Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
-or PI_NO_FILE_MATCH.
-
-The pattern must match an entry in /opt/pigpio/access. The pattern
-may contain wildcards. See [*fileOpen*].
-
-NOTE
-
-The returned value is not the number of files, it is the number
-of bytes in the buffer. The file names are separated by newline
-characters.
-
-...
-#include
-#include
-
-int main(int argc, char *argv[])
-{
- int c;
- char buf[1000];
-
- if (gpioInitialise() < 0) return 1;
-
- // assumes /opt/pigpio/access contains the following line
- // /ram/*.c r
-
- c = fileList("/ram/p*.c", buf, sizeof(buf));
-
- if (c >= 0)
- {
- // terminate string
- buf[c] = 0;
- printf("%s", buf);
- }
-
- gpioTerminate();
-}
-...
-D*/
-
-#pragma GCC diagnostic pop
-
-
-/*F*/
-int gpioCfgBufferSize(unsigned cfgMillis);
-/*D
-Configures pigpio to buffer cfgMillis milliseconds of GPIO samples.
-
-This function is only effective if called before [*gpioInitialise*].
-
-. .
-cfgMillis: 100-10000
-. .
-
-The default setting is 120 milliseconds.
-
-The intention is to allow for bursts of data and protection against
-other processes hogging cpu time.
-
-I haven't seen a process locked out for more than 100 milliseconds.
-
-Making the buffer bigger uses a LOT of memory at the more frequent
-sampling rates as shown in the following table in MBs.
-
-. .
- buffer milliseconds
- 120 250 500 1sec 2sec 4sec 8sec
-
- 1 16 31 55 107 --- --- ---
- 2 10 18 31 55 107 --- ---
-sample 4 8 12 18 31 55 107 ---
- rate 5 8 10 14 24 45 87 ---
- (us) 8 6 8 12 18 31 55 107
- 10 6 8 10 14 24 45 87
-. .
-D*/
-
-
-/*F*/
-int gpioCfgClock(
- unsigned cfgMicros, unsigned cfgPeripheral, unsigned cfgSource);
-/*D
-Configures pigpio to use a particular sample rate timed by a specified
-peripheral.
-
-This function is only effective if called before [*gpioInitialise*].
-
-. .
- cfgMicros: 1, 2, 4, 5, 8, 10
-cfgPeripheral: 0 (PWM), 1 (PCM)
- cfgSource: deprecated, value is ignored
-. .
-
-The timings are provided by the specified peripheral (PWM or PCM).
-
-The default setting is 5 microseconds using the PCM peripheral.
-
-The approximate CPU percentage used for each sample rate is:
-
-. .
-sample cpu
- rate %
-
- 1 25
- 2 16
- 4 11
- 5 10
- 8 15
- 10 14
-. .
-
-A sample rate of 5 microseconds seeems to be the sweet spot.
-D*/
-
-
-/*F*/
-int gpioCfgDMAchannel(unsigned DMAchannel); /* DEPRECATED */
-/*D
-Configures pigpio to use the specified DMA channel.
-
-This function is only effective if called before [*gpioInitialise*].
-
-. .
-DMAchannel: 0-14
-. .
-
-The default setting is to use channel 14.
-D*/
-
-
-/*F*/
-int gpioCfgDMAchannels(
- unsigned primaryChannel, unsigned secondaryChannel);
-/*D
-Configures pigpio to use the specified DMA channels.
-
-This function is only effective if called before [*gpioInitialise*].
-
-. .
- primaryChannel: 0-14
-secondaryChannel: 0-14
-. .
-
-The default setting is to use channel 14 for the primary channel and
-channel 6 for the secondary channel.
-
-The secondary channel is only used for the transmission of waves.
-
-If possible use one of channels 0 to 6 for the secondary channel
-(a full channel).
-
-A full channel only requires one DMA control block regardless of the
-length of a pulse delay. Channels 7 to 14 (lite channels) require
-one DMA control block for each 16383 microseconds of delay. I.e.
-a 10 second pulse delay requires one control block on a full channel
-and 611 control blocks on a lite channel.
-D*/
-
-
-/*F*/
-int gpioCfgPermissions(uint64_t updateMask);
-/*D
-Configures pigpio to only allow updates (writes or mode changes) for the
-GPIO specified by the mask.
-
-This function is only effective if called before [*gpioInitialise*].
-
-. .
-updateMask: bit (1<=0
-arg2: >=0
-argx: extra (byte) arguments
-argc: number of extra arguments
-. .
-
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-D*/
-
-
-/*F*/
-int gpioCustom2(unsigned arg1, char *argx, unsigned argc,
- char *retBuf, unsigned retMax);
-/*D
-This function is available for user customisation.
-
-It differs from gpioCustom1 in that it returns an array of bytes
-rather than just an integer.
-
-The returned value is an integer indicating the number of returned bytes.
-. .
- arg1: >=0
- argx: extra (byte) arguments
- argc: number of extra arguments
-retBuf: buffer for returned bytes
-retMax: maximum number of bytes to return
-. .
-
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-The number of returned bytes must be retMax or less.
-D*/
-
-
-/*F*/
-int rawWaveAddSPI(
- rawSPI_t *spi,
- unsigned offset,
- unsigned spiSS,
- char *buf,
- unsigned spiTxBits,
- unsigned spiBitFirst,
- unsigned spiBitLast,
- unsigned spiBits);
-/*D
-This function adds a waveform representing SPI data to the
-existing waveform (if any).
-
-. .
- spi: a pointer to a spi object
- offset: microseconds from the start of the waveform
- spiSS: the slave select GPIO
- buf: the bits to transmit, most significant bit first
- spiTxBits: the number of bits to write
-spiBitFirst: the first bit to read
- spiBitLast: the last bit to read
- spiBits: the number of bits to transfer
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_SER_OFFSET, or PI_TOO_MANY_PULSES.
-
-Not intended for general use.
-D*/
-
-/*F*/
-int rawWaveAddGeneric(unsigned numPulses, rawWave_t *pulses);
-/*D
-This function adds a number of pulses to the current waveform.
-
-. .
-numPulses: the number of pulses
- pulses: the array containing the pulses
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-The advantage of this function over gpioWaveAddGeneric is that it
-allows the setting of the flags field.
-
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist of a delay.
-
-Not intended for general use.
-D*/
-
-/*F*/
-unsigned rawWaveCB(void);
-/*D
-Returns the number of the cb being currently output.
-
-Not intended for general use.
-D*/
-
-/*F*/
-rawCbs_t *rawWaveCBAdr(int cbNum);
-/*D
-Return the (Linux) address of contol block cbNum.
-
-. .
-cbNum: the cb of interest
-. .
-
-Not intended for general use.
-D*/
-
-/*F*/
-uint32_t rawWaveGetOOL(int pos);
-/*D
-Gets the OOL parameter stored at pos.
-
-. .
-pos: the position of interest.
-. .
-
-Not intended for general use.
-D*/
-
-
-/*F*/
-void rawWaveSetOOL(int pos, uint32_t lVal);
-/*D
-Sets the OOL parameter stored at pos to value.
-
-. .
- pos: the position of interest
-lVal: the value to write
-. .
-
-Not intended for general use.
-D*/
-
-/*F*/
-uint32_t rawWaveGetOut(int pos);
-/*D
-Gets the wave output parameter stored at pos.
-
-DEPRECATED: use rawWaveGetOOL instead.
-
-. .
-pos: the position of interest.
-. .
-
-Not intended for general use.
-D*/
-
-
-/*F*/
-void rawWaveSetOut(int pos, uint32_t lVal);
-/*D
-Sets the wave output parameter stored at pos to value.
-
-DEPRECATED: use rawWaveSetOOL instead.
-
-. .
- pos: the position of interest
-lVal: the value to write
-. .
-
-Not intended for general use.
-D*/
-
-/*F*/
-uint32_t rawWaveGetIn(int pos);
-/*D
-Gets the wave input value parameter stored at pos.
-
-DEPRECATED: use rawWaveGetOOL instead.
-
-. .
-pos: the position of interest
-. .
-
-Not intended for general use.
-D*/
-
-
-/*F*/
-void rawWaveSetIn(int pos, uint32_t lVal);
-/*D
-Sets the wave input value stored at pos to value.
-
-DEPRECATED: use rawWaveSetOOL instead.
-
-. .
- pos: the position of interest
-lVal: the value to write
-. .
-
-Not intended for general use.
-D*/
-
-/*F*/
-rawWaveInfo_t rawWaveInfo(int wave_id);
-/*D
-Gets details about the wave with id wave_id.
-
-. .
-wave_id: the wave of interest
-. .
-
-Not intended for general use.
-D*/
-
-/*F*/
-int getBitInBytes(int bitPos, char *buf, int numBits);
-/*D
-Returns the value of the bit bitPos bits from the start of buf. Returns
-0 if bitPos is greater than or equal to numBits.
-
-. .
- bitPos: bit index from the start of buf
- buf: array of bits
-numBits: number of valid bits in buf
-. .
-
-D*/
-
-/*F*/
-void putBitInBytes(int bitPos, char *buf, int bit);
-/*D
-Sets the bit bitPos bits from the start of buf to bit.
-
-. .
-bitPos: bit index from the start of buf
- buf: array of bits
- bit: 0-1, value to set
-. .
-
-D*/
-
-/*F*/
-double time_time(void);
-/*D
-Return the current time in seconds since the Epoch.
-D*/
-
-
-/*F*/
-void time_sleep(double seconds);
-/*D
-Delay execution for a given number of seconds
-
-. .
-seconds: the number of seconds to sleep
-. .
-D*/
-
-
-/*F*/
-void rawDumpWave(void);
-/*D
-Used to print a readable version of the current waveform to stderr.
-
-Not intended for general use.
-D*/
-
-
-/*F*/
-void rawDumpScript(unsigned script_id);
-/*D
-Used to print a readable version of a script to stderr.
-
-. .
-script_id: >=0, a script_id returned by [*gpioStoreScript*]
-. .
-
-Not intended for general use.
-D*/
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*PARAMS
-
-active :: 0-1000000
-
-The number of microseconds level changes are reported for once
-a noise filter has been triggered (by [*steady*] microseconds of
-a stable level).
-
-arg1::
-
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-arg2::
-
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-argc::
-The count of bytes passed to a user customised function.
-
-*argx::
-A pointer to an array of bytes passed to a user customised function.
-Its meaning and content is defined by the customiser.
-
-baud::
-The speed of serial communication (I2C, SPI, serial link, waves) in
-bits per second.
-
-bit::
-A value of 0 or 1.
-
-bitPos::
-A bit position within a byte or word. The least significant bit is
-position 0.
-
-bits::
-A value used to select GPIO. If bit n of bits is set then GPIO n is
-selected.
-
-A convenient way to set bit n is to or in (1<=0
-
-The number of times a GPIO is swiched on and off per second. This
-can be set per GPIO and may be as little as 5Hz or as much as
-40KHz. The GPIO will be on for a proportion of the time as defined
-by its dutycycle.
-
-gpio::
-
-A Broadcom numbered GPIO, in the range 0-53.
-
-There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
-GPIO53.
-
-They are split into two banks. Bank 1 consists of GPIO0 through
-GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-
-All the GPIO which are safe for the user to read and write are in
-bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
-have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
-See [*gpioHardwareRevision*].
-
-The user GPIO are marked with an X in the following table.
-
-. .
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-Type 1 X X - - X - - X X X X X - - X X
-Type 2 - - X X X - - X X X X X - - X X
-Type 3 X X X X X X X X X X X X X X
-
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
-Type 1 - X X - - X X X X X - - - - - -
-Type 2 - X X - - - X X X X - X X X X X
-Type 3 X X X X X X X X X X X X - - - -
-. .
-
-gpioAlertFunc_t::
-. .
-typedef void (*gpioAlertFunc_t) (int gpio, int level, uint32_t tick);
-. .
-
-gpioAlertFuncEx_t::
-. .
-typedef void (*gpioAlertFuncEx_t)
- (int gpio, int level, uint32_t tick, void *userdata);
-. .
-
-gpioCfg*::
-
-These functions are only effective if called before [*gpioInitialise*].
-
-[*gpioCfgBufferSize*]
-[*gpioCfgClock*]
-[*gpioCfgDMAchannel*]
-[*gpioCfgDMAchannels*]
-[*gpioCfgPermissions*]
-[*gpioCfgInterfaces*]
-[*gpioCfgSocketPort*]
-[*gpioCfgMemAlloc*]
-
-gpioGetSamplesFunc_t::
-. .
-typedef void (*gpioGetSamplesFunc_t)
- (const gpioSample_t *samples, int numSamples);
-. .
-
-gpioGetSamplesFuncEx_t::
-. .
-typedef void (*gpioGetSamplesFuncEx_t)
- (const gpioSample_t *samples, int numSamples, void *userdata);
-. .
-
-gpioISRFunc_t::
-. .
-typedef void (*gpioISRFunc_t)
- (int gpio, int level, uint32_t tick);
-. .
-
-gpioISRFuncEx_t::
-. .
-typedef void (*gpioISRFuncEx_t)
- (int gpio, int level, uint32_t tick, void *userdata);
-. .
-
-gpioPulse_t::
-. .
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
-} gpioPulse_t;
-. .
-
-gpioSample_t::
-. .
-typedef struct
-{
- uint32_t tick;
- uint32_t level;
-} gpioSample_t;
-. .
-
-gpioSignalFunc_t::
-. .
-typedef void (*gpioSignalFunc_t) (int signum);
-. .
-
-gpioSignalFuncEx_t::
-. .
-typedef void (*gpioSignalFuncEx_t) (int signum, void *userdata);
-. .
-
-gpioThreadFunc_t::
-. .
-typedef void *(gpioThreadFunc_t) (void *);
-. .
-
-gpioTimerFunc_t::
-. .
-typedef void (*gpioTimerFunc_t) (void);
-. .
-
-gpioTimerFuncEx_t::
-. .
-typedef void (*gpioTimerFuncEx_t) (void *userdata);
-. .
-
-gpioWaveAdd*::
-
-One of
-
-[*gpioWaveAddNew*]
-[*gpioWaveAddGeneric*]
-[*gpioWaveAddSerial*]
-
-handle::>=0
-
-A number referencing an object opened by one of [*fileOpen*],
-[*gpioNotifyOpen*], [*i2cOpen*], [*serOpen*], [*spiOpen*].
-
-i2cAddr:: 0-0x7F
-The address of a device on the I2C bus.
-
-i2cBus::>=0
-
-An I2C bus number.
-
-i2cFlags::0
-
-Flags which modify an I2C open command. None are currently defined.
-
-i2cReg:: 0-255
-
-A register of an I2C device.
-
-ifFlags::0-3
-. .
-PI_DISABLE_FIFO_IF 1
-PI_DISABLE_SOCK_IF 2
-. .
-
-*inBuf::
-A buffer used to pass data to a function.
-
-inLen::
-The number of bytes of data in a buffer.
-
-int::
-A whole number, negative or positive.
-
-int32_t::
-A 32-bit signed value.
-
-invert::
-A flag used to set normal or inverted bit bang serial data level logic.
-
-level::
-The level of a GPIO. Low or High.
-
-. .
-PI_OFF 0
-PI_ON 1
-
-PI_CLEAR 0
-PI_SET 1
-
-PI_LOW 0
-PI_HIGH 1
-. .
-
-There is one exception. If a watchdog expires on a GPIO the level will be
-reported as PI_TIMEOUT. See [*gpioSetWatchdog*].
-
-. .
-PI_TIMEOUT 2
-. .
-
-
-lVal::0-4294967295 (Hex 0x0-0xFFFFFFFF, Octal 0-37777777777)
-
-A 32-bit word value.
-
-memAllocMode:: 0-2
-
-The DMA memory allocation mode.
-
-. .
-PI_MEM_ALLOC_AUTO 0
-PI_MEM_ALLOC_PAGEMAP 1
-PI_MEM_ALLOC_MAILBOX 2
-. .
-
-*micros::
-
-A value representing microseconds.
-
-micros::
-
-A value representing microseconds.
-
-millis::
-
-A value representing milliseconds.
-
-MISO::
-The GPIO used for the MISO signal when bit banging SPI.
-
-mode::
-
-1. The operational mode of a GPIO, normally INPUT or OUTPUT.
-
-. .
-PI_INPUT 0
-PI_OUTPUT 1
-PI_ALT0 4
-PI_ALT1 5
-PI_ALT2 6
-PI_ALT3 7
-PI_ALT4 3
-PI_ALT5 2
-. .
-
-2. A file open mode.
-
-. .
-PI_FILE_READ 1
-PI_FILE_WRITE 2
-PI_FILE_RW 3
-. .
-
-The following values can be or'd into the mode.
-
-. .
-PI_FILE_APPEND 4
-PI_FILE_CREATE 8
-PI_FILE_TRUNC 16
-. .
-
-MOSI::
-The GPIO used for the MOSI signal when bit banging SPI.
-
-numBits::
-
-The number of bits stored in a buffer.
-
-numBytes::
-The number of bytes used to store characters in a string. Depending
-on the number of bits per character there may be 1, 2, or 4 bytes
-per character.
-
-numPar:: 0-10
-The number of parameters passed to a script.
-
-numPulses::
-The number of pulses to be added to a waveform.
-
-numSegs::
-The number of segments in a combined I2C transaction.
-
-numSockAddr::
-The number of network addresses allowed to use the socket interface.
-
-0 means all addresses allowed.
-
-offset::
-The associated data starts this number of microseconds from the start of
-the waveform.
-
-*outBuf::
-A buffer used to return data from a function.
-
-outLen::
-The size in bytes of an output buffer.
-
-pad:: 0-2
-A set of GPIO which share common drivers.
-
-Pad @ GPIO
-0 @ 0-27
-1 @ 28-45
-2 @ 46-53
-
-padStrength:: 1-16
-The mA which may be drawn from each GPIO whilst still guaranteeing the
-high and low levels.
-
-*param::
-An array of script parameters.
-
-pi_i2c_msg_t::
-. .
-typedef struct
-{
- uint16_t addr; // slave address
- uint16_t flags;
- uint16_t len; // msg length
- uint8_t *buf; // pointer to msg data
-} pi_i2c_msg_t;
-. .
-
-port:: 1024-32000
-The port used to bind to the pigpio socket. Defaults to 8888.
-
-pos::
-The position of an item.
-
-primaryChannel:: 0-14
-The DMA channel used to time the sampling of GPIO and to time servo and
-PWM pulses.
-
-*pth::
-
-A thread identifier, returned by [*gpioStartThread*].
-
-pthread_t::
-
-A thread identifier.
-
-pud::0-2
-
-The setting of the pull up/down resistor for a GPIO, which may be off,
-pull-up, or pull-down.
-. .
-PI_PUD_OFF 0
-PI_PUD_DOWN 1
-PI_PUD_UP 2
-. .
-
-pulseLen::
-
-1-100, the length of a trigger pulse in microseconds.
-
-*pulses::
-
-An array of pulses to be added to a waveform.
-
-pulsewidth::0, 500-2500
-. .
-PI_SERVO_OFF 0
-PI_MIN_SERVO_PULSEWIDTH 500
-PI_MAX_SERVO_PULSEWIDTH 2500
-. .
-
-PWMduty::0-1000000 (1M)
-The hardware PWM dutycycle.
-
-. .
-PI_HW_PWM_RANGE 1000000
-. .
-
-PWMfreq::5-250K
-The hardware PWM frequency.
-
-. .
-PI_HW_PWM_MIN_FREQ 1
-PI_HW_PWM_MAX_FREQ 125000000
-. .
-
-range::25-40000
-. .
-PI_MIN_DUTYCYCLE_RANGE 25
-PI_MAX_DUTYCYCLE_RANGE 40000
-. .
-
-rawCbs_t::
-. .
-typedef struct // linux/arch/arm/mach-bcm2708/include/mach/dma.h
-{
- unsigned long info;
- unsigned long src;
- unsigned long dst;
- unsigned long length;
- unsigned long stride;
- unsigned long next;
- unsigned long pad[2];
-} rawCbs_t;
-. .
-
-rawSPI_t::
-. .
-typedef struct
-{
- int clk; // GPIO for clock
- int mosi; // GPIO for MOSI
- int miso; // GPIO for MISO
- int ss_pol; // slave select off state
- int ss_us; // delay after slave select
- int clk_pol; // clock off state
- int clk_pha; // clock phase
- int clk_us; // clock micros
-} rawSPI_t;
-. .
-
-rawWave_t::
-. .
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
- uint32_t flags;
-} rawWave_t;
-. .
-
-rawWaveInfo_t::
-. .
-typedef struct
-{
- uint16_t botCB; // first CB used by wave
- uint16_t topCB; // last CB used by wave
- uint16_t botOOL; // last OOL used by wave
- uint16_t topOOL; // first OOL used by wave
- uint16_t deleted;
- uint16_t numCB;
- uint16_t numBOOL;
- uint16_t numTOOL;
-} rawWaveInfo_t;
-. .
-
-*retBuf::
-
-A buffer to hold a number of bytes returned to a used customised function,
-
-retMax::
-
-The maximum number of bytes a user customised function should return.
-
-*rxBuf::
-
-A pointer to a buffer to receive data.
-
-SCL::
-The user GPIO to use for the clock when bit banging I2C.
-
-SCLK::
-The GPIO used for the SCLK signal when bit banging SPI.
-
-*script::
-A pointer to the text of a script.
-
-script_id::
-An id of a stored script as returned by [*gpioStoreScript*].
-
-*scriptName::
-The name of a [*shell*] script to be executed. The script must be present in
-/opt/pigpio/cgi and must have execute permission.
-
-*scriptString::
-The string to be passed to a [*shell*] script to be executed.
-
-SDA::
-The user GPIO to use for data when bit banging I2C.
-
-secondaryChannel:: 0-6
-
-The DMA channel used to time output waveforms.
-
-*seconds::
-
-A pointer to a uint32_t to store the second component of
-a returned time.
-
-seconds::
-The number of seconds.
-
-seekFrom::
-
-. .
-PI_FROM_START 0
-PI_FROM_CURRENT 1
-PI_FROM_END 2
-. .
-
-seekOffset::
-The number of bytes to move forward (positive) or backwards (negative)
-from the seek position (start, current, or end of file).
-
-*segs::
-An array of segments which make up a combined I2C transaction.
-
-serFlags::
-Flags which modify a serial open command. None are currently defined.
-
-*sertty::
-The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
-
-setting::
-A value used to set a flag, 0 for false, non-zero for true.
-
-signum::0-63
-. .
-PI_MIN_SIGNUM 0
-PI_MAX_SIGNUM 63
-. .
-
-size_t::
-
-A standard type used to indicate the size of an object in bytes.
-
-*sockAddr::
-An array of network addresses allowed to use the socket interface encoded
-as 32 bit numbers.
-
-E.g. address 192.168.1.66 would be encoded as 0x4201a8c0.
-
-*spi::
-A pointer to a [*rawSPI_t*] structure.
-
-spiBitFirst::
-GPIO reads are made from spiBitFirst to spiBitLast.
-
-spiBitLast::
-
-GPIO reads are made from spiBitFirst to spiBitLast.
-
-spiBits::
-The number of bits to transfer in a raw SPI transaction.
-
-spiChan::
-A SPI channel, 0-2.
-
-spiFlags::
-See [*spiOpen*] and [*bbSPIOpen*].
-
-spiSS::
-The SPI slave select GPIO in a raw SPI transaction.
-
-spiTxBits::
-The number of bits to transfer dring a raw SPI transaction
-
-steady :: 0-300000
-
-The number of microseconds level changes must be stable for
-before reporting the level changed ([*gpioGlitchFilter*]) or triggering
-the active part of a noise filter ([*gpioNoiseFilter*]).
-
-stop_bits::2-8
-The number of (half) stop bits to be used when adding serial data
-to a waveform.
-
-. .
-PI_MIN_WAVE_HALFSTOPBITS 2
-PI_MAX_WAVE_HALFSTOPBITS 8
-. .
-
-*str::
-An array of characters.
-
-timeout::
-A GPIO level change timeout in milliseconds.
-
-[*gpioSetWatchdog*]
-. .
-PI_MIN_WDOG_TIMEOUT 0
-PI_MAX_WDOG_TIMEOUT 60000
-. .
-
-[*gpioSetISRFunc*] and [*gpioSetISRFuncEx*]
-. .
-<=0 cancel timeout
->0 timeout after specified milliseconds
-. .
-
-timer::
-. .
-PI_MIN_TIMER 0
-PI_MAX_TIMER 9
-. .
-
-timetype::
-. .
-PI_TIME_RELATIVE 0
-PI_TIME_ABSOLUTE 1
-. .
-
-*txBuf::
-
-An array of bytes to transmit.
-
-uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)
-
-A 32-bit unsigned value.
-
-uint64_t::0-(2^64)-1
-
-A 64-bit unsigned value.
-
-unsigned::
-
-A whole number >= 0.
-
-updateMask::
-
-A 64 bit mask indicating which GPIO may be written to by the user.
-
-If GPIO#n may be written then bit (1< 3
-#define PI_BAD_CHANNEL -27 // DMA channel not 0-14
-#define PI_BAD_PRIM_CHANNEL -27 // DMA primary channel not 0-14
-#define PI_BAD_SOCKET_PORT -28 // socket port not 1024-32000
-#define PI_BAD_FIFO_COMMAND -29 // unrecognized fifo command
-#define PI_BAD_SECO_CHANNEL -30 // DMA secondary channel not 0-6
-#define PI_NOT_INITIALISED -31 // function called before gpioInitialise
-#define PI_INITIALISED -32 // function called after gpioInitialise
-#define PI_BAD_WAVE_MODE -33 // waveform mode not 0-3
-#define PI_BAD_CFG_INTERNAL -34 // bad parameter in gpioCfgInternals call
-#define PI_BAD_WAVE_BAUD -35 // baud rate not 50-250K(RX)/50-1M(TX)
-#define PI_TOO_MANY_PULSES -36 // waveform has too many pulses
-#define PI_TOO_MANY_CHARS -37 // waveform has too many chars
-#define PI_NOT_SERIAL_GPIO -38 // no bit bang serial read on GPIO
-#define PI_BAD_SERIAL_STRUC -39 // bad (null) serial structure parameter
-#define PI_BAD_SERIAL_BUF -40 // bad (null) serial buf parameter
-#define PI_NOT_PERMITTED -41 // GPIO operation not permitted
-#define PI_SOME_PERMITTED -42 // one or more GPIO not permitted
-#define PI_BAD_WVSC_COMMND -43 // bad WVSC subcommand
-#define PI_BAD_WVSM_COMMND -44 // bad WVSM subcommand
-#define PI_BAD_WVSP_COMMND -45 // bad WVSP subcommand
-#define PI_BAD_PULSELEN -46 // trigger pulse length not 1-100
-#define PI_BAD_SCRIPT -47 // invalid script
-#define PI_BAD_SCRIPT_ID -48 // unknown script id
-#define PI_BAD_SER_OFFSET -49 // add serial data offset > 30 minutes
-#define PI_GPIO_IN_USE -50 // GPIO already in use
-#define PI_BAD_SERIAL_COUNT -51 // must read at least a byte at a time
-#define PI_BAD_PARAM_NUM -52 // script parameter id not 0-9
-#define PI_DUP_TAG -53 // script has duplicate tag
-#define PI_TOO_MANY_TAGS -54 // script has too many tags
-#define PI_BAD_SCRIPT_CMD -55 // illegal script command
-#define PI_BAD_VAR_NUM -56 // script variable id not 0-149
-#define PI_NO_SCRIPT_ROOM -57 // no more room for scripts
-#define PI_NO_MEMORY -58 // can't allocate temporary memory
-#define PI_SOCK_READ_FAILED -59 // socket read failed
-#define PI_SOCK_WRIT_FAILED -60 // socket write failed
-#define PI_TOO_MANY_PARAM -61 // too many script parameters (> 10)
-#define PI_NOT_HALTED -62 // DEPRECATED
-#define PI_SCRIPT_NOT_READY -62 // script initialising
-#define PI_BAD_TAG -63 // script has unresolved tag
-#define PI_BAD_MICS_DELAY -64 // bad MICS delay (too large)
-#define PI_BAD_MILS_DELAY -65 // bad MILS delay (too large)
-#define PI_BAD_WAVE_ID -66 // non existent wave id
-#define PI_TOO_MANY_CBS -67 // No more CBs for waveform
-#define PI_TOO_MANY_OOL -68 // No more OOL for waveform
-#define PI_EMPTY_WAVEFORM -69 // attempt to create an empty waveform
-#define PI_NO_WAVEFORM_ID -70 // no more waveforms
-#define PI_I2C_OPEN_FAILED -71 // can't open I2C device
-#define PI_SER_OPEN_FAILED -72 // can't open serial device
-#define PI_SPI_OPEN_FAILED -73 // can't open SPI device
-#define PI_BAD_I2C_BUS -74 // bad I2C bus
-#define PI_BAD_I2C_ADDR -75 // bad I2C address
-#define PI_BAD_SPI_CHANNEL -76 // bad SPI channel
-#define PI_BAD_FLAGS -77 // bad i2c/spi/ser open flags
-#define PI_BAD_SPI_SPEED -78 // bad SPI speed
-#define PI_BAD_SER_DEVICE -79 // bad serial device name
-#define PI_BAD_SER_SPEED -80 // bad serial baud rate
-#define PI_BAD_PARAM -81 // bad i2c/spi/ser parameter
-#define PI_I2C_WRITE_FAILED -82 // i2c write failed
-#define PI_I2C_READ_FAILED -83 // i2c read failed
-#define PI_BAD_SPI_COUNT -84 // bad SPI count
-#define PI_SER_WRITE_FAILED -85 // ser write failed
-#define PI_SER_READ_FAILED -86 // ser read failed
-#define PI_SER_READ_NO_DATA -87 // ser read no data available
-#define PI_UNKNOWN_COMMAND -88 // unknown command
-#define PI_SPI_XFER_FAILED -89 // spi xfer/read/write failed
-#define PI_BAD_POINTER -90 // bad (NULL) pointer
-#define PI_NO_AUX_SPI -91 // no auxiliary SPI on Pi A or B
-#define PI_NOT_PWM_GPIO -92 // GPIO is not in use for PWM
-#define PI_NOT_SERVO_GPIO -93 // GPIO is not in use for servo pulses
-#define PI_NOT_HCLK_GPIO -94 // GPIO has no hardware clock
-#define PI_NOT_HPWM_GPIO -95 // GPIO has no hardware PWM
-#define PI_BAD_HPWM_FREQ -96 // hardware PWM frequency not 1-125M
-#define PI_BAD_HPWM_DUTY -97 // hardware PWM dutycycle not 0-1M
-#define PI_BAD_HCLK_FREQ -98 // hardware clock frequency not 4689-250M
-#define PI_BAD_HCLK_PASS -99 // need password to use hardware clock 1
-#define PI_HPWM_ILLEGAL -100 // illegal, PWM in use for main clock
-#define PI_BAD_DATABITS -101 // serial data bits not 1-32
-#define PI_BAD_STOPBITS -102 // serial (half) stop bits not 2-8
-#define PI_MSG_TOOBIG -103 // socket/pipe message too big
-#define PI_BAD_MALLOC_MODE -104 // bad memory allocation mode
-#define PI_TOO_MANY_SEGS -105 // too many I2C transaction segments
-#define PI_BAD_I2C_SEG -106 // an I2C transaction segment failed
-#define PI_BAD_SMBUS_CMD -107 // SMBus command not supported by driver
-#define PI_NOT_I2C_GPIO -108 // no bit bang I2C in progress on GPIO
-#define PI_BAD_I2C_WLEN -109 // bad I2C write length
-#define PI_BAD_I2C_RLEN -110 // bad I2C read length
-#define PI_BAD_I2C_CMD -111 // bad I2C command
-#define PI_BAD_I2C_BAUD -112 // bad I2C baud rate, not 50-500k
-#define PI_CHAIN_LOOP_CNT -113 // bad chain loop count
-#define PI_BAD_CHAIN_LOOP -114 // empty chain loop
-#define PI_CHAIN_COUNTER -115 // too many chain counters
-#define PI_BAD_CHAIN_CMD -116 // bad chain command
-#define PI_BAD_CHAIN_DELAY -117 // bad chain delay micros
-#define PI_CHAIN_NESTING -118 // chain counters nested too deeply
-#define PI_CHAIN_TOO_BIG -119 // chain is too long
-#define PI_DEPRECATED -120 // deprecated function removed
-#define PI_BAD_SER_INVERT -121 // bit bang serial invert not 0 or 1
-#define PI_BAD_EDGE -122 // bad ISR edge value, not 0-2
-#define PI_BAD_ISR_INIT -123 // bad ISR initialisation
-#define PI_BAD_FOREVER -124 // loop forever must be last command
-#define PI_BAD_FILTER -125 // bad filter parameter
-#define PI_BAD_PAD -126 // bad pad number
-#define PI_BAD_STRENGTH -127 // bad pad drive strength
-#define PI_FIL_OPEN_FAILED -128 // file open failed
-#define PI_BAD_FILE_MODE -129 // bad file mode
-#define PI_BAD_FILE_FLAG -130 // bad file flag
-#define PI_BAD_FILE_READ -131 // bad file read
-#define PI_BAD_FILE_WRITE -132 // bad file write
-#define PI_FILE_NOT_ROPEN -133 // file not open for read
-#define PI_FILE_NOT_WOPEN -134 // file not open for write
-#define PI_BAD_FILE_SEEK -135 // bad file seek
-#define PI_NO_FILE_MATCH -136 // no files match pattern
-#define PI_NO_FILE_ACCESS -137 // no permission to access file
-#define PI_FILE_IS_A_DIR -138 // file is a directory
-#define PI_BAD_SHELL_STATUS -139 // bad shell return status
-#define PI_BAD_SCRIPT_NAME -140 // bad script name
-#define PI_BAD_SPI_BAUD -141 // bad SPI baud rate, not 50-500k
-#define PI_NOT_SPI_GPIO -142 // no bit bang SPI in progress on GPIO
-
-#define PI_PIGIF_ERR_0 -2000
-#define PI_PIGIF_ERR_99 -2099
-
-#define PI_CUSTOM_ERR_0 -3000
-#define PI_CUSTOM_ERR_999 -3999
-
-/*DEF_E*/
-
-/*DEF_S Defaults*/
-
-#define PI_DEFAULT_BUFFER_MILLIS 120
-#define PI_DEFAULT_CLK_MICROS 5
-#define PI_DEFAULT_CLK_PERIPHERAL PI_CLOCK_PCM
-#define PI_DEFAULT_IF_FLAGS 0
-#define PI_DEFAULT_DMA_CHANNEL 14
-#define PI_DEFAULT_DMA_PRIMARY_CHANNEL 14
-#define PI_DEFAULT_DMA_SECONDARY_CHANNEL 6
-#define PI_DEFAULT_SOCKET_PORT 8888
-#define PI_DEFAULT_SOCKET_PORT_STR "8888"
-#define PI_DEFAULT_SOCKET_ADDR_STR "127.0.0.1"
-#define PI_DEFAULT_UPDATE_MASK_UNKNOWN 0xFFFFFFFF
-#define PI_DEFAULT_UPDATE_MASK_B1 0x03E7CF93
-#define PI_DEFAULT_UPDATE_MASK_A_B2 0xFBC7CF9C
-#define PI_DEFAULT_UPDATE_MASK_APLUS_BPLUS 0x0080480FFFFFFCLL
-#define PI_DEFAULT_UPDATE_MASK_ZERO 0x0080000FFFFFFCLL
-#define PI_DEFAULT_UPDATE_MASK_PI2B 0x0080480FFFFFFCLL
-#define PI_DEFAULT_UPDATE_MASK_PI3B 0x0000000FFFFFFCLL
-#define PI_DEFAULT_UPDATE_MASK_COMPUTE 0x00FFFFFFFFFFFFLL
-#define PI_DEFAULT_MEM_ALLOC_MODE PI_MEM_ALLOC_AUTO
-
-#define PI_DEFAULT_CFG_INTERNALS 0
-
-/*DEF_E*/
-
-#endif
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.o b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.o
deleted file mode 100644
index b5871c3c6..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.o and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.py b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.py
deleted file mode 100644
index b0962d557..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpio.py
+++ /dev/null
@@ -1,5023 +0,0 @@
-"""
-pigpio is a Python module for the Raspberry which talks to
-the pigpio daemon to allow control of the general purpose
-input outputs (GPIO).
-
-[http://abyz.co.uk/rpi/pigpio/python.html]
-
-*Features*
-
-o the pigpio Python module can run on Windows, Macs, or Linux
-
-o controls one or more Pi's
-
-o hardware timed PWM on any of GPIO 0-31
-
-o hardware timed servo pulses on any of GPIO 0-31
-
-o callbacks when any of GPIO 0-31 change state
-
-o creating and transmitting precisely timed waveforms
-
-o reading/writing GPIO and setting their modes
-
-o wrappers for I2C, SPI, and serial links
-
-o creating and running scripts on the pigpio daemon
-
-*GPIO*
-
-ALL GPIO are identified by their Broadcom number.
-
-*Notes*
-
-Transmitted waveforms are accurate to a microsecond.
-
-Callback level changes are time-stamped and will be
-accurate to within a few microseconds.
-
-*Settings*
-
-A number of settings are determined when the pigpio daemon is started.
-
-o the sample rate (1, 2, 4, 5, 8, or 10 us, default 5 us).
-
-o the set of GPIO which may be updated (generally written to). The
- default set is those available on the Pi board revision.
-
-o the available PWM frequencies (see [*set_PWM_frequency*]).
-
-*Exceptions*
-
-By default a fatal exception is raised if you pass an invalid
-argument to a pigpio function.
-
-If you wish to handle the returned status yourself you should set
-pigpio.exceptions to False.
-
-You may prefer to check the returned status in only a few parts
-of your code. In that case do the following.
-
-...
-pigpio.exceptions = False
-
-# Code where you want to test the error status.
-
-pigpio.exceptions = True
-...
-
-*Usage*
-
-This module uses the services of the C pigpio library. pigpio
-must be running on the Pi(s) whose GPIO are to be manipulated.
-
-The normal way to start pigpio is as a daemon (during system
-start).
-
-sudo pigpiod
-
-Your Python program must import pigpio and create one or more
-instances of the pigpio.pi class. This class gives access to
-a specified Pi's GPIO.
-
-...
-pi1 = pigpio.pi() # pi1 accesses the local Pi's GPIO
-pi2 = pigpio.pi('tom') # pi2 accesses tom's GPIO
-pi3 = pigpio.pi('dick') # pi3 accesses dick's GPIO
-
-pi1.write(4, 0) # set local Pi's GPIO 4 low
-pi2.write(4, 1) # set tom's GPIO 4 to high
-pi3.read(4) # get level of dick's GPIO 4
-...
-
-The later example code snippets assume that pi is an instance of
-the pigpio.pi class.
-
-OVERVIEW
-
-Essential
-
-pigpio.pi Initialise Pi connection
-stop Stop a Pi connection
-
-Beginner
-
-set_mode Set a GPIO mode
-get_mode Get a GPIO mode
-set_pull_up_down Set/clear GPIO pull up/down resistor
-
-read Read a GPIO
-write Write a GPIO
-
-set_PWM_dutycycle Start/stop PWM pulses on a GPIO
-get_PWM_dutycycle Get PWM dutycycle set on a GPIO
-
-set_servo_pulsewidth Start/Stop servo pulses on a GPIO
-get_servo_pulsewidth Get servo pulsewidth set on a GPIO
-
-callback Create GPIO level change callback
-wait_for_edge Wait for GPIO level change
-
-Intermediate
-
-gpio_trigger Send a trigger pulse to a GPIO
-
-set_watchdog Set a watchdog on a GPIO
-
-set_PWM_range Configure PWM range of a GPIO
-get_PWM_range Get configured PWM range of a GPIO
-
-set_PWM_frequency Set PWM frequency of a GPIO
-get_PWM_frequency Get PWM frequency of a GPIO
-
-read_bank_1 Read all bank 1 GPIO
-read_bank_2 Read all bank 2 GPIO
-
-clear_bank_1 Clear selected GPIO in bank 1
-clear_bank_2 Clear selected GPIO in bank 2
-
-set_bank_1 Set selected GPIO in bank 1
-set_bank_2 Set selected GPIO in bank 2
-
-Advanced
-
-get_PWM_real_range Get underlying PWM range for a GPIO
-
-notify_open Request a notification handle
-notify_begin Start notifications for selected GPIO
-notify_pause Pause notifications
-notify_close Close a notification
-
-bb_serial_read_open Open a GPIO for bit bang serial reads
-bb_serial_read Read bit bang serial data from a GPIO
-bb_serial_read_close Close a GPIO for bit bang serial reads
-bb_serial_invert Invert serial logic (1 invert, 0 normal)
-
-hardware_clock Start hardware clock on supported GPIO
-hardware_PWM Start hardware PWM on supported GPIO
-
-set_glitch_filter Set a glitch filter on a GPIO
-set_noise_filter Set a noise filter on a GPIO
-
-get_pad_strength Gets a pads drive strength
-set_pad_strength Sets a pads drive strength
-
-shell Executes a shell command
-
-Scripts
-
-store_script Store a script
-run_script Run a stored script
-script_status Get script status and parameters
-stop_script Stop a running script
-delete_script Delete a stored script
-
-Waves
-
-wave_clear Deletes all waveforms
-
-wave_add_new Starts a new waveform
-wave_add_generic Adds a series of pulses to the waveform
-wave_add_serial Adds serial data to the waveform
-
-wave_create Creates a waveform from added data
-wave_delete Deletes a waveform
-
-wave_send_once Transmits a waveform once
-wave_send_repeat Transmits a waveform repeatedly
-wave_send_using_mode Transmits a waveform in the chosen mode
-
-wave_chain Transmits a chain of waveforms
-
-wave_tx_at Returns the current transmitting waveform
-wave_tx_busy Checks to see if a waveform has ended
-wave_tx_stop Aborts the current waveform
-
-wave_get_micros Length in microseconds of the current waveform
-wave_get_max_micros Absolute maximum allowed micros
-wave_get_pulses Length in pulses of the current waveform
-wave_get_max_pulses Absolute maximum allowed pulses
-wave_get_cbs Length in cbs of the current waveform
-wave_get_max_cbs Absolute maximum allowed cbs
-
-I2C
-
-i2c_open Opens an I2C device
-i2c_close Closes an I2C device
-
-i2c_write_quick SMBus write quick
-i2c_write_byte SMBus write byte
-i2c_read_byte SMBus read byte
-i2c_write_byte_data SMBus write byte data
-i2c_write_word_data SMBus write word data
-i2c_read_byte_data SMBus read byte data
-i2c_read_word_data SMBus read word data
-i2c_process_call SMBus process call
-i2c_write_block_data SMBus write block data
-i2c_read_block_data SMBus read block data
-i2c_block_process_call SMBus block process call
-
-i2c_read_i2c_block_data SMBus read I2C block data
-i2c_write_i2c_block_data SMBus write I2C block data
-
-i2c_read_device Reads the raw I2C device
-i2c_write_device Writes the raw I2C device
-
-i2c_zip Performs multiple I2C transactions
-
-bb_i2c_open Opens GPIO for bit banging I2C
-bb_i2c_close Closes GPIO for bit banging I2C
-bb_i2c_zip Performs multiple bit banged I2C transactions
-
-SPI
-
-spi_open Opens a SPI device
-spi_close Closes a SPI device
-
-spi_read Reads bytes from a SPI device
-spi_write Writes bytes to a SPI device
-spi_xfer Transfers bytes with a SPI device
-
-bb_spi_open Opens GPIO for bit banging SPI
-bb_spi_close Closes GPIO for bit banging SPI
-bb_spi_xfer Transfers bytes with bit banging SPI
-
-Serial
-
-serial_open Opens a serial device
-serial_close Closes a serial device
-
-serial_read Reads bytes from a serial device
-serial_read_byte Reads a byte from a serial device
-
-serial_write Writes bytes to a serial device
-serial_write_byte Writes a byte to a serial device
-
-serial_data_available Returns number of bytes ready to be read
-
-Files
-
-file_open Opens a file
-file_close Closes a file
-file_read Reads bytes from a file
-file_write Writes bytes to a file
-file_seek Seeks to a position within a file
-file_list List files which match a pattern
-
-Custom
-
-custom_1 User custom function 1
-custom_2 User custom function 2
-
-Utility
-
-get_current_tick Get current tick (microseconds)
-
-get_hardware_revision Get hardware revision
-get_pigpio_version Get the pigpio version
-
-pigpio.error_text Gets error text from error number
-pigpio.tickDiff Returns difference between two ticks
-"""
-
-import sys
-import socket
-import struct
-import time
-import threading
-import os
-import atexit
-
-VERSION = "1.33"
-
-exceptions = True
-
-# GPIO levels
-
-OFF = 0
-LOW = 0
-CLEAR = 0
-
-ON = 1
-HIGH = 1
-SET = 1
-
-TIMEOUT = 2
-
-# GPIO edges
-
-RISING_EDGE = 0
-FALLING_EDGE = 1
-EITHER_EDGE = 2
-
-# GPIO modes
-
-INPUT = 0
-OUTPUT = 1
-ALT0 = 4
-ALT1 = 5
-ALT2 = 6
-ALT3 = 7
-ALT4 = 3
-ALT5 = 2
-
-# GPIO Pull Up Down
-
-PUD_OFF = 0
-PUD_DOWN = 1
-PUD_UP = 2
-
-# script run status
-
-PI_SCRIPT_INITING=0
-PI_SCRIPT_HALTED =1
-PI_SCRIPT_RUNNING=2
-PI_SCRIPT_WAITING=3
-PI_SCRIPT_FAILED =4
-
-# notification flags
-
-NTFY_FLAGS_ALIVE = (1 << 6)
-NTFY_FLAGS_WDOG = (1 << 5)
-NTFY_FLAGS_GPIO = 31
-
-# wave modes
-
-WAVE_MODE_ONE_SHOT =0
-WAVE_MODE_REPEAT =1
-WAVE_MODE_ONE_SHOT_SYNC=2
-WAVE_MODE_REPEAT_SYNC =3
-
-WAVE_NOT_FOUND = 9998 # Transmitted wave not found.
-NO_TX_WAVE = 9999 # No wave being transmitted.
-
-FILE_READ=1
-FILE_WRITE=2
-FILE_RW=3
-
-FILE_APPEND=4
-FILE_CREATE=8
-FILE_TRUNC=16
-
-FROM_START=0
-FROM_CURRENT=1
-FROM_END=2
-
-SPI_MODE_0 = 0
-SPI_MODE_1 = 1
-SPI_MODE_2 = 2
-SPI_MODE_3 = 3
-
-SPI_CPHA = 1 << 0
-SPI_CPOL = 1 << 1
-
-SPI_CS_HIGH_ACTIVE = 1 << 2
-
-SPI_TX_LSBFIRST = 1 << 14
-SPI_RX_LSBFIRST = 1 << 15
-
-# pigpio command numbers
-
-_PI_CMD_MODES= 0
-_PI_CMD_MODEG= 1
-_PI_CMD_PUD= 2
-_PI_CMD_READ= 3
-_PI_CMD_WRITE= 4
-_PI_CMD_PWM= 5
-_PI_CMD_PRS= 6
-_PI_CMD_PFS= 7
-_PI_CMD_SERVO= 8
-_PI_CMD_WDOG= 9
-_PI_CMD_BR1= 10
-_PI_CMD_BR2= 11
-_PI_CMD_BC1= 12
-_PI_CMD_BC2= 13
-_PI_CMD_BS1= 14
-_PI_CMD_BS2= 15
-_PI_CMD_TICK= 16
-_PI_CMD_HWVER=17
-
-_PI_CMD_NO= 18
-_PI_CMD_NB= 19
-_PI_CMD_NP= 20
-_PI_CMD_NC= 21
-
-_PI_CMD_PRG= 22
-_PI_CMD_PFG= 23
-_PI_CMD_PRRG= 24
-_PI_CMD_HELP= 25
-_PI_CMD_PIGPV=26
-
-_PI_CMD_WVCLR=27
-_PI_CMD_WVAG= 28
-_PI_CMD_WVAS= 29
-_PI_CMD_WVGO= 30
-_PI_CMD_WVGOR=31
-_PI_CMD_WVBSY=32
-_PI_CMD_WVHLT=33
-_PI_CMD_WVSM= 34
-_PI_CMD_WVSP= 35
-_PI_CMD_WVSC= 36
-
-_PI_CMD_TRIG= 37
-
-_PI_CMD_PROC= 38
-_PI_CMD_PROCD=39
-_PI_CMD_PROCR=40
-_PI_CMD_PROCS=41
-
-_PI_CMD_SLRO= 42
-_PI_CMD_SLR= 43
-_PI_CMD_SLRC= 44
-
-_PI_CMD_PROCP=45
-_PI_CMD_MICRO=46
-_PI_CMD_MILLI=47
-_PI_CMD_PARSE=48
-
-_PI_CMD_WVCRE=49
-_PI_CMD_WVDEL=50
-_PI_CMD_WVTX =51
-_PI_CMD_WVTXR=52
-_PI_CMD_WVNEW=53
-
-_PI_CMD_I2CO =54
-_PI_CMD_I2CC =55
-_PI_CMD_I2CRD=56
-_PI_CMD_I2CWD=57
-_PI_CMD_I2CWQ=58
-_PI_CMD_I2CRS=59
-_PI_CMD_I2CWS=60
-_PI_CMD_I2CRB=61
-_PI_CMD_I2CWB=62
-_PI_CMD_I2CRW=63
-_PI_CMD_I2CWW=64
-_PI_CMD_I2CRK=65
-_PI_CMD_I2CWK=66
-_PI_CMD_I2CRI=67
-_PI_CMD_I2CWI=68
-_PI_CMD_I2CPC=69
-_PI_CMD_I2CPK=70
-
-_PI_CMD_SPIO =71
-_PI_CMD_SPIC =72
-_PI_CMD_SPIR =73
-_PI_CMD_SPIW =74
-_PI_CMD_SPIX =75
-
-_PI_CMD_SERO =76
-_PI_CMD_SERC =77
-_PI_CMD_SERRB=78
-_PI_CMD_SERWB=79
-_PI_CMD_SERR =80
-_PI_CMD_SERW =81
-_PI_CMD_SERDA=82
-
-_PI_CMD_GDC =83
-_PI_CMD_GPW =84
-
-_PI_CMD_HC =85
-_PI_CMD_HP =86
-
-_PI_CMD_CF1 =87
-_PI_CMD_CF2 =88
-
-_PI_CMD_NOIB =99
-
-_PI_CMD_BI2CC=89
-_PI_CMD_BI2CO=90
-_PI_CMD_BI2CZ=91
-
-_PI_CMD_I2CZ =92
-
-_PI_CMD_WVCHA=93
-
-_PI_CMD_SLRI =94
-
-_PI_CMD_CGI =95
-_PI_CMD_CSI =96
-
-_PI_CMD_FG =97
-_PI_CMD_FN =98
-
-_PI_CMD_WVTXM=100
-_PI_CMD_WVTAT=101
-
-_PI_CMD_PADS =102
-_PI_CMD_PADG =103
-
-_PI_CMD_FO =104
-_PI_CMD_FC =105
-_PI_CMD_FR =106
-_PI_CMD_FW =107
-_PI_CMD_FS =108
-_PI_CMD_FL =109
-_PI_CMD_SHELL=110
-
-_PI_CMD_BSPIC=111
-_PI_CMD_BSPIO=112
-_PI_CMD_BSPIX=113
-
-# pigpio error numbers
-
-_PI_INIT_FAILED =-1
-PI_BAD_USER_GPIO =-2
-PI_BAD_GPIO =-3
-PI_BAD_MODE =-4
-PI_BAD_LEVEL =-5
-PI_BAD_PUD =-6
-PI_BAD_PULSEWIDTH =-7
-PI_BAD_DUTYCYCLE =-8
-_PI_BAD_TIMER =-9
-_PI_BAD_MS =-10
-_PI_BAD_TIMETYPE =-11
-_PI_BAD_SECONDS =-12
-_PI_BAD_MICROS =-13
-_PI_TIMER_FAILED =-14
-PI_BAD_WDOG_TIMEOUT =-15
-_PI_NO_ALERT_FUNC =-16
-_PI_BAD_CLK_PERIPH =-17
-_PI_BAD_CLK_SOURCE =-18
-_PI_BAD_CLK_MICROS =-19
-_PI_BAD_BUF_MILLIS =-20
-PI_BAD_DUTYRANGE =-21
-_PI_BAD_SIGNUM =-22
-_PI_BAD_PATHNAME =-23
-PI_NO_HANDLE =-24
-PI_BAD_HANDLE =-25
-_PI_BAD_IF_FLAGS =-26
-_PI_BAD_CHANNEL =-27
-_PI_BAD_PRIM_CHANNEL=-27
-_PI_BAD_SOCKET_PORT =-28
-_PI_BAD_FIFO_COMMAND=-29
-_PI_BAD_SECO_CHANNEL=-30
-_PI_NOT_INITIALISED =-31
-_PI_INITIALISED =-32
-_PI_BAD_WAVE_MODE =-33
-_PI_BAD_CFG_INTERNAL=-34
-PI_BAD_WAVE_BAUD =-35
-PI_TOO_MANY_PULSES =-36
-PI_TOO_MANY_CHARS =-37
-PI_NOT_SERIAL_GPIO =-38
-_PI_BAD_SERIAL_STRUC=-39
-_PI_BAD_SERIAL_BUF =-40
-PI_NOT_PERMITTED =-41
-PI_SOME_PERMITTED =-42
-PI_BAD_WVSC_COMMND =-43
-PI_BAD_WVSM_COMMND =-44
-PI_BAD_WVSP_COMMND =-45
-PI_BAD_PULSELEN =-46
-PI_BAD_SCRIPT =-47
-PI_BAD_SCRIPT_ID =-48
-PI_BAD_SER_OFFSET =-49
-PI_GPIO_IN_USE =-50
-PI_BAD_SERIAL_COUNT =-51
-PI_BAD_PARAM_NUM =-52
-PI_DUP_TAG =-53
-PI_TOO_MANY_TAGS =-54
-PI_BAD_SCRIPT_CMD =-55
-PI_BAD_VAR_NUM =-56
-PI_NO_SCRIPT_ROOM =-57
-PI_NO_MEMORY =-58
-PI_SOCK_READ_FAILED =-59
-PI_SOCK_WRIT_FAILED =-60
-PI_TOO_MANY_PARAM =-61
-PI_SCRIPT_NOT_READY =-62
-PI_BAD_TAG =-63
-PI_BAD_MICS_DELAY =-64
-PI_BAD_MILS_DELAY =-65
-PI_BAD_WAVE_ID =-66
-PI_TOO_MANY_CBS =-67
-PI_TOO_MANY_OOL =-68
-PI_EMPTY_WAVEFORM =-69
-PI_NO_WAVEFORM_ID =-70
-PI_I2C_OPEN_FAILED =-71
-PI_SER_OPEN_FAILED =-72
-PI_SPI_OPEN_FAILED =-73
-PI_BAD_I2C_BUS =-74
-PI_BAD_I2C_ADDR =-75
-PI_BAD_SPI_CHANNEL =-76
-PI_BAD_FLAGS =-77
-PI_BAD_SPI_SPEED =-78
-PI_BAD_SER_DEVICE =-79
-PI_BAD_SER_SPEED =-80
-PI_BAD_PARAM =-81
-PI_I2C_WRITE_FAILED =-82
-PI_I2C_READ_FAILED =-83
-PI_BAD_SPI_COUNT =-84
-PI_SER_WRITE_FAILED =-85
-PI_SER_READ_FAILED =-86
-PI_SER_READ_NO_DATA =-87
-PI_UNKNOWN_COMMAND =-88
-PI_SPI_XFER_FAILED =-89
-_PI_BAD_POINTER =-90
-PI_NO_AUX_SPI =-91
-PI_NOT_PWM_GPIO =-92
-PI_NOT_SERVO_GPIO =-93
-PI_NOT_HCLK_GPIO =-94
-PI_NOT_HPWM_GPIO =-95
-PI_BAD_HPWM_FREQ =-96
-PI_BAD_HPWM_DUTY =-97
-PI_BAD_HCLK_FREQ =-98
-PI_BAD_HCLK_PASS =-99
-PI_HPWM_ILLEGAL =-100
-PI_BAD_DATABITS =-101
-PI_BAD_STOPBITS =-102
-PI_MSG_TOOBIG =-103
-PI_BAD_MALLOC_MODE =-104
-_PI_TOO_MANY_SEGS =-105
-_PI_BAD_I2C_SEG =-106
-PI_BAD_SMBUS_CMD =-107
-PI_NOT_I2C_GPIO =-108
-PI_BAD_I2C_WLEN =-109
-PI_BAD_I2C_RLEN =-110
-PI_BAD_I2C_CMD =-111
-PI_BAD_I2C_BAUD =-112
-PI_CHAIN_LOOP_CNT =-113
-PI_BAD_CHAIN_LOOP =-114
-PI_CHAIN_COUNTER =-115
-PI_BAD_CHAIN_CMD =-116
-PI_BAD_CHAIN_DELAY =-117
-PI_CHAIN_NESTING =-118
-PI_CHAIN_TOO_BIG =-119
-PI_DEPRECATED =-120
-PI_BAD_SER_INVERT =-121
-_PI_BAD_EDGE =-122
-_PI_BAD_ISR_INIT =-123
-PI_BAD_FOREVER =-124
-PI_BAD_FILTER =-125
-PI_BAD_PAD =-126
-PI_BAD_STRENGTH =-127
-PI_FIL_OPEN_FAILED =-128
-PI_BAD_FILE_MODE =-129
-PI_BAD_FILE_FLAG =-130
-PI_BAD_FILE_READ =-131
-PI_BAD_FILE_WRITE =-132
-PI_FILE_NOT_ROPEN =-133
-PI_FILE_NOT_WOPEN =-134
-PI_BAD_FILE_SEEK =-135
-PI_NO_FILE_MATCH =-136
-PI_NO_FILE_ACCESS =-137
-PI_FILE_IS_A_DIR =-138
-PI_BAD_SHELL_STATUS =-139
-PI_BAD_SCRIPT_NAME =-140
-PI_BAD_SPI_BAUD =-141
-PI_NOT_SPI_GPIO =-142
-
-# pigpio error text
-
-_errors=[
- [_PI_INIT_FAILED , "pigpio initialisation failed"],
- [PI_BAD_USER_GPIO , "GPIO not 0-31"],
- [PI_BAD_GPIO , "GPIO not 0-53"],
- [PI_BAD_MODE , "mode not 0-7"],
- [PI_BAD_LEVEL , "level not 0-1"],
- [PI_BAD_PUD , "pud not 0-2"],
- [PI_BAD_PULSEWIDTH , "pulsewidth not 0 or 500-2500"],
- [PI_BAD_DUTYCYCLE , "dutycycle not 0-range (default 255)"],
- [_PI_BAD_TIMER , "timer not 0-9"],
- [_PI_BAD_MS , "ms not 10-60000"],
- [_PI_BAD_TIMETYPE , "timetype not 0-1"],
- [_PI_BAD_SECONDS , "seconds < 0"],
- [_PI_BAD_MICROS , "micros not 0-999999"],
- [_PI_TIMER_FAILED , "gpioSetTimerFunc failed"],
- [PI_BAD_WDOG_TIMEOUT , "timeout not 0-60000"],
- [_PI_NO_ALERT_FUNC , "DEPRECATED"],
- [_PI_BAD_CLK_PERIPH , "clock peripheral not 0-1"],
- [_PI_BAD_CLK_SOURCE , "DEPRECATED"],
- [_PI_BAD_CLK_MICROS , "clock micros not 1, 2, 4, 5, 8, or 10"],
- [_PI_BAD_BUF_MILLIS , "buf millis not 100-10000"],
- [PI_BAD_DUTYRANGE , "dutycycle range not 25-40000"],
- [_PI_BAD_SIGNUM , "signum not 0-63"],
- [_PI_BAD_PATHNAME , "can't open pathname"],
- [PI_NO_HANDLE , "no handle available"],
- [PI_BAD_HANDLE , "unknown handle"],
- [_PI_BAD_IF_FLAGS , "ifFlags > 3"],
- [_PI_BAD_CHANNEL , "DMA channel not 0-14"],
- [_PI_BAD_SOCKET_PORT , "socket port not 1024-30000"],
- [_PI_BAD_FIFO_COMMAND , "unknown fifo command"],
- [_PI_BAD_SECO_CHANNEL , "DMA secondary channel not 0-14"],
- [_PI_NOT_INITIALISED , "function called before gpioInitialise"],
- [_PI_INITIALISED , "function called after gpioInitialise"],
- [_PI_BAD_WAVE_MODE , "waveform mode not 0-1"],
- [_PI_BAD_CFG_INTERNAL , "bad parameter in gpioCfgInternals call"],
- [PI_BAD_WAVE_BAUD , "baud rate not 50-250000(RX)/1000000(TX)"],
- [PI_TOO_MANY_PULSES , "waveform has too many pulses"],
- [PI_TOO_MANY_CHARS , "waveform has too many chars"],
- [PI_NOT_SERIAL_GPIO , "no bit bang serial read in progress on GPIO"],
- [PI_NOT_PERMITTED , "no permission to update GPIO"],
- [PI_SOME_PERMITTED , "no permission to update one or more GPIO"],
- [PI_BAD_WVSC_COMMND , "bad WVSC subcommand"],
- [PI_BAD_WVSM_COMMND , "bad WVSM subcommand"],
- [PI_BAD_WVSP_COMMND , "bad WVSP subcommand"],
- [PI_BAD_PULSELEN , "trigger pulse length not 1-100"],
- [PI_BAD_SCRIPT , "invalid script"],
- [PI_BAD_SCRIPT_ID , "unknown script id"],
- [PI_BAD_SER_OFFSET , "add serial data offset > 30 minute"],
- [PI_GPIO_IN_USE , "GPIO already in use"],
- [PI_BAD_SERIAL_COUNT , "must read at least a byte at a time"],
- [PI_BAD_PARAM_NUM , "script parameter id not 0-9"],
- [PI_DUP_TAG , "script has duplicate tag"],
- [PI_TOO_MANY_TAGS , "script has too many tags"],
- [PI_BAD_SCRIPT_CMD , "illegal script command"],
- [PI_BAD_VAR_NUM , "script variable id not 0-149"],
- [PI_NO_SCRIPT_ROOM , "no more room for scripts"],
- [PI_NO_MEMORY , "can't allocate temporary memory"],
- [PI_SOCK_READ_FAILED , "socket read failed"],
- [PI_SOCK_WRIT_FAILED , "socket write failed"],
- [PI_TOO_MANY_PARAM , "too many script parameters (> 10)"],
- [PI_SCRIPT_NOT_READY , "script initialising"],
- [PI_BAD_TAG , "script has unresolved tag"],
- [PI_BAD_MICS_DELAY , "bad MICS delay (too large)"],
- [PI_BAD_MILS_DELAY , "bad MILS delay (too large)"],
- [PI_BAD_WAVE_ID , "non existent wave id"],
- [PI_TOO_MANY_CBS , "No more CBs for waveform"],
- [PI_TOO_MANY_OOL , "No more OOL for waveform"],
- [PI_EMPTY_WAVEFORM , "attempt to create an empty waveform"],
- [PI_NO_WAVEFORM_ID , "No more waveform ids"],
- [PI_I2C_OPEN_FAILED , "can't open I2C device"],
- [PI_SER_OPEN_FAILED , "can't open serial device"],
- [PI_SPI_OPEN_FAILED , "can't open SPI device"],
- [PI_BAD_I2C_BUS , "bad I2C bus"],
- [PI_BAD_I2C_ADDR , "bad I2C address"],
- [PI_BAD_SPI_CHANNEL , "bad SPI channel"],
- [PI_BAD_FLAGS , "bad i2c/spi/ser open flags"],
- [PI_BAD_SPI_SPEED , "bad SPI speed"],
- [PI_BAD_SER_DEVICE , "bad serial device name"],
- [PI_BAD_SER_SPEED , "bad serial baud rate"],
- [PI_BAD_PARAM , "bad i2c/spi/ser parameter"],
- [PI_I2C_WRITE_FAILED , "I2C write failed"],
- [PI_I2C_READ_FAILED , "I2C read failed"],
- [PI_BAD_SPI_COUNT , "bad SPI count"],
- [PI_SER_WRITE_FAILED , "ser write failed"],
- [PI_SER_READ_FAILED , "ser read failed"],
- [PI_SER_READ_NO_DATA , "ser read no data available"],
- [PI_UNKNOWN_COMMAND , "unknown command"],
- [PI_SPI_XFER_FAILED , "SPI xfer/read/write failed"],
- [_PI_BAD_POINTER , "bad (NULL) pointer"],
- [PI_NO_AUX_SPI , "no auxiliary SPI on Pi A or B"],
- [PI_NOT_PWM_GPIO , "GPIO is not in use for PWM"],
- [PI_NOT_SERVO_GPIO , "GPIO is not in use for servo pulses"],
- [PI_NOT_HCLK_GPIO , "GPIO has no hardware clock"],
- [PI_NOT_HPWM_GPIO , "GPIO has no hardware PWM"],
- [PI_BAD_HPWM_FREQ , "hardware PWM frequency not 1-125M"],
- [PI_BAD_HPWM_DUTY , "hardware PWM dutycycle not 0-1M"],
- [PI_BAD_HCLK_FREQ , "hardware clock frequency not 4689-250M"],
- [PI_BAD_HCLK_PASS , "need password to use hardware clock 1"],
- [PI_HPWM_ILLEGAL , "illegal, PWM in use for main clock"],
- [PI_BAD_DATABITS , "serial data bits not 1-32"],
- [PI_BAD_STOPBITS , "serial (half) stop bits not 2-8"],
- [PI_MSG_TOOBIG , "socket/pipe message too big"],
- [PI_BAD_MALLOC_MODE , "bad memory allocation mode"],
- [_PI_TOO_MANY_SEGS , "too many I2C transaction segments"],
- [_PI_BAD_I2C_SEG , "an I2C transaction segment failed"],
- [PI_BAD_SMBUS_CMD , "SMBus command not supported"],
- [PI_NOT_I2C_GPIO , "no bit bang I2C in progress on GPIO"],
- [PI_BAD_I2C_WLEN , "bad I2C write length"],
- [PI_BAD_I2C_RLEN , "bad I2C read length"],
- [PI_BAD_I2C_CMD , "bad I2C command"],
- [PI_BAD_I2C_BAUD , "bad I2C baud rate, not 50-500k"],
- [PI_CHAIN_LOOP_CNT , "bad chain loop count"],
- [PI_BAD_CHAIN_LOOP , "empty chain loop"],
- [PI_CHAIN_COUNTER , "too many chain counters"],
- [PI_BAD_CHAIN_CMD , "bad chain command"],
- [PI_BAD_CHAIN_DELAY , "bad chain delay micros"],
- [PI_CHAIN_NESTING , "chain counters nested too deeply"],
- [PI_CHAIN_TOO_BIG , "chain is too long"],
- [PI_DEPRECATED , "deprecated function removed"],
- [PI_BAD_SER_INVERT , "bit bang serial invert not 0 or 1"],
- [_PI_BAD_EDGE , "bad ISR edge value, not 0-2"],
- [_PI_BAD_ISR_INIT , "bad ISR initialisation"],
- [PI_BAD_FOREVER , "loop forever must be last chain command"],
- [PI_BAD_FILTER , "bad filter parameter"],
- [PI_BAD_PAD , "bad pad number"],
- [PI_BAD_STRENGTH , "bad pad drive strength"],
- [PI_FIL_OPEN_FAILED , "file open failed"],
- [PI_BAD_FILE_MODE , "bad file mode"],
- [PI_BAD_FILE_FLAG , "bad file flag"],
- [PI_BAD_FILE_READ , "bad file read"],
- [PI_BAD_FILE_WRITE , "bad file write"],
- [PI_FILE_NOT_ROPEN , "file not open for read"],
- [PI_FILE_NOT_WOPEN , "file not open for write"],
- [PI_BAD_FILE_SEEK , "bad file seek"],
- [PI_NO_FILE_MATCH , "no files match pattern"],
- [PI_NO_FILE_ACCESS , "no permission to access file"],
- [PI_FILE_IS_A_DIR , "file is a directory"],
- [PI_BAD_SHELL_STATUS , "bad shell return status"],
- [PI_BAD_SCRIPT_NAME , "bad script name"],
- [PI_BAD_SPI_BAUD , "bad SPI baud rate, not 50-500k"],
- [PI_NOT_SPI_GPIO , "no bit bang SPI in progress on GPIO"],
-]
-
-except_a = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n{}"
-
-except_z = "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-
-except1 = """
-Did you start the pigpio daemon? E.g. sudo pigpiod
-
-Did you specify the correct Pi host/port in the environment
-variables PIGPIO_ADDR/PIGPIO_PORT?
-E.g. export PIGPIO_ADDR=soft, export PIGPIO_PORT=8888
-
-Did you specify the correct Pi host/port in the
-pigpio.pi() function? E.g. pigpio.pi('soft', 8888)"""
-
-except2 = """
-Do you have permission to access the pigpio daemon?
-Perhaps it was started with sudo pigpiod -nlocalhost"""
-
-class _socklock:
- """
- A class to store socket and lock.
- """
- def __init__(self):
- self.s = None
- self.l = threading.Lock()
-
-class error(Exception):
- """pigpio module exception"""
- def __init__(self, value):
- self.value = value
- def __str__(self):
- return repr(self.value)
-
-class pulse:
- """
- A class to store pulse information.
- """
-
- def __init__(self, gpio_on, gpio_off, delay):
- """
- Initialises a pulse.
-
- gpio_on:= the GPIO to switch on at the start of the pulse.
- gpio_off:= the GPIO to switch off at the start of the pulse.
- delay:= the delay in microseconds before the next pulse.
-
- """
- self.gpio_on = gpio_on
- self.gpio_off = gpio_off
- self.delay = delay
-
-def error_text(errnum):
- """
- Returns a text description of a pigpio error.
-
- errnum:= <0, the error number
-
- ...
- print(pigpio.error_text(-5))
- level not 0-1
- ...
- """
- for e in _errors:
- if e[0] == errnum:
- return e[1]
- return "unknown error ({})".format(errnum)
-
-def tickDiff(t1, t2):
- """
- Returns the microsecond difference between two ticks.
-
- t1:= the earlier tick
- t2:= the later tick
-
- ...
- print(pigpio.tickDiff(4294967272, 12))
- 36
- ...
- """
- tDiff = t2 - t1
- if tDiff < 0:
- tDiff += (1 << 32)
- return tDiff
-
-# A couple of hacks to cope with different string handling
-# between various Python versions
-# 3 != 2.7.8 != 2.7.3
-
-if sys.hexversion < 0x03000000:
- def _b(x):
- return x
-else:
- def _b(x):
- return x.encode('latin-1')
-
-if sys.hexversion < 0x02070800:
- def _str(x):
- return buffer(x)
-else:
- def _str(x):
- return x
-
-def u2i(uint32):
- """
- Converts a 32 bit unsigned number to signed.
-
- uint32:= an unsigned 32 bit number
-
- ...
- print(u2i(4294967272))
- -24
- print(u2i(37))
- 37
- ...
- """
- mask = (2 ** 32) - 1
- if uint32 & (1 << 31):
- v = uint32 | ~mask
- else:
- v = uint32 & mask
- return v
-
-def _u2i(uint32):
- """
- Converts a 32 bit unsigned number to signed. If the number
- is negative it indicates an error. On error a pigpio
- exception will be raised if exceptions is True.
- """
- v = u2i(uint32)
- if v < 0:
- if exceptions:
- raise error(error_text(v))
- return v
-
-def _pigpio_command(sl, cmd, p1, p2, rl=True):
- """
- Runs a pigpio socket command.
-
- sl:= command socket and lock.
- cmd:= the command to be executed.
- p1:= command parameter 1 (if applicable).
- p2:= command parameter 2 (if applicable).
- """
- sl.l.acquire()
- sl.s.send(struct.pack('IIII', cmd, p1, p2, 0))
- dummy, res = struct.unpack('12sI', sl.s.recv(16))
- if rl: sl.l.release()
- return res
-
-def _pigpio_command_ext(sl, cmd, p1, p2, p3, extents, rl=True):
- """
- Runs an extended pigpio socket command.
-
- sl:= command socket and lock.
- cmd:= the command to be executed.
- p1:= command parameter 1 (if applicable).
- p2:= command parameter 2 (if applicable).
- p3:= total size in bytes of following extents
- extents:= additional data blocks
- """
- ext = bytearray(struct.pack('IIII', cmd, p1, p2, p3))
- for x in extents:
- if type(x) == type(""):
- ext.extend(_b(x))
- else:
- ext.extend(x)
- sl.l.acquire()
- sl.s.sendall(ext)
- dummy, res = struct.unpack('12sI', sl.s.recv(16))
- if rl: sl.l.release()
- return res
-
-class _callback_ADT:
- """An ADT class to hold callback information."""
-
- def __init__(self, gpio, edge, func):
- """
- Initialises a callback ADT.
-
- gpio:= Broadcom GPIO number.
- edge:= EITHER_EDGE, RISING_EDGE, or FALLING_EDGE.
- func:= a user function taking three arguments (GPIO, level, tick).
- """
- self.gpio = gpio
- self.edge = edge
- self.func = func
- self.bit = 1<=0 Hz
-
- Returns the numerically closest frequency if OK, otherwise
- PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-
- If PWM is currently active on the GPIO it will be switched
- off and then back on at the new frequency.
-
- Each GPIO can be independently set to one of 18 different
- PWM frequencies.
-
- The selectable frequencies depend upon the sample rate which
- may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
- sample rate is set when the pigpio daemon is started.
-
- The frequencies for each sample rate are:
-
- . .
- Hertz
-
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
- 1250 1000 800 500 400 250 200 100 50
-
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
- 625 500 400 250 200 125 100 50 25
-
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
- 313 250 200 125 100 63 50 25 13
- sample
- rate
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
- 250 200 160 100 80 50 40 20 10
-
- 8: 5000 2500 1250 1000 625 500 313 250 200
- 156 125 100 63 50 31 25 13 6
-
- 10: 4000 2000 1000 800 500 400 250 200 160
- 125 100 80 50 40 25 20 10 5
- . .
-
- ...
- pi.set_PWM_frequency(4,0)
- print(pi.get_PWM_frequency(4))
- 10
-
- pi.set_PWM_frequency(4,100000)
- print(pi.get_PWM_frequency(4))
- 8000
- ...
- """
- return _u2i(
- _pigpio_command(self.sl, _PI_CMD_PFS, user_gpio, frequency))
-
- def get_PWM_frequency(self, user_gpio):
- """
- Returns the frequency of PWM being used on the GPIO.
-
- user_gpio:= 0-31.
-
- Returns the frequency (in Hz) used for the GPIO.
-
- For normal PWM the frequency will be that defined for the GPIO
- by [*set_PWM_frequency*].
-
- If a hardware clock is active on the GPIO the reported frequency
- will be that set by [*hardware_clock*].
-
- If hardware PWM is active on the GPIO the reported frequency
- will be that set by [*hardware_PWM*].
-
- ...
- pi.set_PWM_frequency(4,0)
- print(pi.get_PWM_frequency(4))
- 10
-
- pi.set_PWM_frequency(4, 800)
- print(pi.get_PWM_frequency(4))
- 800
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_PFG, user_gpio, 0))
-
- def set_servo_pulsewidth(self, user_gpio, pulsewidth):
- """
- Starts (500-2500) or stops (0) servo pulses on the GPIO.
-
- user_gpio:= 0-31.
- pulsewidth:= 0 (off),
- 500 (most anti-clockwise) - 2500 (most clockwise).
-
- The selected pulsewidth will continue to be transmitted until
- changed by a subsequent call to set_servo_pulsewidth.
-
- The pulsewidths supported by servos varies and should probably
- be determined by experiment. A value of 1500 should always be
- safe and represents the mid-point of rotation.
-
- You can DAMAGE a servo if you command it to move beyond its
- limits.
-
- ...
- pi.set_servo_pulsewidth(17, 0) # off
- pi.set_servo_pulsewidth(17, 1000) # safe anti-clockwise
- pi.set_servo_pulsewidth(17, 1500) # centre
- pi.set_servo_pulsewidth(17, 2000) # safe clockwise
- ...
- """
- return _u2i(_pigpio_command(
- self.sl, _PI_CMD_SERVO, user_gpio, int(pulsewidth)))
-
- def get_servo_pulsewidth(self, user_gpio):
- """
- Returns the servo pulsewidth being used on the GPIO.
-
- user_gpio:= 0-31.
-
- Returns the servo pulsewidth.
-
- ...
- pi.set_servo_pulsewidth(4, 525)
- print(pi.get_servo_pulsewidth(4))
- 525
-
- pi.set_servo_pulsewidth(4, 2130)
- print(pi.get_servo_pulsewidth(4))
- 2130
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_GPW, user_gpio, 0))
-
- def notify_open(self):
- """
- Returns a notification handle (>=0).
-
- A notification is a method for being notified of GPIO state
- changes via a pipe.
-
- Pipes are only accessible from the local machine so this
- function serves no purpose if you are using Python from a
- remote machine. The in-built (socket) notifications
- provided by [*callback*] should be used instead.
-
- Notifications for handle x will be available at the pipe
- named /dev/pigpiox (where x is the handle number).
-
- E.g. if the function returns 15 then the notifications must be
- read from /dev/pigpio15.
-
- Notifications have the following structure.
-
- . .
- H seqno
- H flags
- I tick
- I level
- . .
-
- seqno: starts at 0 each time the handle is opened and then
- increments by one for each report.
-
- flags: two flags are defined, PI_NTFY_FLAGS_WDOG and
- PI_NTFY_FLAGS_ALIVE.
-
- PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the
- flags indicate a GPIO which has had a watchdog timeout.
-
- PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep
- alive signal on the pipe/socket and is sent once a minute
- in the absence of other notification activity.
-
- tick: the number of microseconds since system boot. It wraps
- around after 1h12m.
-
- level: indicates the level of each GPIO. If bit 1<= 0:
- pi.notify_begin(h, 1234)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_NO, 0, 0))
-
- def notify_begin(self, handle, bits):
- """
- Starts notifications on a handle.
-
- handle:= >=0 (as returned by a prior call to [*notify_open*])
- bits:= a 32 bit mask indicating the GPIO to be notified.
-
- The notification sends state changes for each GPIO whose
- corresponding bit in bits is set.
-
- The following code starts notifications for GPIO 1, 4,
- 6, 7, and 10 (1234 = 0x04D2 = 0b0000010011010010).
-
- ...
- h = pi.notify_open()
- if h >= 0:
- pi.notify_begin(h, 1234)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_NB, handle, bits))
-
- def notify_pause(self, handle):
- """
- Pauses notifications on a handle.
-
- handle:= >=0 (as returned by a prior call to [*notify_open*])
-
- Notifications for the handle are suspended until
- [*notify_begin*] is called again.
-
- ...
- h = pi.notify_open()
- if h >= 0:
- pi.notify_begin(h, 1234)
- ...
- pi.notify_pause(h)
- ...
- pi.notify_begin(h, 1234)
- ...
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_NB, handle, 0))
-
- def notify_close(self, handle):
- """
- Stops notifications on a handle and releases the handle for reuse.
-
- handle:= >=0 (as returned by a prior call to [*notify_open*])
-
- ...
- h = pi.notify_open()
- if h >= 0:
- pi.notify_begin(h, 1234)
- ...
- pi.notify_close(h)
- ...
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_NC, handle, 0))
-
- def set_watchdog(self, user_gpio, wdog_timeout):
- """
- Sets a watchdog timeout for a GPIO.
-
- user_gpio:= 0-31.
- wdog_timeout:= 0-60000.
-
- The watchdog is nominally in milliseconds.
-
- Only one watchdog may be registered per GPIO.
-
- The watchdog may be cancelled by setting timeout to 0.
-
- If no level change has been detected for the GPIO for timeout
- milliseconds any notification for the GPIO has a report written
- to the fifo with the flags set to indicate a watchdog timeout.
-
- The callback class interprets the flags and will
- call registered callbacks for the GPIO with level TIMEOUT.
-
- ...
- pi.set_watchdog(23, 1000) # 1000 ms watchdog on GPIO 23
- pi.set_watchdog(23, 0) # cancel watchdog on GPIO 23
- ...
- """
- return _u2i(_pigpio_command(
- self.sl, _PI_CMD_WDOG, user_gpio, int(wdog_timeout)))
-
- def read_bank_1(self):
- """
- Returns the levels of the bank 1 GPIO (GPIO 0-31).
-
- The returned 32 bit integer has a bit set if the corresponding
- GPIO is high. GPIO n has bit value (1<=0) if OK, otherwise PI_EMPTY_WAVEFORM,
- PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
-
- The data provided by the [*wave_add_**] functions is consumed by
- this function.
-
- As many waveforms may be created as there is space available.
- The wave id is passed to [*wave_send_**] to specify the waveform
- to transmit.
-
- Normal usage would be
-
- Step 1. [*wave_clear*] to clear all waveforms and added data.
-
- Step 2. [*wave_add_**] calls to supply the waveform data.
-
- Step 3. [*wave_create*] to create the waveform and get a unique id
-
- Repeat steps 2 and 3 as needed.
-
- Step 4. [*wave_send_**] with the id of the waveform to transmit.
-
- A waveform comprises one or more pulses.
-
- A pulse specifies
-
- 1) the GPIO to be switched on at the start of the pulse.
- 2) the GPIO to be switched off at the start of the pulse.
- 3) the delay in microseconds before the next pulse.
-
- Any or all the fields can be zero. It doesn't make any sense
- to set all the fields to zero (the pulse will be ignored).
-
- When a waveform is started each pulse is executed in order with
- the specified delay between the pulse and the next.
-
- ...
- wid = pi.wave_create()
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVCRE, 0, 0))
-
- def wave_delete(self, wave_id):
- """
- This function deletes the waveform with id wave_id.
-
- wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
-
- Wave ids are allocated in order, 0, 1, 2, etc.
-
- ...
- pi.wave_delete(6) # delete waveform with id 6
-
- pi.wave_delete(0) # delete waveform with id 0
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVDEL, wave_id, 0))
-
- def wave_tx_start(self): # DEPRECATED
- """
- This function is deprecated and has been removed.
-
- Use [*wave_create*]/[*wave_send_**] instead.
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVGO, 0, 0))
-
- def wave_tx_repeat(self): # DEPRECATED
- """
- This function is deprecated and has beeen removed.
-
- Use [*wave_create*]/[*wave_send_**] instead.
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVGOR, 0, 0))
-
- def wave_send_once(self, wave_id):
- """
- Transmits the waveform with id wave_id. The waveform is sent
- once.
-
- NOTE: Any hardware PWM started by [*hardware_PWM*] will
- be cancelled.
-
- wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
-
- Returns the number of DMA control blocks used in the waveform.
-
- ...
- cbs = pi.wave_send_once(wid)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTX, wave_id, 0))
-
- def wave_send_repeat(self, wave_id):
- """
- Transmits the waveform with id wave_id. The waveform repeats
- until wave_tx_stop is called or another call to [*wave_send_**]
- is made.
-
- NOTE: Any hardware PWM started by [*hardware_PWM*] will
- be cancelled.
-
- wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
-
- Returns the number of DMA control blocks used in the waveform.
-
- ...
- cbs = pi.wave_send_repeat(wid)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXR, wave_id, 0))
-
- def wave_send_using_mode(self, wave_id, mode):
- """
- Transmits the waveform with id wave_id using mode mode.
-
- wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
- mode:= WAVE_MODE_ONE_SHOT, WAVE_MODE_REPEAT,
- WAVE_MODE_ONE_SHOT_SYNC, or WAVE_MODE_REPEAT_SYNC.
-
- WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
-
- WAVE_MODE_REPEAT same as [*wave_send_repeat*].
-
- WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
- to sync with the previous waveform.
-
- WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
- to sync with the previous waveform.
-
- WARNING: bad things may happen if you delete the previous
- waveform before it has been synced to the new waveform.
-
- NOTE: Any hardware PWM started by [*hardware_PWM*] will
- be cancelled.
-
- wave_id:= >=0 (as returned by a prior call to [*wave_create*]).
-
- Returns the number of DMA control blocks used in the waveform.
-
- ...
- cbs = pi.wave_send_using_mode(wid, WAVE_MODE_REPEAT_SYNC)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTXM, wave_id, mode))
-
- def wave_tx_at(self):
- """
- Returns the id of the waveform currently being
- transmitted.
-
- Returns the waveform id or one of the following special
- values:
-
- WAVE_NOT_FOUND (9998) - transmitted wave not found.
- NO_TX_WAVE (9999) - no wave being transmitted.
-
- ...
- wid = pi.wave_tx_at()
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVTAT, 0, 0))
-
- def wave_tx_busy(self):
- """
- Returns 1 if a waveform is currently being transmitted,
- otherwise 0.
-
- ...
- pi.wave_send_once(0) # send first waveform
-
- while pi.wave_tx_busy(): # wait for waveform to be sent
- time.sleep(0.1)
-
- pi.wave_send_once(1) # send next waveform
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVBSY, 0, 0))
-
- def wave_tx_stop(self):
- """
- Stops the transmission of the current waveform.
-
- This function is intended to stop a waveform started with
- wave_send_repeat.
-
- ...
- pi.wave_send_repeat(3)
-
- time.sleep(5)
-
- pi.wave_tx_stop()
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_WVHLT, 0, 0))
-
- def wave_chain(self, data):
- """
- This function transmits a chain of waveforms.
-
- NOTE: Any hardware PWM started by [*hardware_PWM*]
- will be cancelled.
-
- The waves to be transmitted are specified by the contents
- of data which contains an ordered list of [*wave_id*]s
- and optional command codes and related data.
-
- Returns 0 if OK, otherwise PI_CHAIN_NESTING,
- PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD,
- PI_CHAIN_COUNTER, PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG,
- or PI_BAD_WAVE_ID.
-
- Each wave is transmitted in the order specified. A wave
- may occur multiple times per chain.
-
- A blocks of waves may be transmitted multiple times by
- using the loop commands. The block is bracketed by loop
- start and end commands. Loops may be nested.
-
- Delays between waves may be added with the delay command.
-
- The following command codes are supported:
-
- Name @ Cmd & Data @ Meaning
- Loop Start @ 255 0 @ Identify start of a wave block
- Loop Repeat @ 255 1 x y @ loop x + y*256 times
- Delay @ 255 2 x y @ delay x + y*256 microseconds
- Loop Forever @ 255 3 @ loop forever
-
- If present Loop Forever must be the last entry in the chain.
-
- The code is currently dimensioned to support a chain with
- roughly 600 entries and 20 loop counters.
-
- ...
- #!/usr/bin/env python
-
- import time
- import pigpio
-
- WAVES=5
- GPIO=4
-
- wid=[0]*WAVES
-
- pi = pigpio.pi() # Connect to local Pi.
-
- pi.set_mode(GPIO, pigpio.OUTPUT);
-
- for i in range(WAVES):
- pi.wave_add_generic([
- pigpio.pulse(1<=0) for the device at the I2C bus address.
-
- i2c_bus:= >=0.
- i2c_address:= 0-0x7F.
- i2c_flags:= 0, no flags are currently defined.
-
- Normally you would only use the [*i2c_**] functions if
- you are or will be connecting to the Pi over a network. If
- you will always run on the local Pi use the standard SMBus
- module instead.
-
- Physically buses 0 and 1 are available on the Pi. Higher
- numbered buses will be available if a kernel supported bus
- multiplexor is being used.
-
- For the SMBus commands the low level transactions are shown
- at the end of the function description. The following
- abbreviations are used.
-
- . .
- S (1 bit) : Start bit
- P (1 bit) : Stop bit
- Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
- A, NA (1 bit) : Accept and not accept bit.
- Addr (7 bits): I2C 7 bit address.
- reg (8 bits): Command byte, which often selects a register.
- Data (8 bits): A data byte.
- Count (8 bits): A byte defining the length of a block operation.
-
- [..]: Data sent by the device.
- . .
-
- ...
- h = pi.i2c_open(1, 0x53) # open device at address 0x53 on bus 1
- ...
- """
- # I p1 i2c_bus
- # I p2 i2c_addr
- # I p3 4
- ## extension ##
- # I i2c_flags
- extents = [struct.pack("I", i2c_flags)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CO, i2c_bus, i2c_address, 4, extents))
-
- def i2c_close(self, handle):
- """
- Closes the I2C device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
-
- ...
- pi.i2c_close(h)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CC, handle, 0))
-
- def i2c_write_quick(self, handle, bit):
- """
- Sends a single bit to the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- bit:= 0 or 1, the value to write.
-
- SMBus 2.0 5.5.1 - Quick command.
- . .
- S Addr bit [A] P
- . .
-
- ...
- pi.i2c_write_quick(0, 1) # send 1 to device 0
- pi.i2c_write_quick(3, 0) # send 0 to device 3
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CWQ, handle, bit))
-
- def i2c_write_byte(self, handle, byte_val):
- """
- Sends a single byte to the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- byte_val:= 0-255, the value to write.
-
- SMBus 2.0 5.5.2 - Send byte.
- . .
- S Addr Wr [A] byte_val [A] P
- . .
-
- ...
- pi.i2c_write_byte(1, 17) # send byte 17 to device 1
- pi.i2c_write_byte(2, 0x23) # send byte 0x23 to device 2
- ...
- """
- return _u2i(
- _pigpio_command(self.sl, _PI_CMD_I2CWS, handle, byte_val))
-
- def i2c_read_byte(self, handle):
- """
- Reads a single byte from the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
-
- SMBus 2.0 5.5.3 - Receive byte.
- . .
- S Addr Rd [A] [Data] NA P
- . .
-
- ...
- b = pi.i2c_read_byte(2) # read a byte from device 2
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRS, handle, 0))
-
- def i2c_write_byte_data(self, handle, reg, byte_val):
- """
- Writes a single byte to the specified register of the device
- associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- byte_val:= 0-255, the value to write.
-
- SMBus 2.0 5.5.4 - Write byte.
- . .
- S Addr Wr [A] reg [A] byte_val [A] P
- . .
-
- ...
- # send byte 0xC5 to reg 2 of device 1
- pi.i2c_write_byte_data(1, 2, 0xC5)
-
- # send byte 9 to reg 4 of device 2
- pi.i2c_write_byte_data(2, 4, 9)
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 4
- ## extension ##
- # I byte_val
- extents = [struct.pack("I", byte_val)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CWB, handle, reg, 4, extents))
-
- def i2c_write_word_data(self, handle, reg, word_val):
- """
- Writes a single 16 bit word to the specified register of the
- device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- word_val:= 0-65535, the value to write.
-
- SMBus 2.0 5.5.4 - Write word.
- . .
- S Addr Wr [A] reg [A] word_val_Low [A] word_val_High [A] P
- . .
-
- ...
- # send word 0xA0C5 to reg 5 of device 4
- pi.i2c_write_word_data(4, 5, 0xA0C5)
-
- # send word 2 to reg 2 of device 5
- pi.i2c_write_word_data(5, 2, 23)
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 4
- ## extension ##
- # I word_val
- extents = [struct.pack("I", word_val)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CWW, handle, reg, 4, extents))
-
- def i2c_read_byte_data(self, handle, reg):
- """
- Reads a single byte from the specified register of the device
- associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
-
- SMBus 2.0 5.5.5 - Read byte.
- . .
- S Addr Wr [A] reg [A] S Addr Rd [A] [Data] NA P
- . .
-
- ...
- # read byte from reg 17 of device 2
- b = pi.i2c_read_byte_data(2, 17)
-
- # read byte from reg 1 of device 0
- b = pi.i2c_read_byte_data(0, 1)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRB, handle, reg))
-
- def i2c_read_word_data(self, handle, reg):
- """
- Reads a single 16 bit word from the specified register of the
- device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
-
- SMBus 2.0 5.5.5 - Read word.
- . .
- S Addr Wr [A] reg [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
- . .
-
- ...
- # read word from reg 2 of device 3
- w = pi.i2c_read_word_data(3, 2)
-
- # read word from reg 7 of device 2
- w = pi.i2c_read_word_data(2, 7)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_I2CRW, handle, reg))
-
- def i2c_process_call(self, handle, reg, word_val):
- """
- Writes 16 bits of data to the specified register of the device
- associated with handle and reads 16 bits of data in return.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- word_val:= 0-65535, the value to write.
-
- SMBus 2.0 5.5.6 - Process call.
- . .
- S Addr Wr [A] reg [A] word_val_Low [A] word_val_High [A]
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
- . .
-
- ...
- r = pi.i2c_process_call(h, 4, 0x1231)
- r = pi.i2c_process_call(h, 6, 0)
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 4
- ## extension ##
- # I word_val
- extents = [struct.pack("I", word_val)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CPC, handle, reg, 4, extents))
-
- def i2c_write_block_data(self, handle, reg, data):
- """
- Writes up to 32 bytes to the specified register of the device
- associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- data:= the bytes to write.
-
- SMBus 2.0 5.5.7 - Block write.
- . .
- S Addr Wr [A] reg [A] len(data) [A] data0 [A] data1 [A] ... [A]
- datan [A] P
- . .
-
- ...
- pi.i2c_write_block_data(4, 5, b'hello')
-
- pi.i2c_write_block_data(4, 5, "data bytes")
-
- pi.i2c_write_block_data(5, 0, b'\\x00\\x01\\x22')
-
- pi.i2c_write_block_data(6, 2, [0, 1, 0x22])
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 len
- ## extension ##
- # s len data bytes
- if len(data):
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CWK, handle, reg, len(data), [data]))
- else:
- return 0
-
- def i2c_read_block_data(self, handle, reg):
- """
- Reads a block of up to 32 bytes from the specified register of
- the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
-
- SMBus 2.0 5.5.7 - Block read.
- . .
- S Addr Wr [A] reg [A]
- S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
- . .
-
- The amount of returned data is set by the device.
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.i2c_read_block_data(h, 10)
- if b >= 0:
- # process data
- else:
- # process read failure
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command(self.sl, _PI_CMD_I2CRK, handle, reg, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def i2c_block_process_call(self, handle, reg, data):
- """
- Writes data bytes to the specified register of the device
- associated with handle and reads a device specified number
- of bytes of data in return.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- data:= the bytes to write.
-
- The SMBus 2.0 documentation states that a minimum of 1 byte may
- be sent and a minimum of 1 byte may be received. The total
- number of bytes sent/received must be 32 or less.
-
- SMBus 2.0 5.5.8 - Block write-block read.
- . .
- S Addr Wr [A] reg [A] len(data) [A] data0 [A] ... datan [A]
- S Addr Rd [A] [Count] A [Data] ... A P
- . .
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.i2c_block_process_call(h, 10, b'\\x02\\x05\\x00')
-
- (b, d) = pi.i2c_block_process_call(h, 10, b'abcdr')
-
- (b, d) = pi.i2c_block_process_call(h, 10, "abracad")
-
- (b, d) = pi.i2c_block_process_call(h, 10, [2, 5, 16])
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CPK, handle, reg, len(data), [data], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def i2c_write_i2c_block_data(self, handle, reg, data):
- """
- Writes data bytes to the specified register of the device
- associated with handle . 1-32 bytes may be written.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- data:= the bytes to write.
-
- . .
- S Addr Wr [A] reg [A] data0 [A] data1 [A] ... [A] datan [NA] P
- . .
-
- ...
- pi.i2c_write_i2c_block_data(4, 5, 'hello')
-
- pi.i2c_write_i2c_block_data(4, 5, b'hello')
-
- pi.i2c_write_i2c_block_data(5, 0, b'\\x00\\x01\\x22')
-
- pi.i2c_write_i2c_block_data(6, 2, [0, 1, 0x22])
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 len
- ## extension ##
- # s len data bytes
- if len(data):
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CWI, handle, reg, len(data), [data]))
- else:
- return 0
-
- def i2c_read_i2c_block_data(self, handle, reg, count):
- """
- Reads count bytes from the specified register of the device
- associated with handle . The count may be 1-32.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- reg:= >=0, the device register.
- count:= >0, the number of bytes to read.
-
- . .
- S Addr Wr [A] reg [A]
- S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
- . .
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.i2c_read_i2c_block_data(h, 4, 32)
- if b >= 0:
- # process data
- else:
- # process read failure
- ...
- """
- # I p1 handle
- # I p2 reg
- # I p3 4
- ## extension ##
- # I count
- extents = [struct.pack("I", count)]
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CRI, handle, reg, 4, extents, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def i2c_read_device(self, handle, count):
- """
- Returns count bytes read from the raw device associated
- with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- count:= >0, the number of bytes to read.
-
- . .
- S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
- . .
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (count, data) = pi.i2c_read_device(h, 12)
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(
- _pigpio_command(self.sl, _PI_CMD_I2CRD, handle, count, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def i2c_write_device(self, handle, data):
- """
- Writes the data bytes to the raw device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- data:= the bytes to write.
-
- . .
- S Addr Wr [A] data0 [A] data1 [A] ... [A] datan [A] P
- . .
-
- ...
- pi.i2c_write_device(h, b"\\x12\\x34\\xA8")
-
- pi.i2c_write_device(h, b"help")
-
- pi.i2c_write_device(h, 'help')
-
- pi.i2c_write_device(h, [23, 56, 231])
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
- if len(data):
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CWD, handle, 0, len(data), [data]))
- else:
- return 0
-
-
- def i2c_zip(self, handle, data):
- """
- This function executes a sequence of I2C operations. The
- operations to be performed are specified by the contents of data
- which contains the concatenated command codes and associated data.
-
- handle:= >=0 (as returned by a prior call to [*i2c_open*]).
- data:= the concatenated I2C commands, see below
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (count, data) = pi.i2c_zip(h, [4, 0x53, 7, 1, 0x32, 6, 6, 0])
- ...
-
- The following command codes are supported:
-
- Name @ Cmd & Data @ Meaning
- End @ 0 @ No more commands
- Escape @ 1 @ Next P is two bytes
- On @ 2 @ Switch combined flag on
- Off @ 3 @ Switch combined flag off
- Address @ 4 P @ Set I2C address to P
- Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
- Read @ 6 P @ Read P bytes of data
- Write @ 7 P ... @ Write P bytes of data
-
- The address, read, and write commands take a parameter P.
- Normally P is one byte (0-255). If the command is preceded by
- the Escape command then P is two bytes (0-65535, least significant
- byte first).
-
- The address defaults to that associated with the handle.
- The flags default to 0. The address and flags maintain their
- previous value until updated.
-
- Any read I2C data is concatenated in the returned bytearray.
-
- ...
- Set address 0x53, write 0x32, read 6 bytes
- Set address 0x1E, write 0x03, read 6 bytes
- Set address 0x68, write 0x1B, read 8 bytes
- End
-
- 0x04 0x53 0x07 0x01 0x32 0x06 0x06
- 0x04 0x1E 0x07 0x01 0x03 0x06 0x06
- 0x04 0x68 0x07 0x01 0x1B 0x06 0x08
- 0x00
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_I2CZ, handle, 0, len(data), [data], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
-
- def bb_spi_open(self, CS, MISO, MOSI, SCLK, baud=100000, spi_flags=0):
- """
- This function selects a set of GPIO for bit banging SPI at a
- specified baud rate.
-
- CS := 0-31
- MISO := 0-31
- MOSI := 0-31
- SCLK := 0-31
- baud := 50-250000
- spiFlags := see below
-
- spiFlags consists of the least significant 22 bits.
-
- . .
- 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
- . .
-
- mm defines the SPI mode, defaults to 0
-
- . .
- Mode CPOL CPHA
- 0 0 0
- 1 0 1
- 2 1 0
- 3 1 1
- . .
-
- The following constants may be used to set the mode:
-
- . .
- pigpio.SPI_MODE_0
- pigpio.SPI_MODE_1
- pigpio.SPI_MODE_2
- pigpio.SPI_MODE_3
- . .
-
- Alternatively pigpio.SPI_CPOL and/or pigpio.SPI_CPHA
- may be used.
-
- p is 0 if CS is active low (default) and 1 for active high.
- pigpio.SPI_CS_HIGH_ACTIVE may be used to set this flag.
-
- T is 1 if the least significant bit is transmitted on MOSI first,
- the default (0) shifts the most significant bit out first.
- pigpio.SPI_TX_LSBFIRST may be used to set this flag.
-
- R is 1 if the least significant bit is received on MISO first,
- the default (0) receives the most significant bit first.
- pigpio.SPI_RX_LSBFIRST may be used to set this flag.
-
- The other bits in spiFlags should be set to zero.
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or
- PI_GPIO_IN_USE.
-
- If more than one device is connected to the SPI bus (defined by
- SCLK, MOSI, and MISO) each must have its own CS.
-
- ...
- bb_spi_open(10, MISO, MOSI, SCLK, 10000, 0); // device 1
- bb_spi_open(11, MISO, MOSI, SCLK, 20000, 3); // device 2
- ...
- """
- # I p1 CS
- # I p2 0
- # I p3 20
- ## extension ##
- # I MISO
- # I MOSI
- # I SCLK
- # I baud
- # I spi_flags
-
- extents = [struct.pack("IIIII", MISO, MOSI, SCLK, baud, spi_flags)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_BSPIO, CS, 0, 20, extents))
-
-
- def bb_spi_close(self, CS):
- """
- This function stops bit banging SPI on a set of GPIO
- opened with [*bb_spi_open*].
-
- CS:= 0-31, the CS GPIO used in a prior call to [*bb_spi_open*]
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO.
-
- ...
- pi.bb_spi_close(CS)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_BSPIC, CS, 0))
-
-
- def bb_spi_xfer(self, CS, data):
- """
- This function executes a bit banged SPI transfer.
-
- CS:= 0-31 (as used in a prior call to [*bb_spi_open*])
- data:= data to be sent
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- #!/usr/bin/env python
-
- import pigpio
-
- CE0=5
- CE1=6
- MISO=13
- MOSI=19
- SCLK=12
-
- pi = pigpio.pi()
- if not pi.connected:
- exit()
-
- pi.bb_spi_open(CE0, MISO, MOSI, SCLK, 10000, 0) # MCP4251 DAC
- pi.bb_spi_open(CE1, MISO, MOSI, SCLK, 20000, 3) # MCP3008 ADC
-
- for i in range(256):
-
- count, data = pi.bb_spi_xfer(CE0, [0, i]) # Set DAC value
-
- if count == 2:
-
- count, data = pi.bb_spi_xfer(CE0, [12, 0]) # Read back DAC
-
- if count == 2:
-
- set_val = data[1]
-
- count, data = pi.bb_spi_xfer(CE1, [1, 128, 0]) # Read ADC
-
- if count == 3:
-
- read_val = ((data[1]&3)<<8) | data[2]
-
- print("{} {}".format(set_val, read_val))
-
- pi.bb_spi_close(CE0)
- pi.bb_spi_close(CE1)
-
- pi.stop()
- ...
- """
- # I p1 CS
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_BSPIX, CS, 0, len(data), [data], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
-
- def bb_i2c_open(self, SDA, SCL, baud=100000):
- """
- This function selects a pair of GPIO for bit banging I2C at a
- specified baud rate.
-
- Bit banging I2C allows for certain operations which are not possible
- with the standard I2C driver.
-
- o baud rates as low as 50
- o repeated starts
- o clock stretching
- o I2C on any pair of spare GPIO
-
- SDA:= 0-31
- SCL:= 0-31
- baud:= 50-500000
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
- PI_GPIO_IN_USE.
-
- NOTE:
-
- The GPIO used for SDA and SCL must have pull-ups to 3V3 connected.
- As a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-
- ...
- h = pi.bb_i2c_open(4, 5, 50000) # bit bang on GPIO 4/5 at 50kbps
- ...
- """
- # I p1 SDA
- # I p2 SCL
- # I p3 4
- ## extension ##
- # I baud
- extents = [struct.pack("I", baud)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_BI2CO, SDA, SCL, 4, extents))
-
-
- def bb_i2c_close(self, SDA):
- """
- This function stops bit banging I2C on a pair of GPIO
- previously opened with [*bb_i2c_open*].
-
- SDA:= 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-
- ...
- pi.bb_i2c_close(SDA)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_BI2CC, SDA, 0))
-
-
- def bb_i2c_zip(self, SDA, data):
- """
- This function executes a sequence of bit banged I2C operations.
- The operations to be performed are specified by the contents
- of data which contains the concatenated command codes and
- associated data.
-
- SDA:= 0-31 (as used in a prior call to [*bb_i2c_open*])
- data:= the concatenated I2C commands, see below
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (count, data) = pi.bb_i2c_zip(
- h, [4, 0x53, 2, 7, 1, 0x32, 2, 6, 6, 3, 0])
- ...
-
- The following command codes are supported:
-
- Name @ Cmd & Data @ Meaning
- End @ 0 @ No more commands
- Escape @ 1 @ Next P is two bytes
- Start @ 2 @ Start condition
- Stop @ 3 @ Stop condition
- Address @ 4 P @ Set I2C address to P
- Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
- Read @ 6 P @ Read P bytes of data
- Write @ 7 P ... @ Write P bytes of data
-
- The address, read, and write commands take a parameter P.
- Normally P is one byte (0-255). If the command is preceded by
- the Escape command then P is two bytes (0-65535, least significant
- byte first).
-
- The address and flags default to 0. The address and flags maintain
- their previous value until updated.
-
- No flags are currently defined.
-
- Any read I2C data is concatenated in the returned bytearray.
-
- ...
- Set address 0x53
- start, write 0x32, (re)start, read 6 bytes, stop
- Set address 0x1E
- start, write 0x03, (re)start, read 6 bytes, stop
- Set address 0x68
- start, write 0x1B, (re)start, read 8 bytes, stop
- End
-
- 0x04 0x53
- 0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-
- 0x04 0x1E
- 0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-
- 0x04 0x68
- 0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-
- 0x00
- ...
- """
- # I p1 SDA
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_BI2CZ, SDA, 0, len(data), [data], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def spi_open(self, spi_channel, baud, spi_flags=0):
- """
- Returns a handle for the SPI device on channel. Data will be
- transferred at baud bits per second. The flags may be used to
- modify the default behaviour of 4-wire operation, mode 0,
- active low chip select.
-
- An auxiliary SPI device is available on all models but the
- A and B and may be selected by setting the A bit in the
- flags. The auxiliary device has 3 chip selects and a
- selectable word size in bits.
-
- spi_channel:= 0-1 (0-2 for the auxiliary SPI device).
- baud:= 32K-125M (values above 30M are unlikely to work).
- spi_flags:= see below.
-
- Normally you would only use the [*spi_**] functions if
- you are or will be connecting to the Pi over a network. If
- you will always run on the local Pi use the standard SPI
- module instead.
-
- spi_flags consists of the least significant 22 bits.
-
- . .
- 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
- . .
-
- mm defines the SPI mode.
-
- WARNING: modes 1 and 3 do not appear to work on
- the auxiliary device.
-
- . .
- Mode POL PHA
- 0 0 0
- 1 0 1
- 2 1 0
- 3 1 1
- . .
-
- px is 0 if CEx is active low (default) and 1 for active high.
-
- ux is 0 if the CEx GPIO is reserved for SPI (default)
- and 1 otherwise.
-
- A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
- W is 0 if the device is not 3-wire, 1 if the device is 3-wire.
- Standard SPI device only.
-
- nnnn defines the number of bytes (0-15) to write before
- switching the MOSI line to MISO to read data. This field
- is ignored if W is not set. Standard SPI device only.
-
- T is 1 if the least significant bit is transmitted on MOSI
- first, the default (0) shifts the most significant bit out
- first. Auxiliary SPI device only.
-
- R is 1 if the least significant bit is received on MISO
- first, the default (0) receives the most significant bit
- first. Auxiliary SPI device only.
-
- bbbbbb defines the word size in bits (0-32). The default (0)
- sets 8 bits per word. Auxiliary SPI device only.
-
- The [*spi_read*], [*spi_write*], and [*spi_xfer*] functions
- transfer data packed into 1, 2, or 4 bytes according to
- the word size in bits.
-
- For bits 1-8 there will be one byte per character.
- For bits 9-16 there will be two bytes per character.
- For bits 17-32 there will be four bytes per character.
-
- E.g. 32 12-bit words will be transferred in 64 bytes.
-
- The other bits in flags should be set to zero.
-
- ...
- # open SPI device on channel 1 in mode 3 at 50000 bits per second
-
- h = pi.spi_open(1, 50000, 3)
- ...
- """
- # I p1 spi_channel
- # I p2 baud
- # I p3 4
- ## extension ##
- # I spi_flags
- extents = [struct.pack("I", spi_flags)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SPIO, spi_channel, baud, 4, extents))
-
- def spi_close(self, handle):
- """
- Closes the SPI device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*spi_open*]).
-
- ...
- pi.spi_close(h)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SPIC, handle, 0))
-
- def spi_read(self, handle, count):
- """
- Reads count bytes from the SPI device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*spi_open*]).
- count:= >0, the number of bytes to read.
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.spi_read(h, 60) # read 60 bytes from device h
- if b == 60:
- # process read data
- else:
- # error path
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command(
- self.sl, _PI_CMD_SPIR, handle, count, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def spi_write(self, handle, data):
- """
- Writes the data bytes to the SPI device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*spi_open*]).
- data:= the bytes to write.
-
- ...
- pi.spi_write(0, b'\\x02\\xc0\\x80') # write 3 bytes to device 0
-
- pi.spi_write(0, b'defgh') # write 5 bytes to device 0
-
- pi.spi_write(0, "def") # write 3 bytes to device 0
-
- pi.spi_write(1, [2, 192, 128]) # write 3 bytes to device 1
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SPIW, handle, 0, len(data), [data]))
-
- def spi_xfer(self, handle, data):
- """
- Writes the data bytes to the SPI device associated with handle,
- returning the data bytes read from the device.
-
- handle:= >=0 (as returned by a prior call to [*spi_open*]).
- data:= the bytes to write.
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (count, rx_data) = pi.spi_xfer(h, b'\\x01\\x80\\x00')
-
- (count, rx_data) = pi.spi_xfer(h, [1, 128, 0])
-
- (count, rx_data) = pi.spi_xfer(h, b"hello")
-
- (count, rx_data) = pi.spi_xfer(h, "hello")
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SPIX, handle, 0, len(data), [data], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def serial_open(self, tty, baud, ser_flags=0):
- """
- Returns a handle for the serial tty device opened
- at baud bits per second. The device name must start
- with /dev/tty or /dev/serial.
-
- tty:= the serial device to open.
- baud:= baud rate in bits per second, see below.
- ser_flags:= 0, no flags are currently defined.
-
- Normally you would only use the [*serial_**] functions if
- you are or will be connecting to the Pi over a network. If
- you will always run on the local Pi use the standard serial
- module instead.
-
- The baud rate must be one of 50, 75, 110, 134, 150,
- 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
- 38400, 57600, 115200, or 230400.
-
- ...
- h1 = pi.serial_open("/dev/ttyAMA0", 300)
-
- h2 = pi.serial_open("/dev/ttyUSB1", 19200, 0)
-
- h3 = pi.serial_open("/dev/serial0", 9600)
- ...
- """
- # I p1 baud
- # I p2 ser_flags
- # I p3 len
- ## extension ##
- # s len data bytes
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SERO, baud, ser_flags, len(tty), [tty]))
-
- def serial_close(self, handle):
- """
- Closes the serial device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
-
- ...
- pi.serial_close(h1)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SERC, handle, 0))
-
- def serial_read_byte(self, handle):
- """
- Returns a single byte from the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
-
- ...
- b = pi.serial_read_byte(h1)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SERRB, handle, 0))
-
- def serial_write_byte(self, handle, byte_val):
- """
- Writes a single byte to the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
- byte_val:= 0-255, the value to write.
-
- ...
- pi.serial_write_byte(h1, 23)
-
- pi.serial_write_byte(h1, ord('Z'))
- ...
- """
- return _u2i(
- _pigpio_command(self.sl, _PI_CMD_SERWB, handle, byte_val))
-
- def serial_read(self, handle, count):
- """
- Reads up to count bytes from the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
- count:= >0, the number of bytes to read.
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.serial_read(h2, 100)
- if b > 0:
- # process read data
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(
- _pigpio_command(self.sl, _PI_CMD_SERR, handle, count, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def serial_write(self, handle, data):
- """
- Writes the data bytes to the device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
- data:= the bytes to write.
-
- ...
- pi.serial_write(h1, b'\\x02\\x03\\x04')
-
- pi.serial_write(h2, b'help')
-
- pi.serial_write(h2, "hello")
-
- pi.serial_write(h1, [2, 3, 4])
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SERW, handle, 0, len(data), [data]))
-
- def serial_data_available(self, handle):
- """
- Returns the number of bytes available to be read from the
- device associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*serial_open*]).
-
- ...
- rdy = pi.serial_data_available(h1)
-
- if rdy > 0:
- (b, d) = pi.serial_read(h1, rdy)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SERDA, handle, 0))
-
- def gpio_trigger(self, user_gpio, pulse_len=10, level=1):
- """
- Send a trigger pulse to a GPIO. The GPIO is set to
- level for pulse_len microseconds and then reset to not level.
-
- user_gpio:= 0-31
- pulse_len:= 1-100
- level:= 0-1
-
- ...
- pi.gpio_trigger(23, 10, 1)
- ...
- """
- # pigpio message format
-
- # I p1 user_gpio
- # I p2 pulse_len
- # I p3 4
- ## extension ##
- # I level
- extents = [struct.pack("I", level)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_TRIG, user_gpio, pulse_len, 4, extents))
-
- def set_glitch_filter(self, user_gpio, steady):
- """
- Sets a glitch filter on a GPIO.
-
- Level changes on the GPIO are not reported unless the level
- has been stable for at least [*steady*] microseconds. The
- level is then reported. Level changes of less than [*steady*]
- microseconds are ignored.
-
- user_gpio:= 0-31
- steady:= 0-300000
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
- Note, each (stable) edge will be timestamped [*steady*]
- microseconds after it was first detected.
-
- ...
- pi.set_glitch_filter(23, 100)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_FG, user_gpio, steady))
-
- def set_noise_filter(self, user_gpio, steady, active):
- """
- Sets a noise filter on a GPIO.
-
- Level changes on the GPIO are ignored until a level which has
- been stable for [*steady*] microseconds is detected. Level
- changes on the GPIO are then reported for [*active*]
- microseconds after which the process repeats.
-
- user_gpio:= 0-31
- steady:= 0-300000
- active:= 0-1000000
-
- Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
- Note, level changes before and after the active period may
- be reported. Your software must be designed to cope with
- such reports.
-
- ...
- pi.set_noise_filter(23, 1000, 5000)
- ...
- """
- # pigpio message format
-
- # I p1 user_gpio
- # I p2 steady
- # I p3 4
- ## extension ##
- # I active
- extents = [struct.pack("I", active)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_FN, user_gpio, steady, 4, extents))
-
- def store_script(self, script):
- """
- Store a script for later execution.
-
- See [[http://abyz.co.uk/rpi/pigpio/pigs.html#Scripts]] for
- details.
-
- script:= the script text as a series of bytes.
-
- Returns a >=0 script id if OK.
-
- ...
- sid = pi.store_script(
- b'tag 0 w 22 1 mils 100 w 22 0 mils 100 dcr p0 jp 0')
- ...
- """
- # I p1 0
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
- if len(script):
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_PROC, 0, 0, len(script), [script]))
- else:
- return 0
-
- def run_script(self, script_id, params=None):
- """
- Runs a stored script.
-
- script_id:= id of stored script.
- params:= up to 10 parameters required by the script.
-
- ...
- s = pi.run_script(sid, [par1, par2])
-
- s = pi.run_script(sid)
-
- s = pi.run_script(sid, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
- ...
- """
- # I p1 script id
- # I p2 0
- # I p3 params * 4 (0-10 params)
- ## (optional) extension ##
- # I[] params
- if params is not None:
- ext = bytearray()
- for p in params:
- ext.extend(struct.pack("I", p))
- nump = len(params)
- extents = [ext]
- else:
- nump = 0
- extents = []
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_PROCR, script_id, 0, nump*4, extents))
-
- def script_status(self, script_id):
- """
- Returns the run status of a stored script as well as the
- current values of parameters 0 to 9.
-
- script_id:= id of stored script.
-
- The run status may be
-
- . .
- PI_SCRIPT_INITING
- PI_SCRIPT_HALTED
- PI_SCRIPT_RUNNING
- PI_SCRIPT_WAITING
- PI_SCRIPT_FAILED
- . .
-
- The return value is a tuple of run status and a list of
- the 10 parameters. On error the run status will be negative
- and the parameter list will be empty.
-
- ...
- (s, pars) = pi.script_status(sid)
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(
- _pigpio_command(self.sl, _PI_CMD_PROCP, script_id, 0, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- pars = struct.unpack('11i', _str(data))
- status = pars[0]
- params = pars[1:]
- else:
- status = bytes
- params = ()
- self.sl.l.release()
- return status, params
-
- def stop_script(self, script_id):
- """
- Stops a running script.
-
- script_id:= id of stored script.
-
- ...
- status = pi.stop_script(sid)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCS, script_id, 0))
-
- def delete_script(self, script_id):
- """
- Deletes a stored script.
-
- script_id:= id of stored script.
-
- ...
- status = pi.delete_script(sid)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_PROCD, script_id, 0))
-
- def bb_serial_read_open(self, user_gpio, baud, bb_bits=8):
- """
- Opens a GPIO for bit bang reading of serial data.
-
- user_gpio:= 0-31, the GPIO to use.
- baud:= 50-250000, the baud rate.
- bb_bits:= 1-32, the number of bits per word, default 8.
-
- The serial data is held in a cyclic buffer and is read using
- [*bb_serial_read*].
-
- It is the caller's responsibility to read data from the cyclic
- buffer in a timely fashion.
-
- ...
- status = pi.bb_serial_read_open(4, 19200)
- status = pi.bb_serial_read_open(17, 9600)
- ...
- """
- # pigpio message format
-
- # I p1 user_gpio
- # I p2 baud
- # I p3 4
- ## extension ##
- # I bb_bits
- extents = [struct.pack("I", bb_bits)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SLRO, user_gpio, baud, 4, extents))
-
- def bb_serial_read(self, user_gpio):
- """
- Returns data from the bit bang serial cyclic buffer.
-
- user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- The bytes returned for each character depend upon the number of
- data bits [*bb_bits*] specified in the [*bb_serial_read_open*]
- command.
-
- For [*bb_bits*] 1-8 there will be one byte per character.
- For [*bb_bits*] 9-16 there will be two bytes per character.
- For [*bb_bits*] 17-32 there will be four bytes per character.
-
- ...
- (count, data) = pi.bb_serial_read(4)
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(
- _pigpio_command(self.sl, _PI_CMD_SLR, user_gpio, 10000, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
-
- def bb_serial_read_close(self, user_gpio):
- """
- Closes a GPIO for bit bang reading of serial data.
-
- user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
-
- ...
- status = pi.bb_serial_read_close(17)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SLRC, user_gpio, 0))
-
- def bb_serial_invert(self, user_gpio, invert):
- """
- Invert serial logic.
-
- user_gpio:= 0-31 (opened in a prior call to [*bb_serial_read_open*])
- invert:= 0-1 (1 invert, 0 normal)
-
- ...
- status = pi.bb_serial_invert(17, 1)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_SLRI, user_gpio, invert))
-
-
- def custom_1(self, arg1=0, arg2=0, argx=[]):
- """
- Calls a pigpio function customised by the user.
-
- arg1:= >=0, default 0.
- arg2:= >=0, default 0.
- argx:= extra arguments (each 0-255), default empty.
-
- The returned value is an integer which by convention
- should be >=0 for OK and <0 for error.
-
- ...
- value = pi.custom_1()
-
- value = pi.custom_1(23)
-
- value = pi.custom_1(0, 55)
-
- value = pi.custom_1(23, 56, [1, 5, 7])
-
- value = pi.custom_1(23, 56, b"hello")
-
- value = pi.custom_1(23, 56, "hello")
- ...
- """
- # I p1 arg1
- # I p2 arg2
- # I p3 len
- ## extension ##
- # s len argx bytes
-
- return u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_CF1, arg1, arg2, len(argx), [argx]))
-
- def custom_2(self, arg1=0, argx=[], retMax=8192):
- """
- Calls a pigpio function customised by the user.
-
- arg1:= >=0, default 0.
- argx:= extra arguments (each 0-255), default empty.
- retMax:= >=0, maximum number of bytes to return, default 8192.
-
- The returned value is a tuple of the number of bytes
- returned and a bytearray containing the bytes. If
- there was an error the number of bytes read will be
- less than zero (and will contain the error code).
-
- ...
- (count, data) = pi.custom_2()
-
- (count, data) = pi.custom_2(23)
-
- (count, data) = pi.custom_2(23, [1, 5, 7])
-
- (count, data) = pi.custom_2(23, b"hello")
-
- (count, data) = pi.custom_2(23, "hello", 128)
- ...
- """
- # I p1 arg1
- # I p2 retMax
- # I p3 len
- ## extension ##
- # s len argx bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_CF2, arg1, retMax, len(argx), [argx], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def get_pad_strength(self, pad):
- """
- This function returns the pad drive strength in mA.
-
- pad:= 0-2, the pad to get.
-
- Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
-
- Pad @ GPIO
- 0 @ 0-27
- 1 @ 28-45
- 2 @ 46-53
-
- ...
- strength = pi.get_pad_strength(0) # Get pad 0 strength.
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_PADG, pad, 0))
-
- def set_pad_strength(self, pad, pad_strength):
- """
- This function sets the pad drive strength in mA.
-
-
- pad:= 0-2, the pad to set.
- pad_strength:= 1-16 mA.
-
- Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
-
- Pad @ GPIO
- 0 @ 0-27
- 1 @ 28-45
- 2 @ 46-53
-
- ...
- pi.set_pad_strength(2, 14) # Set pad 2 to 14 mA.
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_PADS, pad, pad_strength))
-
-
- def file_open(self, file_name, file_mode):
- """
- This function returns a handle to a file opened in a specified mode.
-
- file_name:= the file to open.
- file_mode:= the file open mode.
-
- Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
- PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
-
- ...
- h = pi.file_open("/home/pi/shared/dir_3/file.txt",
- pigpio.FILE_WRITE | pigpio.FILE_CREATE)
-
- pi.file_write(h, "Hello world")
-
- pi.file_close(h)
- ...
-
- File
-
- A file may only be opened if permission is granted by an entry in
- /opt/pigpio/access. This is intended to allow remote access to files
- in a more or less controlled manner.
-
- Each entry in /opt/pigpio/access takes the form of a file path
- which may contain wildcards followed by a single letter permission.
- The permission may be R for read, W for write, U for read/write,
- and N for no access.
-
- Where more than one entry matches a file the most specific rule
- applies. If no entry matches a file then access is denied.
-
- Suppose /opt/pigpio/access contains the following entries
-
- . .
- /home/* n
- /home/pi/shared/dir_1/* w
- /home/pi/shared/dir_2/* r
- /home/pi/shared/dir_3/* u
- /home/pi/shared/dir_1/file.txt n
- . .
-
- Files may be written in directory dir_1 with the exception
- of file.txt.
-
- Files may be read in directory dir_2.
-
- Files may be read and written in directory dir_3.
-
- If a directory allows read, write, or read/write access then files
- may be created in that directory.
-
- In an attempt to prevent risky permissions the following paths are
- ignored in /opt/pigpio/access.
-
- . .
- a path containing ..
- a path containing only wildcards (*?)
- a path containing less than two non-wildcard parts
- . .
-
- Mode
-
- The mode may have the following values.
-
- Constant @ Value @ Meaning
- FILE_READ @ 1 @ open file for reading
- FILE_WRITE @ 2 @ open file for writing
- FILE_RW @ 3 @ open file for reading and writing
-
- The following values may be or'd into the mode.
-
- Name @ Value @ Meaning
- FILE_APPEND @ 4 @ All writes append data to the end of the file
- FILE_CREATE @ 8 @ The file is created if it doesn't exist
- FILE_TRUNC @ 16 @ The file is truncated
-
- Newly created files are owned by root with permissions owner
- read and write.
-
- ...
- #!/usr/bin/env python
-
- import pigpio
-
- pi = pigpio.pi()
-
- if not pi.connected:
- exit()
-
- # Assumes /opt/pigpio/access contains the following line.
- # /ram/*.c r
-
- handle = pi.file_open("/ram/pigpio.c", pigpio.FILE_READ)
-
- done = False
-
- while not done:
- c, d = pi.file_read(handle, 60000)
- if c > 0:
- print(d)
- else:
- done = True
-
- pi.file_close(handle)
-
- pi.stop()
- ...
- """
- # I p1 file_mode
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_FO, file_mode, 0, len(file_name), [file_name]))
-
- def file_close(self, handle):
- """
- Closes the file associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*file_open*]).
-
- ...
- pi.file_close(handle)
- ...
- """
- return _u2i(_pigpio_command(self.sl, _PI_CMD_FC, handle, 0))
-
- def file_read(self, handle, count):
- """
- Reads up to count bytes from the file associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*file_open*]).
- count:= >0, the number of bytes to read.
-
- The returned value is a tuple of the number of bytes read and a
- bytearray containing the bytes. If there was an error the
- number of bytes read will be less than zero (and will contain
- the error code).
-
- ...
- (b, d) = pi.file_read(h2, 100)
- if b > 0:
- # process read data
- ...
- """
- # Don't raise exception. Must release lock.
- bytes = u2i(
- _pigpio_command(self.sl, _PI_CMD_FR, handle, count, False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def file_write(self, handle, data):
- """
- Writes the data bytes to the file associated with handle.
-
- handle:= >=0 (as returned by a prior call to [*file_open*]).
- data:= the bytes to write.
-
- ...
- pi.file_write(h1, b'\\x02\\x03\\x04')
-
- pi.file_write(h2, b'help')
-
- pi.file_write(h2, "hello")
-
- pi.file_write(h1, [2, 3, 4])
- ...
- """
- # I p1 handle
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_FW, handle, 0, len(data), [data]))
-
- def file_seek(self, handle, seek_offset, seek_from):
- """
- Seeks to a position relative to the start, current position,
- or end of the file. Returns the new position.
-
- handle:= >=0 (as returned by a prior call to [*file_open*]).
- seek_offset:= byte offset.
- seek_from:= FROM_START, FROM_CURRENT, or FROM_END.
-
- ...
- new_pos = pi.file_seek(h, 100, pigpio.FROM_START)
-
- cur_pos = pi.file_seek(h, 0, pigpio.FROM_CURRENT)
-
- file_size = pi.file_seek(h, 0, pigpio.FROM_END)
- ...
- """
- # I p1 handle
- # I p2 seek_offset
- # I p3 4
- ## extension ##
- # I seek_from
- extents = [struct.pack("I", seek_from)]
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_FS, handle, seek_offset, 4, extents))
-
- def file_list(self, fpattern):
- """
- Returns a list of files which match a pattern.
-
- fpattern:= file pattern to match.
-
- Returns the number of returned bytes if OK, otherwise
- PI_NO_FILE_ACCESS, or PI_NO_FILE_MATCH.
-
- The pattern must match an entry in /opt/pigpio/access. The
- pattern may contain wildcards. See [*file_open*].
-
- NOTE
-
- The returned value is not the number of files, it is the number
- of bytes in the buffer. The file names are separated by newline
- characters.
-
- ...
- #!/usr/bin/env python
-
- import pigpio
-
- pi = pigpio.pi()
-
- if not pi.connected:
- exit()
-
- # Assumes /opt/pigpio/access contains the following line.
- # /ram/*.c r
-
- c, d = pi.file_list("/ram/p*.c")
- if c > 0:
- print(d)
-
- pi.stop()
- ...
- """
- # I p1 60000
- # I p2 0
- # I p3 len
- ## extension ##
- # s len data bytes
-
- # Don't raise exception. Must release lock.
- bytes = u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_FL, 60000, 0, len(fpattern), [fpattern], False))
- if bytes > 0:
- data = self._rxbuf(bytes)
- else:
- data = ""
- self.sl.l.release()
- return bytes, data
-
- def shell(self, shellscr, pstring=""):
- """
- This function uses the system call to execute a shell script
- with the given string as its parameter.
-
- shellscr:= the name of the script, only alphanumerics,
- '-' and '_' are allowed in the name
- pstring := the parameter string to pass to the script
-
- The exit status of the system call is returned if OK,
- otherwise PI_BAD_SHELL_STATUS.
-
- [*shellscr*] must exist in /opt/pigpio/cgi and must be executable.
-
- The returned exit status is normally 256 times that set by
- the shell script exit function. If the script can't be
- found 32512 will be returned.
-
- The following table gives some example returned statuses.
-
- Script exit status @ Returned system call status
- 1 @ 256
- 5 @ 1280
- 10 @ 2560
- 200 @ 51200
- script not found @ 32512
-
- ...
- // pass two parameters, hello and world
- status = pi.shell("scr1", "hello world");
-
- // pass three parameters, hello, string with spaces, and world
- status = pi.shell("scr1", "hello 'string with spaces' world");
-
- // pass one parameter, hello string with spaces world
- status = pi.shell("scr1", "\\"hello string with spaces world\\"");
- ...
- """
- # I p1 len(shellscr)
- # I p2 0
- # I p3 len(shellscr)+len(pstring)+1
- ## extension ##
- # s len data bytes
-
- ls = len(shellscr)
- lp = len(pstring)
- return _u2i(_pigpio_command_ext(
- self.sl, _PI_CMD_SHELL, ls, 0, ls+lp+1, [shellscr+'\x00'+pstring]))
-
- def callback(self, user_gpio, edge=RISING_EDGE, func=None):
- """
- Calls a user supplied function (a callback) whenever the
- specified GPIO edge is detected.
-
- user_gpio:= 0-31.
- edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE.
- func:= user supplied callback function.
-
- The user supplied callback receives three parameters, the GPIO,
- the level, and the tick.
-
- If a user callback is not specified a default tally callback is
- provided which simply counts edges. The count may be retrieved
- by calling the tally function. The count may be reset to zero
- by calling the reset_tally function.
-
- The callback may be cancelled by calling the cancel function.
-
- A GPIO may have multiple callbacks (although I can't think of
- a reason to do so).
-
- ...
- def cbf(gpio, level, tick):
- print(gpio, level, tick)
-
- cb1 = pi.callback(22, pigpio.EITHER_EDGE, cbf)
-
- cb2 = pi.callback(4, pigpio.EITHER_EDGE)
-
- cb3 = pi.callback(17)
-
- print(cb3.tally())
-
- cb3.reset_tally()
-
- cb1.cancel() # To cancel callback cb1.
- ...
- """
- return _callback(self._notify, user_gpio, edge, func)
-
- def wait_for_edge(self, user_gpio, edge=RISING_EDGE, wait_timeout=60.0):
- """
- Wait for an edge event on a GPIO.
-
- user_gpio:= 0-31.
- edge:= EITHER_EDGE, RISING_EDGE (default), or
- FALLING_EDGE.
- wait_timeout:= >=0.0 (default 60.0).
-
- The function returns when the edge is detected or after
- the number of seconds specified by timeout has expired.
-
- Do not use this function for precise timing purposes,
- the edge is only checked 20 times a second. Whenever
- you need to know the accurate time of GPIO events use
- a [*callback*] function.
-
- The function returns True if the edge is detected,
- otherwise False.
-
- ...
- if pi.wait_for_edge(23):
- print("Rising edge detected")
- else:
- print("wait for edge timed out")
-
- if pi.wait_for_edge(23, pigpio.FALLING_EDGE, 5.0):
- print("Falling edge detected")
- else:
- print("wait for falling edge timed out")
- ...
- """
- a = _wait_for_edge(self._notify, user_gpio, edge, wait_timeout)
- return a.trigger
-
- def __init__(self,
- host = os.getenv("PIGPIO_ADDR", ''),
- port = os.getenv("PIGPIO_PORT", 8888)):
- """
- Grants access to a Pi's GPIO.
-
- host:= the host name of the Pi on which the pigpio daemon is
- running. The default is localhost unless overridden by
- the PIGPIO_ADDR environment variable.
-
- port:= the port number on which the pigpio daemon is listening.
- The default is 8888 unless overridden by the PIGPIO_PORT
- environment variable. The pigpio daemon must have been
- started with the same port number.
-
- This connects to the pigpio daemon and reserves resources
- to be used for sending commands and receiving notifications.
-
- An instance attribute [*connected*] may be used to check the
- success of the connection. If the connection is established
- successfully [*connected*] will be True, otherwise False.
-
- ...
- pi = pigio.pi() # use defaults
- pi = pigpio.pi('mypi') # specify host, default port
- pi = pigpio.pi('mypi', 7777) # specify host and port
-
- pi = pigpio.pi() # exit script if no connection
- if not pi.connected:
- exit()
- ...
- """
- self.connected = True
-
- self.sl = _socklock()
- self._notify = None
-
- port = int(port)
-
- self._host = host
- self._port = port
-
- self.sl.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sl.s.settimeout(None)
-
- # Disable the Nagle algorithm.
- self.sl.s.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
-
- try:
- self.sl.s.connect((host, port))
- self._notify = _callback_thread(self.sl, host, port)
-
- except socket.error:
- exception = 1
-
- except struct.error:
- exception = 2
-
- else:
- exception = 0
- atexit.register(self.stop)
-
- if exception != 0:
-
- self.connected = False
-
- if self.sl.s is not None:
- self.sl.s = None
-
- if host == '':
- h = "localhost"
- else:
- h = host
-
- s = "Can't connect to pigpio at {}({})".format(str(h), str(port))
-
- print(except_a.format(s))
- if exception == 1:
- print(except1)
- else:
- print(except2)
- print(except_z)
-
- def stop(self):
- """Release pigpio resources.
-
- ...
- pi.stop()
- ...
- """
-
- self.connected = False
-
- if self._notify is not None:
- self._notify.stop()
- self._notify = None
-
- if self.sl.s is not None:
- self.sl.s.close()
- self.sl.s = None
-
-def xref():
- """
- active: 0-1000000
- The number of microseconds level changes are reported for once
- a noise filter has been triggered (by [*steady*] microseconds of
- a stable level).
-
-
- arg1:
- An unsigned argument passed to a user customised function. Its
- meaning is defined by the customiser.
-
- arg2:
- An unsigned argument passed to a user customised function. Its
- meaning is defined by the customiser.
-
- argx:
- An array of bytes passed to a user customised function.
- Its meaning and content is defined by the customiser.
-
- baud:
- The speed of serial communication (I2C, SPI, serial link, waves)
- in bits per second.
-
- bb_bits: 1-32
- The number of data bits to be used when adding serial data to a
- waveform.
-
- bb_stop: 2-8
- The number of (half) stop bits to be used when adding serial data
- to a waveform.
-
- bit: 0-1
- A value of 0 or 1.
-
- bits: 32 bit number
- A mask used to select GPIO to be operated on. If bit n is set
- then GPIO n is selected. A convenient way of setting bit n is to
- bit or in the value (1<=1
- The length of a pulse in microseconds.
-
- dutycycle: 0-range_
- A number between 0 and range_.
-
- The dutycycle sets the proportion of time on versus time off during each
- PWM cycle.
-
- Dutycycle @ On time
- 0 @ Off
- range_ * 0.25 @ 25% On
- range_ * 0.50 @ 50% On
- range_ * 0.75 @ 75% On
- range_ @ Fully On
-
- edge: 0-2
- EITHER_EDGE = 2
- FALLING_EDGE = 1
- RISING_EDGE = 0
-
- errnum: <0
-
- . .
- PI_BAD_USER_GPIO = -2
- PI_BAD_GPIO = -3
- PI_BAD_MODE = -4
- PI_BAD_LEVEL = -5
- PI_BAD_PUD = -6
- PI_BAD_PULSEWIDTH = -7
- PI_BAD_DUTYCYCLE = -8
- PI_BAD_WDOG_TIMEOUT = -15
- PI_BAD_DUTYRANGE = -21
- PI_NO_HANDLE = -24
- PI_BAD_HANDLE = -25
- PI_BAD_WAVE_BAUD = -35
- PI_TOO_MANY_PULSES = -36
- PI_TOO_MANY_CHARS = -37
- PI_NOT_SERIAL_GPIO = -38
- PI_NOT_PERMITTED = -41
- PI_SOME_PERMITTED = -42
- PI_BAD_WVSC_COMMND = -43
- PI_BAD_WVSM_COMMND = -44
- PI_BAD_WVSP_COMMND = -45
- PI_BAD_PULSELEN = -46
- PI_BAD_SCRIPT = -47
- PI_BAD_SCRIPT_ID = -48
- PI_BAD_SER_OFFSET = -49
- PI_GPIO_IN_USE = -50
- PI_BAD_SERIAL_COUNT = -51
- PI_BAD_PARAM_NUM = -52
- PI_DUP_TAG = -53
- PI_TOO_MANY_TAGS = -54
- PI_BAD_SCRIPT_CMD = -55
- PI_BAD_VAR_NUM = -56
- PI_NO_SCRIPT_ROOM = -57
- PI_NO_MEMORY = -58
- PI_SOCK_READ_FAILED = -59
- PI_SOCK_WRIT_FAILED = -60
- PI_TOO_MANY_PARAM = -61
- PI_SCRIPT_NOT_READY = -62
- PI_BAD_TAG = -63
- PI_BAD_MICS_DELAY = -64
- PI_BAD_MILS_DELAY = -65
- PI_BAD_WAVE_ID = -66
- PI_TOO_MANY_CBS = -67
- PI_TOO_MANY_OOL = -68
- PI_EMPTY_WAVEFORM = -69
- PI_NO_WAVEFORM_ID = -70
- PI_I2C_OPEN_FAILED = -71
- PI_SER_OPEN_FAILED = -72
- PI_SPI_OPEN_FAILED = -73
- PI_BAD_I2C_BUS = -74
- PI_BAD_I2C_ADDR = -75
- PI_BAD_SPI_CHANNEL = -76
- PI_BAD_FLAGS = -77
- PI_BAD_SPI_SPEED = -78
- PI_BAD_SER_DEVICE = -79
- PI_BAD_SER_SPEED = -80
- PI_BAD_PARAM = -81
- PI_I2C_WRITE_FAILED = -82
- PI_I2C_READ_FAILED = -83
- PI_BAD_SPI_COUNT = -84
- PI_SER_WRITE_FAILED = -85
- PI_SER_READ_FAILED = -86
- PI_SER_READ_NO_DATA = -87
- PI_UNKNOWN_COMMAND = -88
- PI_SPI_XFER_FAILED = -89
- PI_NO_AUX_SPI = -91
- PI_NOT_PWM_GPIO = -92
- PI_NOT_SERVO_GPIO = -93
- PI_NOT_HCLK_GPIO = -94
- PI_NOT_HPWM_GPIO = -95
- PI_BAD_HPWM_FREQ = -96
- PI_BAD_HPWM_DUTY = -97
- PI_BAD_HCLK_FREQ = -98
- PI_BAD_HCLK_PASS = -99
- PI_HPWM_ILLEGAL = -100
- PI_BAD_DATABITS = -101
- PI_BAD_STOPBITS = -102
- PI_MSG_TOOBIG = -103
- PI_BAD_MALLOC_MODE = -104
- PI_BAD_SMBUS_CMD = -107
- PI_NOT_I2C_GPIO = -108
- PI_BAD_I2C_WLEN = -109
- PI_BAD_I2C_RLEN = -110
- PI_BAD_I2C_CMD = -111
- PI_BAD_I2C_BAUD = -112
- PI_CHAIN_LOOP_CNT = -113
- PI_BAD_CHAIN_LOOP = -114
- PI_CHAIN_COUNTER = -115
- PI_BAD_CHAIN_CMD = -116
- PI_BAD_CHAIN_DELAY = -117
- PI_CHAIN_NESTING = -118
- PI_CHAIN_TOO_BIG = -119
- PI_DEPRECATED = -120
- PI_BAD_SER_INVERT = -121
- PI_BAD_FOREVER = -124
- PI_BAD_FILTER = -125
- PI_BAD_PAD = -126
- PI_BAD_STRENGTH = -127
- PI_FIL_OPEN_FAILED = -128
- PI_BAD_FILE_MODE = -129
- PI_BAD_FILE_FLAG = -130
- PI_BAD_FILE_READ = -131
- PI_BAD_FILE_WRITE = -132
- PI_FILE_NOT_ROPEN = -133
- PI_FILE_NOT_WOPEN = -134
- PI_BAD_FILE_SEEK = -135
- PI_NO_FILE_MATCH = -136
- PI_NO_FILE_ACCESS = -137
- PI_FILE_IS_A_DIR = -138
- PI_BAD_SHELL_STATUS = -139
- PI_BAD_SCRIPT_NAME = -140
- . .
-
- file_mode:
- The mode may have the following values.
-
- . .
- FILE_READ 1
- FILE_WRITE 2
- FILE_RW 3
- . .
-
- The following values can be or'd into the file open mode.
-
- . .
- FILE_APPEND 4
- FILE_CREATE 8
- FILE_TRUNC 16
- . .
-
- file_name:
- A full file path. To be accessible the path must match
- an entry in /opt/pigpio/access.
-
- fpattern:
- A file path which may contain wildcards. To be accessible the path
- must match an entry in /opt/pigpio/access.
-
- frequency: 0-40000
- Defines the frequency to be used for PWM on a GPIO.
- The closest permitted frequency will be used.
-
- func:
- A user supplied callback function.
-
- gpio: 0-53
- A Broadcom numbered GPIO. All the user GPIO are in the range 0-31.
-
- There are 54 General Purpose Input Outputs (GPIO) named GPIO0
- through GPIO53.
-
- They are split into two banks. Bank 1 consists of GPIO0
- through GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-
- All the GPIO which are safe for the user to read and write are in
- bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
- have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
- See [*get_hardware_revision*].
-
- The user GPIO are marked with an X in the following table.
-
- . .
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
- Type 1 X X - - X - - X X X X X - - X X
- Type 2 - - X X X - - X X X X X - - X X
- Type 3 X X X X X X X X X X X X X X
-
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
- Type 1 - X X - - X X X X X - - - - - -
- Type 2 - X X - - - X X X X - X X X X X
- Type 3 X X X X X X X X X X X X - - - -
- . .
-
- gpio_off:
- A mask used to select GPIO to be operated on. See [*bits*].
-
- This mask selects the GPIO to be switched off at the start
- of a pulse.
-
- gpio_on:
- A mask used to select GPIO to be operated on. See [*bits*].
-
- This mask selects the GPIO to be switched on at the start
- of a pulse.
-
- handle: >=0
- A number referencing an object opened by one of [*file_open*],
- [*i2c_open*], [*notify_open*], [*serial_open*], [*spi_open*].
-
- host:
- The name or IP address of the Pi running the pigpio daemon.
-
- i2c_*:
- One of the i2c_ functions.
-
- i2c_address: 0-0x7F
- The address of a device on the I2C bus.
-
- i2c_bus: >=0
- An I2C bus number.
-
- i2c_flags: 0
- No I2C flags are currently defined.
-
- invert: 0-1
- A flag used to set normal or inverted bit bang serial data
- level logic.
-
- level: 0-1 (2)
- CLEAR = 0
- HIGH = 1
- LOW = 0
- OFF = 0
- ON = 1
- SET = 1
- TIMEOUT = 2 # only returned for a watchdog timeout
-
- MISO:
- The GPIO used for the MISO signal when bit banging SPI.
-
- mode:
-
- 1.The operational mode of a GPIO, normally INPUT or OUTPUT.
-
- ALT0 = 4
- ALT1 = 5
- ALT2 = 6
- ALT3 = 7
- ALT4 = 3
- ALT5 = 2
- INPUT = 0
- OUTPUT = 1
-
- 2. The mode of waveform transmission.
-
- WAVE_MODE_ONE_SHOT = 0
- WAVE_MODE_REPEAT = 1
- WAVE_MODE_ONE_SHOT_SYNC = 2
- WAVE_MODE_REPEAT_SYNC = 3
-
- MOSI:
- The GPIO used for the MOSI signal when bit banging SPI.
-
- offset: >=0
- The offset wave data starts from the beginning of the waveform
- being currently defined.
-
- pad: 0-2
- A set of GPIO which share common drivers.
-
- Pad @ GPIO
- 0 @ 0-27
- 1 @ 28-45
- 2 @ 46-53
-
- pad_strength: 1-16
- The mA which may be drawn from each GPIO whilst still guaranteeing the
- high and low levels.
-
- params: 32 bit number
- When scripts are started they can receive up to 10 parameters
- to define their operation.
-
- port:
- The port used by the pigpio daemon, defaults to 8888.
-
- pstring:
- The string to be passed to a [*shell*] script to be executed.
-
- pud: 0-2
- PUD_DOWN = 1
- PUD_OFF = 0
- PUD_UP = 2
-
- pulse_len: 1-100
- The length of the trigger pulse in microseconds.
-
- pulses:
- A list of class pulse objects defining the characteristics of a
- waveform.
-
- pulsewidth:
- The servo pulsewidth in microseconds. 0 switches pulses off.
-
- PWMduty: 0-1000000 (1M)
- The hardware PWM dutycycle.
-
- PWMfreq: 1-125000000 (125M)
- The hardware PWM frequency.
-
- range_: 25-40000
- Defines the limits for the [*dutycycle*] parameter.
-
- range_ defaults to 255.
-
- reg: 0-255
- An I2C device register. The usable registers depend on the
- actual device.
-
- retMax: >=0
- The maximum number of bytes a user customised function
- should return, default 8192.
-
- SCL:
- The user GPIO to use for the clock when bit banging I2C.
-
- SCLK::
- The GPIO used for the SCLK signal when bit banging SPI.
-
- script:
- The text of a script to store on the pigpio daemon.
-
- script_id: >=0
- A number referencing a script created by [*store_script*].
-
- SDA:
- The user GPIO to use for data when bit banging I2C.
-
- seek_from: 0-2
- Direction to seek for [*file_seek*].
-
- FROM_START=0
- FROM_CURRENT=1
- FROM_END=2
-
- seek_offset:
- The number of bytes to move forward (positive) or backwards
- (negative) from the seek position (start, current, or end of file).
-
- ser_flags: 32 bit
- No serial flags are currently defined.
-
- serial_*:
- One of the serial_ functions.
-
- shellscr:
- The name of a shell script. The script must exist
- in /opt/pigpio/cgi and must be executable.
-
- spi_*:
- One of the spi_ functions.
-
- spi_channel: 0-2
- A SPI channel.
-
- spi_flags: 32 bit
- See [*spi_open*].
-
- steady: 0-300000
-
- The number of microseconds level changes must be stable for
- before reporting the level changed ([*set_glitch_filter*])
- or triggering the active part of a noise filter
- ([*set_noise_filter*]).
-
- t1:
- A tick (earlier).
-
- t2:
- A tick (later).
-
- tty:
- A Pi serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0
-
- uint32:
- An unsigned 32 bit number.
-
- user_gpio: 0-31
- A Broadcom numbered GPIO.
-
- All the user GPIO are in the range 0-31.
-
- Not all the GPIO within this range are usable, some are reserved
- for system use.
-
- See [*gpio*].
-
- wait_timeout: 0.0 -
- The number of seconds to wait in [*wait_for_edge*] before timing out.
-
- wave_add_*:
- One of [*wave_add_new*] , [*wave_add_generic*], [*wave_add_serial*].
-
- wave_id: >=0
- A number referencing a wave created by [*wave_create*].
-
- wave_send_*:
- One of [*wave_send_once*], [*wave_send_repeat*].
-
- wdog_timeout: 0-60000
- Defines a GPIO watchdog timeout in milliseconds. If no level
- change is detected on the GPIO for timeout millisecond a watchdog
- timeout report is issued (with level TIMEOUT).
-
- word_val: 0-65535
- A whole number.
- """
- pass
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod.1 b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod.1
deleted file mode 100644
index 188f352fa..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod.1
+++ /dev/null
@@ -1,263 +0,0 @@
-
-." Process this file with
-." groff -man -Tascii pigpiod.1
-."
-.TH pigpiod 1 2012-2015 Linux "pigpio archive"
-.SH NAME
-pigpiod - A utility to start the pigpio library as a daemon.
-
-.SH SYNOPSIS
-
-sudo pigpiod [OPTION]...
-.SH DESCRIPTION
-
-
-.ad l
-
-.nh
-pigpiod is a utility which launches the pigpio library as a daemon.
-.br
-
-.br
-Once launched the pigpio library runs in the background accepting commands from the pipe and socket interfaces.
-.br
-
-.br
-The pigpiod utility requires sudo privileges to launch the library but thereafter the pipe and socket commands may be issued by normal users.
-.br
-
-.br
-pigpiod accepts the following configuration options
-.br
-
-.br
-.SH OPTIONS
-
-.IP "\fB-a value\fP"
-DMA memory allocation mode.
-0=AUTO, 1=PMAP, 2=MBOX.
-Default AUTO
-.
-.IP "\fB-b value\fP"
-GPIO sample buffer size in milliseconds.
-100-10000.
-Default 120
-.
-.IP "\fB-c value\fP"
-Library internal settings.
-.
-Default 0
-.
-.IP "\fB-d value\fP"
-Primary DMA channel.
-0-14.
-Default 14
-.
-.IP "\fB-e value\fP"
-Secondary DMA channel.
-0-14.
-Default 6. Preferably use one of DMA channels 0 to 6 for the secondary channel
-.
-.IP "\fB-f\fP"
-Disable fifo interface.
-.
-Default enabled
-.
-.IP "\fB-k\fP"
-Disable local and remote socket interface.
-.
-Default enabled
-.
-.IP "\fB-l\fP"
-Disable remote socket interface.
-.
-Default enabled
-.
-.IP "\fB-n IP address\fP"
-Allow IP address to use the socket interface.
-Name (e.g. paul) or dotted quad (e.g. 192.168.1.66).
-If the -n option is not used all addresses are allowed (unless overridden by the -k or -l options). Multiple -n options are allowed. If -k has been used -n has no effect. If -l has been used only -n localhost has any effect
-.
-.IP "\fB-p value\fP"
-Socket port.
-1024-32000.
-Default 8888
-.
-.IP "\fB-s value\fP"
-Sample rate.
-1, 2, 4, 5, 8, or 10 microseconds.
-Default 5
-.
-.IP "\fB-t value\fP"
-Clock peripheral.
-0=PWM 1=PCM.
-Default PCM. pigpio uses one or both of PCM and PWM. If PCM is used then PWM is available for audio. If PWM is used then PCM is available for audio. If waves or hardware PWM are used neither PWM nor PCM will be available for audio.
-.
-.IP "\fB-v -V\fP"
-Display pigpio version and exit.
-.
-
-.
-.IP "\fB-x mask\fP"
-GPIO which may be updated.
-A 54 bit mask with (1<
-*/
-
-/*
-This version is for pigpio version 56+
-*/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "pigpio.h"
-
-/*
-This program starts the pigpio library as a daemon.
-*/
-
-static unsigned bufferSizeMilliseconds = PI_DEFAULT_BUFFER_MILLIS;
-static unsigned clockMicros = PI_DEFAULT_CLK_MICROS;
-static unsigned clockPeripheral = PI_DEFAULT_CLK_PERIPHERAL;
-static unsigned ifFlags = PI_DEFAULT_IF_FLAGS;
-static unsigned DMAprimaryChannel = PI_DEFAULT_DMA_PRIMARY_CHANNEL;
-static unsigned DMAsecondaryChannel = PI_DEFAULT_DMA_SECONDARY_CHANNEL;
-static unsigned socketPort = PI_DEFAULT_SOCKET_PORT;
-static unsigned memAllocMode = PI_DEFAULT_MEM_ALLOC_MODE;
-static uint64_t updateMask = -1;
-
-static uint32_t cfgInternals = PI_DEFAULT_CFG_INTERNALS;
-
-static int updateMaskSet = 0;
-
-static FILE * errFifo;
-
-static uint32_t sockNetAddr[MAX_CONNECT_ADDRESSES];
-
-static int numSockNetAddr = 0;
-
-void fatal(char *fmt, ...)
-{
- char buf[128];
- va_list ap;
-
- va_start(ap, fmt);
- vsnprintf(buf, sizeof(buf), fmt, ap);
- va_end(ap);
-
- fprintf(stderr, "%s\n", buf);
-
- fflush(stderr);
-
- exit(EXIT_FAILURE);
-}
-
-void usage()
-{
- fprintf(stderr, "\n" \
- "pigpio V%d\n" \
- "Usage: sudo pigpiod [OPTION] ...\n" \
- " -a value, DMA mode, 0=AUTO, 1=PMAP, 2=MBOX, default AUTO\n" \
- " -b value, sample buffer size in ms, default 120\n" \
- " -c value, library internal settings, default 0\n" \
- " -d value, primary DMA channel, 0-14, default 14\n" \
- " -e value, secondary DMA channel, 0-14, default 6\n" \
- " -f, disable fifo interface, default enabled\n" \
- " -k, disable socket interface, default enabled\n" \
- " -l, localhost socket only default local+remote\n" \
- " -n IP addr, allow address, name or dotted, default allow all\n" \
- " -p value, socket port, 1024-32000, default 8888\n" \
- " -s value, sample rate, 1, 2, 4, 5, 8, or 10, default 5\n" \
- " -t value, clock peripheral, 0=PWM 1=PCM, default PCM\n" \
- " -v, -V, display pigpio version and exit\n" \
- " -x mask, GPIO which may be updated, default board GPIO\n" \
- "EXAMPLE\n" \
- "sudo pigpiod -s 2 -b 200 -f\n" \
- " Set a sample rate of 2 microseconds with a 200 millisecond\n" \
- " buffer. Disable the fifo interface.\n" \
- "\n", PIGPIO_VERSION);
-}
-
-static uint64_t getNum(char *str, int *err)
-{
- uint64_t val;
- char *endptr;
-
- *err = 0;
- val = strtoll(str, &endptr, 0);
- if (*endptr) {*err = 1; val = -1;}
- return val;
-}
-
-static uint32_t checkAddr(char *addrStr)
-{
- int err;
- struct addrinfo hints, *res;
- struct sockaddr_in *sin;
- const char *portStr;
- uint32_t addr;
-
- portStr = getenv(PI_ENVPORT);
-
- if (!portStr) portStr = PI_DEFAULT_SOCKET_PORT_STR;
-
- memset (&hints, 0, sizeof (hints));
-
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags |= AI_CANONNAME;
-
- err = getaddrinfo(addrStr, portStr, &hints, &res);
-
- if (err) return 0;
-
- sin = (struct sockaddr_in *)res->ai_addr;
- addr = sin->sin_addr.s_addr;
-
- freeaddrinfo(res);
-
- return addr;
-}
-
-static void initOpts(int argc, char *argv[])
-{
- int opt, err, i;
- uint32_t addr;
- int64_t mask;
-
- while ((opt = getopt(argc, argv, "a:b:c:d:e:fkln:p:s:t:x:vV")) != -1)
- {
- switch (opt)
- {
- case 'a':
- i = getNum(optarg, &err);
- if ((i >= PI_MEM_ALLOC_AUTO) && (i <= PI_MEM_ALLOC_MAILBOX))
- memAllocMode = i;
- else fatal("invalid -a option (%d)", i);
- break;
-
- case 'b':
- i = getNum(optarg, &err);
- if ((i >= PI_BUF_MILLIS_MIN) && (i <= PI_BUF_MILLIS_MAX))
- bufferSizeMilliseconds = i;
- else fatal("invalid -b option (%d)", i);
- break;
-
- case 'c':
- i = getNum(optarg, &err);
- if ((i >= 0) && (i < PI_CFG_ILLEGAL_VAL))
- cfgInternals = i;
- else fatal("invalid -c option (%x)", i);
- break;
-
- case 'd':
- i = getNum(optarg, &err);
- if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
- DMAprimaryChannel = i;
- else fatal("invalid -d option (%d)", i);
- break;
-
- case 'e':
- i = getNum(optarg, &err);
- if ((i >= PI_MIN_DMA_CHANNEL) && (i <= PI_MAX_DMA_CHANNEL))
- DMAsecondaryChannel = i;
- else fatal("invalid -e option (%d)", i);
- break;
-
- case 'f':
- ifFlags |= PI_DISABLE_FIFO_IF;
- break;
-
- case 'k':
- ifFlags |= PI_DISABLE_SOCK_IF;
- break;
-
- case 'l':
- ifFlags |= PI_LOCALHOST_SOCK_IF;
- break;
-
- case 'n':
- addr = checkAddr(optarg);
- if (addr && (numSockNetAddr= PI_MIN_SOCKET_PORT) && (i <= PI_MAX_SOCKET_PORT))
- socketPort = i;
- else fatal("invalid -p option (%d)", i);
- break;
-
- case 's':
- i = getNum(optarg, &err);
-
- switch(i)
- {
- case 1:
- case 2:
- case 4:
- case 5:
- case 8:
- case 10:
- clockMicros = i;
- break;
-
- default:
- fatal("invalid -s option (%d)", i);
- break;
- }
- break;
-
- case 't':
- i = getNum(optarg, &err);
- if ((i >= PI_CLOCK_PWM) && (i <= PI_CLOCK_PCM))
- clockPeripheral = i;
- else fatal("invalid -t option (%d)", i);
- break;
-
- case 'v':
- case 'V':
- printf("%d\n", PIGPIO_VERSION);
- exit(EXIT_SUCCESS);
- break;
-
- case 'x':
- mask = getNum(optarg, &err);
- if (!err)
- {
- updateMask = mask;
- updateMaskSet = 1;
- }
- else fatal("invalid -x option (%s)", optarg);
- break;
-
- default: /* '?' */
- usage();
- exit(EXIT_FAILURE);
- }
- }
-}
-
-void terminate(int signum)
-{
- /* only registered for SIGHUP/SIGTERM */
-
- gpioTerminate();
-
- fprintf(errFifo, "SIGHUP/SIGTERM received\n");
-
- fflush(NULL);
-
- fclose(errFifo);
-
- unlink(PI_ERRFIFO);
-
- exit(0);
-}
-
-
-int main(int argc, char **argv)
-{
- pid_t pid;
- int flags;
-
- /* Fork off the parent process */
-
- pid = fork();
-
- if (pid < 0) { exit(EXIT_FAILURE); }
-
- /* If we got a good PID, then we can exit the parent process. */
-
- if (pid > 0) { exit(EXIT_SUCCESS); }
-
- /* Change the file mode mask */
-
- umask(0);
-
- /* Open any logs here */
-
- /* NONE */
-
- /* Create a new SID for the child process */
-
- if (setsid() < 0) fatal("setsid failed (%m)");
-
- /* Change the current working directory */
-
- if ((chdir("/")) < 0) fatal("chdir failed (%m)");
-
- /* check command line parameters */
-
- initOpts(argc, argv);
-
- /* Close out the standard file descriptors */
-
- fclose(stdin);
- fclose(stdout);
-
- /* configure library */
-
- gpioCfgBufferSize(bufferSizeMilliseconds);
-
- gpioCfgClock(clockMicros, clockPeripheral, 0);
-
- gpioCfgInterfaces(ifFlags);
-
- gpioCfgDMAchannels(DMAprimaryChannel, DMAsecondaryChannel);
-
- gpioCfgSocketPort(socketPort);
-
- gpioCfgMemAlloc(memAllocMode);
-
- if (updateMaskSet) gpioCfgPermissions(updateMask);
-
- gpioCfgNetAddr(numSockNetAddr, sockNetAddr);
-
- gpioCfgSetInternals(cfgInternals);
-
- /* start library */
-
- if (gpioInitialise()< 0) fatal("Can't initialise pigpio library");
-
- /* create pipe for error reporting */
-
- unlink(PI_ERRFIFO);
-
- mkfifo(PI_ERRFIFO, 0664);
-
- if (chmod(PI_ERRFIFO, 0664) < 0)
- fatal("chmod %s failed (%m)", PI_ERRFIFO);
-
- errFifo = freopen(PI_ERRFIFO, "w+", stderr);
-
- if (errFifo)
- {
- /* set stderr non-blocking */
-
- flags = fcntl(fileno(errFifo), F_GETFL, 0);
- fcntl(fileno(errFifo), F_SETFL, flags | O_NONBLOCK);
-
- /* request SIGHUP/SIGTERM from libarary for termination */
-
- gpioSetSignalFunc(SIGHUP, terminate);
- gpioSetSignalFunc(SIGTERM, terminate);
-
- /* sleep forever */
-
- while (1)
- {
- /* cat /dev/pigerr to view daemon errors */
-
- sleep(5);
-
- fflush(errFifo);
- }
- }
- else
- {
- fprintf(stderr, "freopen failed (%m)");
-
- gpioTerminate();
- }
-
- return 0;
-}
-
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.3 b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.3
deleted file mode 100644
index 284a3ae19..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.3
+++ /dev/null
@@ -1,4826 +0,0 @@
-
-." Process this file with
-." groff -man -Tascii pigpiod_if.3
-."
-.TH pigpiod_if 3 2012-2015 Linux "pigpio archive"
-.SH NAME
-pigpiod_if - A C library to interface to the pigpio daemon.
-
-.SH SYNOPSIS
-
-#include
-
-
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt
-
- ./prog
-.SH DESCRIPTION
-
-
-.ad l
-
-.nh
-
-.br
-
-.br
-THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO
-USE THE MORE VERSATILE pigpiod_if2 LIBRARY.
-
-.br
-
-.br
-pigpiod_if is a C library for the Raspberry which allows control
-of the GPIO via the socket interface to the pigpio daemon.
-.br
-
-.br
-
-.br
-.SS Features
-.br
-
-.br
-o hardware timed PWM on any of GPIO 0-31
-
-.br
-
-.br
-o hardware timed servo pulses on any of GPIO 0-31
-
-.br
-
-.br
-o callbacks when any of GPIO 0-31 change state
-
-.br
-
-.br
-o callbacks at timed intervals
-
-.br
-
-.br
-o reading/writing all of the GPIO in a bank as one operation
-
-.br
-
-.br
-o individually setting GPIO modes, reading and writing
-
-.br
-
-.br
-o notifications when any of GPIO 0-31 change state
-
-.br
-
-.br
-o the construction of output waveforms with microsecond timing
-
-.br
-
-.br
-o rudimentary permission control over GPIO
-
-.br
-
-.br
-o a simple interface to start and stop new threads
-
-.br
-
-.br
-o I2C, SPI, and serial link wrappers
-
-.br
-
-.br
-o creating and running scripts on the pigpio daemon
-
-.br
-
-.br
-.SS GPIO
-.br
-
-.br
-ALL GPIO are identified by their Broadcom number.
-
-.br
-
-.br
-.SS Notes
-.br
-
-.br
-The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals.
-
-.br
-
-.br
-.SS Usage
-.br
-
-.br
-Include in your source files.
-
-.br
-
-.br
-Assuming your source is in prog.c use the following command to build
-
-.br
-
-.br
-
-.EX
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt
-.br
-
-.EE
-
-.br
-
-.br
-to run make sure the pigpio daemon is running
-
-.br
-
-.br
-
-.EX
-sudo pigpiod
-.br
-
-.br
- ./prog # sudo is not required to run programs linked to pigpiod_if
-.br
-
-.EE
-
-.br
-
-.br
-For examples see x_pigpiod_if.c within the pigpio archive file.
-
-.br
-
-.br
-.SS Notes
-.br
-
-.br
-All the functions which return an int return < 0 on error
-
-.br
-
-.br
-.SH FUNCTIONS
-
-.IP "\fBdouble time_time(void)\fP"
-.IP "" 4
-Return the current time in seconds since the Epoch.
-
-.IP "\fBvoid time_sleep(double seconds)\fP"
-.IP "" 4
-Delay execution for a given number of seconds.
-
-.br
-
-.br
-
-.EX
-seconds: the number of seconds to delay.
-.br
-
-.EE
-
-.IP "\fBchar *pigpio_error(int errnum)\fP"
-.IP "" 4
-Return a text description for an error code.
-
-.br
-
-.br
-
-.EX
-errnum: the error code.
-.br
-
-.EE
-
-.IP "\fBunsigned pigpiod_if_version(void)\fP"
-.IP "" 4
-Return the pigpiod_if version.
-
-.IP "\fBpthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata)\fP"
-.IP "" 4
-Starts a new thread of execution with thread_func as the main routine.
-
-.br
-
-.br
-
-.EX
-thread_func: the main function for the new thread.
-.br
- userdata: a pointer to an arbitrary argument.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-.br
-
-.br
-The function is passed the single argument userdata.
-
-.br
-
-.br
-The thread can be cancelled by passing the pointer to pthread_t to
-\fBstop_thread\fP.
-
-.IP "\fBvoid stop_thread(pthread_t *pth)\fP"
-.IP "" 4
-Cancels the thread pointed at by pth.
-
-.br
-
-.br
-
-.EX
-pth: the thread to be stopped.
-.br
-
-.EE
-
-.br
-
-.br
-No value is returned.
-
-.br
-
-.br
-The thread to be stopped should have been started with \fBstart_thread\fP.
-
-.IP "\fBint pigpio_start(char *addrStr, char *portStr)\fP"
-.IP "" 4
-Connect to the pigpio daemon. Reserving command and
-notification streams.
-
-.br
-
-.br
-
-.EX
-addrStr: specifies the host or IP address of the Pi running the
-.br
- pigpio daemon. It may be NULL in which case localhost
-.br
- is used unless overridden by the PIGPIO_ADDR environment
-.br
- variable.
-.br
-
-.br
-portStr: specifies the port address used by the Pi running the
-.br
- pigpio daemon. It may be NULL in which case "8888"
-.br
- is used unless overridden by the PIGPIO_PORT environment
-.br
- variable.
-.br
-
-.EE
-
-.IP "\fBvoid pigpio_stop(void)\fP"
-.IP "" 4
-Terminates the connection to the pigpio daemon and releases
-resources used by the library.
-
-.IP "\fBint set_mode(unsigned gpio, unsigned mode)\fP"
-.IP "" 4
-Set the GPIO mode.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53.
-.br
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
-.br
- PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE,
-or PI_NOT_PERMITTED.
-
-.IP "\fBint get_mode(unsigned gpio)\fP"
-.IP "" 4
-Get the GPIO mode.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-
-.IP "\fBint set_pull_up_down(unsigned gpio, unsigned pud)\fP"
-.IP "" 4
-Set or clear the GPIO pull-up/down resistor.
-
-.br
-
-.br
-
-.EX
-gpio: 0-53.
-.br
- pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD,
-or PI_NOT_PERMITTED.
-
-.IP "\fBint gpio_read(unsigned gpio)\fP"
-.IP "" 4
-Read the GPIO level.
-
-.br
-
-.br
-
-.EX
-gpio:0-53.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-
-.IP "\fBint gpio_write(unsigned gpio, unsigned level)\fP"
-.IP "" 4
-Write the GPIO level.
-
-.br
-
-.br
-
-.EX
- gpio: 0-53.
-.br
-level: 0, 1.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL,
-or PI_NOT_PERMITTED.
-
-.br
-
-.br
-Notes
-
-.br
-
-.br
-If PWM or servo pulses are active on the GPIO they are switched off.
-
-.IP "\fBint set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)\fP"
-.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-dutycycle: 0-range (range defaults to 255).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE,
-or PI_NOT_PERMITTED.
-Notes
-
-.br
-
-.br
-The \fBset_PWM_range\fP function may be used to change the
-default range of 255.
-
-.IP "\fBint get_PWM_dutycycle(unsigned user_gpio)\fP"
-.IP "" 4
-Return the PWM dutycycle in use on a GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-.br
-
-.br
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see \fBget_PWM_range\fP).
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-
-.IP "\fBint set_PWM_range(unsigned user_gpio, unsigned range)\fP"
-.IP "" 4
-Set the range of PWM values to be used on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
- range: 25-40000.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE,
-or PI_NOT_PERMITTED.
-
-.br
-
-.br
-Notes
-
-.br
-
-.br
-If PWM is currently active on the GPIO its dutycycle will be
-scaled to reflect the new range.
-
-.br
-
-.br
-The real range, the number of steps between fully off and fully on
-for each of the 18 available GPIO frequencies is
-
-.br
-
-.br
-
-.EX
- 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
-.br
- 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12),
-.br
-2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18)
-.br
-
-.EE
-
-.br
-
-.br
-The real value set by set_PWM_range is (dutycycle * real range) / range.
-
-.IP "\fBint get_PWM_range(unsigned user_gpio)\fP"
-.IP "" 4
-Get the range of PWM values being used on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the dutycycle range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-If a hardware clock or hardware PWM is active on the GPIO the
-reported range will be 1000000 (1M).
-
-.IP "\fBint get_PWM_real_range(unsigned user_gpio)\fP"
-.IP "" 4
-Get the real underlying range of PWM values being used on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the real range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported
-real range will be 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-.br
-
-.br
-
-.IP "\fBint set_PWM_frequency(unsigned user_gpio, unsigned frequency)\fP"
-.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-frequency: >=0 (Hz).
-.br
-
-.EE
-
-.br
-
-.br
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-
-.br
-
-.br
-If PWM is currently active on the GPIO it will be switched
-off and then back on at the new frequency.
-
-.br
-
-.br
-Each GPIO can be independently set to one of 18 different
-PWM frequencies.
-
-.br
-
-.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the pigpio daemon is started.
-
-.br
-
-.br
-The frequencies for each sample rate are:
-
-.br
-
-.br
-
-.EX
- Hertz
-.br
-
-.br
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
-.br
- 1250 1000 800 500 400 250 200 100 50
-.br
-
-.br
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
-.br
- 625 500 400 250 200 125 100 50 25
-.br
-
-.br
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
-.br
- 313 250 200 125 100 63 50 25 13
-.br
-sample
-.br
- rate
-.br
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
-.br
- 250 200 160 100 80 50 40 20 10
-.br
-
-.br
- 8: 5000 2500 1250 1000 625 500 313 250 200
-.br
- 156 125 100 63 50 31 25 13 6
-.br
-
-.br
- 10: 4000 2000 1000 800 500 400 250 200 160
-.br
- 125 100 80 50 40 25 20 10 5
-.br
-
-.EE
-
-.IP "\fBint get_PWM_frequency(unsigned user_gpio)\fP"
-.IP "" 4
-Get the frequency of PWM being used on the GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-For normal PWM the frequency will be that defined for the GPIO by
-\fBset_PWM_frequency\fP.
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by \fBhardware_clock\fP.
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by \fBhardware_PWM\fP.
-
-.br
-
-.br
-Returns the frequency (in hertz) used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.IP "\fBint set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth)\fP"
-.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the GPIO.
-
-.br
-
-.br
-
-.EX
- user_gpio: 0-31.
-.br
-pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or
-PI_NOT_PERMITTED.
-
-.br
-
-.br
-The selected pulsewidth will continue to be transmitted until
-changed by a subsequent call to set_servo_pulsewidth.
-
-.br
-
-.br
-The pulsewidths supported by servos varies and should probably be
-determined by experiment. A value of 1500 should always be safe and
-represents the mid-point of rotation.
-
-.br
-
-.br
-You can DAMAGE a servo if you command it to move beyond its limits.
-
-.br
-
-.br
-OTHER UPDATE RATES:
-
-.br
-
-.br
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-.br
-
-.br
-
-.EX
-Update Rate (Hz) 50 100 200 400 500
-.br
-1E6/Hz 20000 10000 5000 2500 2000
-.br
-
-.EE
-
-.br
-
-.br
-Firstly set the desired PWM frequency using \fBset_PWM_frequency\fP.
-
-.br
-
-.br
-Then set the PWM range using \fBset_PWM_range\fP to 1E6/Hz.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-.br
-
-.br
-E.g. If you want to update a servo connected to GPIO 25 at 400Hz
-
-.br
-
-.br
-
-.EX
-set_PWM_frequency(25, 400);
-.br
-set_PWM_range(25, 2500);
-.br
-
-.EE
-
-.br
-
-.br
-Thereafter use the \fBset_PWM_dutycycle\fP function to move the servo,
-e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
-.br
-
-.IP "\fBint get_servo_pulsewidth(unsigned user_gpio)\fP"
-.IP "" 4
-Return the servo pulsewidth in use on a GPIO.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-
-.IP "\fBint notify_open(void)\fP"
-.IP "" 4
-Get a free notification handle.
-
-.br
-
-.br
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-.br
-
-.br
-A notification is a method for being notified of GPIO state
-changes via a pipe.
-
-.br
-
-.br
-Pipes are only accessible from the local machine so this function
-serves no purpose if you are using the library from a remote machine.
-The in-built (socket) notifications provided by \fBcallback\fP
-should be used instead.
-
-.br
-
-.br
-Notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number).
-E.g. if the function returns 15 then the notifications must be
-read from /dev/pigpio15.
-
-.IP "\fBint notify_begin(unsigned handle, uint32_t bits)\fP"
-.IP "" 4
-Start notifications on a previously opened handle.
-
-.br
-
-.br
-
-.EX
-handle: 0-31 (as returned by \fBnotify_open\fP)
-.br
- bits: a mask indicating the GPIO to be notified.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-The notification sends state changes for each GPIO whose
-corresponding bit in bits is set.
-
-.br
-
-.br
-Each notification occupies 12 bytes in the fifo as follows:
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t seqno;
-.br
- uint16_t flags;
-.br
- uint32_t tick;
-.br
- uint32_t level;
-.br
-} gpioReport_t;
-.br
-
-.EE
-
-.br
-
-.br
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-.br
-
-.br
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-.br
-
-.br
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-.br
-
-.br
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-.br
-
-.br
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-.br
-
-.br
-level: indicates the level of each GPIO. If bit 1<=0
-.br
- numBytes: >=1
-.br
- str: an array of chars.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-NOTES:
-
-.br
-
-.br
-The serial data is formatted as one start bit, \fBdata_bits\fP data bits,
-and \fBstop_bits\fP/2 stop bits.
-
-.br
-
-.br
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-.br
-
-.br
-\fBnumBytes\fP is the number of bytes of data in str.
-
-.br
-
-.br
-The bytes required for each character depend upon \fBdata_bits\fP.
-
-.br
-
-.br
-For \fBdata_bits\fP 1-8 there will be one byte per character.
-.br
-For \fBdata_bits\fP 9-16 there will be two bytes per character.
-.br
-For \fBdata_bits\fP 17-32 there will be four bytes per character.
-
-.IP "\fBint wave_create(void)\fP"
-.IP "" 4
-This function creates a waveform from the data provided by the prior
-calls to the \fBwave_add_*\fP functions. Upon success a wave id
-greater than or equal to 0 is returned, otherwise PI_EMPTY_WAVEFORM,
-PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
-
-.br
-
-.br
-The data provided by the \fBwave_add_*\fP functions is consumed by this
-function.
-
-.br
-
-.br
-As many waveforms may be created as there is space available. The
-wave id is passed to \fBwave_send_*\fP to specify the waveform to transmit.
-
-.br
-
-.br
-Normal usage would be
-
-.br
-
-.br
-Step 1. \fBwave_clear\fP to clear all waveforms and added data.
-
-.br
-
-.br
-Step 2. \fBwave_add_*\fP calls to supply the waveform data.
-
-.br
-
-.br
-Step 3. \fBwave_create\fP to create the waveform and get a unique id
-
-.br
-
-.br
-Repeat steps 2 and 3 as needed.
-
-.br
-
-.br
-Step 4. \fBwave_send_*\fP with the id of the waveform to transmit.
-
-.br
-
-.br
-A waveform comprises one or more pulses. Each pulse consists of a
-\fBgpioPulse_t\fP structure.
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint32_t gpioOn;
-.br
- uint32_t gpioOff;
-.br
- uint32_t usDelay;
-.br
-} gpioPulse_t;
-.br
-
-.EE
-
-.br
-
-.br
-The fields specify
-
-.br
-
-.br
-1) the GPIO to be switched on at the start of the pulse.
-.br
-2) the GPIO to be switched off at the start of the pulse.
-.br
-3) the delay in microseconds before the next pulse.
-.br
-
-.br
-
-.br
-Any or all the fields can be zero. It doesn't make any sense to
-set all the fields to zero (the pulse will be ignored).
-
-.br
-
-.br
-When a waveform is started each pulse is executed in order with the
-specified delay between the pulse and the next.
-
-.br
-
-.br
-Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
-PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
-
-.IP "\fBint wave_delete(unsigned wave_id)\fP"
-.IP "" 4
-This function deletes the waveform with id wave_id.
-
-.br
-
-.br
-
-.EX
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-
-.IP "\fBint wave_send_once(unsigned wave_id)\fP"
-.IP "" 4
-This function transmits the waveform with id wave_id. The waveform
-is sent once.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-
-.EX
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint wave_send_repeat(unsigned wave_id)\fP"
-.IP "" 4
-This function transmits the waveform with id wave_id. The waveform
-cycles until cancelled (either by the sending of a new waveform or
-by \fBwave_tx_stop\fP).
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-
-.EX
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint wave_chain(char *buf, unsigned bufSize)\fP"
-.IP "" 4
-This function transmits a chain of waveforms.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of \fBwave_id\fPs and optional command
-codes and related data.
-
-.br
-
-.br
-
-.EX
- buf: pointer to the wave_ids and optional command codes
-.br
-bufSize: the number of bytes in buf
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-.br
-
-.br
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-.br
-
-.br
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-.br
-
-.br
-Delays between waves may be added with the delay command.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-Loop Start 255 0 Identify start of a wave block
-.br
-Loop Repeat 255 1 x y loop x + y*256 times
-.br
-Delay 255 2 x y delay x + y*256 microseconds
-.br
-Loop Forever 255 3 loop forever
-.br
-
-.br
-
-.br
-If present Loop Forever must be the last entry in the chain.
-
-.br
-
-.br
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-#define WAVES 5
-.br
-#define GPIO 4
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int i, wid[WAVES];
-.br
-
-.br
- if (pigpio_start(0, 0)<0) return -1;
-.br
-
-.br
- set_mode(GPIO, PI_OUTPUT);
-.br
-
-.br
- for (i=0; i=0, as returned by \fBstore_script\fP.
-.br
- numPar: 0-10, the number of parameters.
-.br
- param: an array of parameters.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
-PI_TOO_MANY_PARAM
-
-.br
-
-.br
-param is an array of up to 10 parameters which may be referenced in
-the script as p0 to p9.
-
-.IP "\fBint script_status(unsigned script_id, uint32_t *param)\fP"
-.IP "" 4
-This function returns the run status of a stored script as well
-as the current values of parameters 0 to 9.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
- param: an array to hold the returned 10 parameters.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns greater than or equal to 0 if OK,
-otherwise PI_BAD_SCRIPT_ID.
-
-.br
-
-.br
-The run status may be
-
-.br
-
-.br
-
-.EX
-PI_SCRIPT_INITING
-.br
-PI_SCRIPT_HALTED
-.br
-PI_SCRIPT_RUNNING
-.br
-PI_SCRIPT_WAITING
-.br
-PI_SCRIPT_FAILED
-.br
-
-.EE
-
-.br
-
-.br
-The current value of script parameters 0 to 9 are returned in param.
-
-.IP "\fBint stop_script(unsigned script_id)\fP"
-.IP "" 4
-This function stops a running script.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint delete_script(unsigned script_id)\fP"
-.IP "" 4
-This function deletes a stored script.
-
-.br
-
-.br
-
-.EX
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
-.IP "" 4
-This function opens a GPIO for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
- baud: 50-250000
-.br
-data_bits: 1-32
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
-or PI_GPIO_IN_USE.
-
-.br
-
-.br
-The serial data is returned in a cyclic buffer and is read using
-bb_serial_read.
-
-.br
-
-.br
-It is the caller's responsibility to read data from the cyclic buffer
-in a timely fashion.
-
-.IP "\fBint bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)\fP"
-.IP "" 4
-This function copies up to bufSize bytes of data read from the
-bit bang serial cyclic buffer to the buffer starting at buf.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
- buf: an array to receive the read bytes.
-.br
- bufSize: >=0
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
-or PI_NOT_SERIAL_GPIO.
-
-.br
-
-.br
-The bytes returned for each character depend upon the number of
-data bits \fBdata_bits\fP specified in the \fBbb_serial_read_open\fP command.
-
-.br
-
-.br
-For \fBdata_bits\fP 1-8 there will be one byte per character.
-.br
-For \fBdata_bits\fP 9-16 there will be two bytes per character.
-.br
-For \fBdata_bits\fP 17-32 there will be four bytes per character.
-
-.IP "\fBint bb_serial_read_close(unsigned user_gpio)\fP"
-.IP "" 4
-This function closes a GPIO for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
-
-.IP "\fBint bb_serial_invert(unsigned user_gpio, unsigned invert)\fP"
-.IP "" 4
-This function inverts serial logic for big bang serial reads.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
- invert: 0-1, 1 invert, 0 normal.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
-
-.IP "\fBint i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP"
-.IP "" 4
-This returns a handle for the device at address i2c_addr on bus i2c_bus.
-
-.br
-
-.br
-
-.EX
- i2c_bus: >=0.
-.br
- i2c_addr: 0-0x7F.
-.br
-i2c_flags: 0.
-.br
-
-.EE
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.br
-
-.br
-Physically buses 0 and 1 are available on the Pi. Higher numbered buses
-will be available if a kernel supported bus multiplexor is being used.
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
-PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
-
-.br
-
-.br
-For the SMBus commands the low level transactions are shown at the end
-of the function description. The following abbreviations are used.
-
-.br
-
-.br
-
-.EX
-S (1 bit) : Start bit
-.br
-P (1 bit) : Stop bit
-.br
-Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
-.br
-A, NA (1 bit) : Accept and not accept bit.
-.br
-.br
-.br
-Addr (7 bits): I2C 7 bit address.
-.br
-Comm (8 bits): Command byte, a data byte which often selects a register.
-.br
-Data (8 bits): A data byte.
-.br
-Count (8 bits): A data byte containing the length of a block operation.
-.br
-
-.br
-[..]: Data sent by the device.
-.br
-
-.EE
-
-.IP "\fBint i2c_close(unsigned handle)\fP"
-.IP "" 4
-This closes the I2C device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint i2c_write_quick(unsigned handle, unsigned bit)\fP"
-.IP "" 4
-This sends a single bit (in the Rd/Wr bit) to the device associated
-with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- bit: 0-1, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Quick command. SMBus 2.0 5.5.1
-
-.EX
-S Addr Rd/Wr [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_byte(unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This sends a single byte to the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- bVal: 0-0xFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Send byte. SMBus 2.0 5.5.2
-
-.EX
-S Addr Wr [A] Data [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_byte(unsigned handle)\fP"
-.IP "" 4
-This reads a single byte from the device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Receive byte. SMBus 2.0 5.5.3
-
-.EX
-S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal)\fP"
-.IP "" 4
-This writes a single byte to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- bVal: 0-0xFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write byte. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] Comm [A] Data [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
-.IP "" 4
-This writes a single 16 bit word to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- wVal: 0-0xFFFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write word. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_byte_data(unsigned handle, unsigned i2c_reg)\fP"
-.IP "" 4
-This reads a single byte from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read byte. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_word_data(unsigned handle, unsigned i2c_reg)\fP"
-.IP "" 4
-This reads a single 16 bit word from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read word. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
-.IP "" 4
-This writes 16 bits of data to the specified register of the device
-associated with handle and and reads 16 bits of data in return.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write/read.
-.br
- wVal: 0-0xFFFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Process call. SMBus 2.0 5.5.6
-
-.EX
-S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
-.br
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes up to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- buf: an array with the data to send.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Block write. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf)\fP"
-.IP "" 4
-This reads a block of up to 32 bytes from the specified register of
-the device associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
- buf: an array to receive the read data.
-.br
-
-.EE
-
-.br
-
-.br
-The amount of returned data is set by the device.
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Block read. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] Comm [A]
-.br
- S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_block_process_call(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes data bytes to the specified register of the device
-associated with handle and reads a device specified number
-of bytes of data in return.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write/read.
-.br
- buf: an array with the data to send and to receive the read data.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-The smbus 2.0 documentation states that a minimum of 1 byte may be
-sent and a minimum of 1 byte may be received. The total number of
-bytes sent/received must be 32 or less.
-
-.br
-
-.br
-Block write-block read. SMBus 2.0 5.5.8
-
-.EX
-S Addr Wr [A] Comm [A] Count [A] Data [A] ...
-.br
- S Addr Rd [A] [Count] A [Data] ... A P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the specified register of the device
-associated with handle . The count may be 1-32.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
- buf: an array to receive the read data.
-.br
- count: 1-32, the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] Comm [A]
-.br
- S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_i2c_block_data(unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes 1 to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- buf: the data to write.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_device(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the raw device into buf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- buf: an array to receive the read data bytes.
-.br
- count: >0, the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_READ_FAILED.
-
-.IP "\fBint i2c_write_device(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes count bytes from buf to the raw device.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- buf: an array containing the data bytes to write.
-.br
- count: >0, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.IP "\fBint i2c_zip(unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN.
-PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-On 2 Switch combined flag on
-.br
-Off 3 Switch combined flag off
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address defaults to that associated with the handle.
-The flags default to 0. The address and flags maintain their
-previous value until updated.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53, write 0x32, read 6 bytes
-.br
-Set address 0x1E, write 0x03, read 6 bytes
-.br
-Set address 0x68, write 0x1B, read 8 bytes
-.br
-End
-.br
-
-.br
-0x04 0x53 0x07 0x01 0x32 0x06 0x06
-.br
-0x04 0x1E 0x07 0x01 0x03 0x06 0x06
-.br
-0x04 0x68 0x07 0x01 0x1B 0x06 0x08
-.br
-0x00
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBint bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud)\fP"
-.IP "" 4
-This function selects a pair of GPIO for bit banging I2C at a
-specified baud rate.
-
-.br
-
-.br
-Bit banging I2C allows for certain operations which are not possible
-with the standard I2C driver.
-
-.br
-
-.br
-o baud rates as low as 50
-.br
-o repeated starts
-.br
-o clock stretching
-.br
-o I2C on any pair of spare GPIO
-
-.br
-
-.br
-
-.EX
- SDA: 0-31
-.br
- SCL: 0-31
-.br
-baud: 50-500000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
-PI_GPIO_IN_USE.
-
-.br
-
-.br
-NOTE:
-
-.br
-
-.br
-The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
-a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-
-.IP "\fBint bb_i2c_close(unsigned SDA)\fP"
-.IP "" 4
-This function stops bit banging I2C on a pair of GPIO previously
-opened with \fBbb_i2c_open\fP.
-
-.br
-
-.br
-
-.EX
-SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-
-.IP "\fBint bb_i2c_zip(unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of bit banged I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
- SDA: 0-31 (as used in a prior call to \fBbb_i2c_open\fP)
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER,
-PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN,
-PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-Start 2 Start condition
-.br
-Stop 3 Stop condition
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address and flags default to 0. The address and flags maintain
-their previous value until updated.
-
-.br
-
-.br
-No flags are currently defined.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53
-.br
-start, write 0x32, (re)start, read 6 bytes, stop
-.br
-Set address 0x1E
-.br
-start, write 0x03, (re)start, read 6 bytes, stop
-.br
-Set address 0x68
-.br
-start, write 0x1B, (re)start, read 8 bytes, stop
-.br
-End
-.br
-
-.br
-0x04 0x53
-.br
-0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x1E
-.br
-0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x68
-.br
-0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-.br
-
-.br
-0x00
-.br
-
-.EE
-
-.IP "\fBint spi_open(unsigned spi_channel, unsigned baud, unsigned spi_flags)\fP"
-.IP "" 4
-This function returns a handle for the SPI device on channel.
-Data will be transferred at baud bits per second. The flags may
-be used to modify the default behaviour of 4-wire operation, mode 0,
-active low chip select.
-
-.br
-
-.br
-An auxiliary SPI device is available on all models but the
-A and B and may be selected by setting the A bit in the
-flags. The auxiliary device has 3 chip selects and a
-selectable word size in bits.
-
-.br
-
-.br
-
-.EX
-spi_channel: 0-1 (0-2 for the auxiliary SPI device).
-.br
- baud: 32K-125M (values above 30M are unlikely to work).
-.br
- spi_flags: see below.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
-PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
-
-.br
-
-.br
-spi_flags consists of the least significant 22 bits.
-
-.br
-
-.br
-
-.EX
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-.br
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
-.br
-
-.EE
-
-.br
-
-.br
-mm defines the SPI mode.
-
-.br
-
-.br
-Warning: modes 1 and 3 do not appear to work on the auxiliary device.
-
-.br
-
-.br
-
-.EX
-Mode POL PHA
-.br
- 0 0 0
-.br
- 1 0 1
-.br
- 2 1 0
-.br
- 3 1 1
-.br
-
-.EE
-
-.br
-
-.br
-px is 0 if CEx is active low (default) and 1 for active high.
-
-.br
-
-.br
-ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-
-.br
-
-.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
-.br
-
-.br
-W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
-SPI device only.
-
-.br
-
-.br
-nnnn defines the number of bytes (0-15) to write before switching
-the MOSI line to MISO to read data. This field is ignored
-if W is not set. Standard SPI device only.
-
-.br
-
-.br
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-bbbbbb defines the word size in bits (0-32). The default (0)
-sets 8 bits per word. Auxiliary SPI device only.
-
-.br
-
-.br
-The other bits in flags should be set to zero.
-
-.IP "\fBint spi_close(unsigned handle)\fP"
-.IP "" 4
-This functions closes the SPI device identified by the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint spi_read(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads count bytes of data from the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- buf: an array to receive the read data bytes.
-.br
- count: the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spi_write(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes of data from buf to the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- buf: the data bytes to write.
-.br
- count: the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP"
-.IP "" 4
-This function transfers count bytes of data from txBuf to the SPI
-device associated with the handle. Simultaneously count bytes of
-data are read from the device and placed in rxBuf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- txBuf: the data bytes to write.
-.br
- rxBuf: the received data bytes.
-.br
- count: the number of bytes to transfer.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint serial_open(char *ser_tty, unsigned baud, unsigned ser_flags)\fP"
-.IP "" 4
-This function opens a serial device at a specified baud rate
-with specified flags. The device name must start with
-/dev/tty or /dev/serial.
-
-.br
-
-.br
-
-.EX
- ser_tty: the serial device to open.
-.br
- baud: the baud rate in bits per second, see below.
-.br
-ser_flags: 0.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
-PI_SER_OPEN_FAILED.
-
-.br
-
-.br
-The baud rate must be one of 50, 75, 110, 134, 150,
-200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
-38400, 57600, 115200, or 230400.
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.IP "\fBint serial_close(unsigned handle)\fP"
-.IP "" 4
-This function closes the serial device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint serial_write_byte(unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This function writes bVal to the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_read_byte(unsigned handle)\fP"
-.IP "" 4
-This function reads a byte from the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
-
-.IP "\fBint serial_write(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes from buf to the the serial port
-associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
- buf: the array of bytes to write.
-.br
- count: the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_read(unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads up to count bytes from the the serial port
-associated with handle and writes them to buf.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
- buf: an array to receive the read data.
-.br
- count: the maximum number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_data_available(unsigned handle)\fP"
-.IP "" 4
-Returns the number of bytes available to be read from the
-device associated with handle.
-
-.br
-
-.br
-
-.EX
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes of data available (>=0) if OK,
-otherwise PI_BAD_HANDLE.
-
-.IP "\fBint custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned argc)\fP"
-.IP "" 4
-This function is available for user customisation.
-
-.br
-
-.br
-It returns a single integer value.
-
-.br
-
-.br
-
-.EX
-arg1: >=0
-.br
-arg2: >=0
-.br
-argx: extra (byte) arguments
-.br
-argc: number of extra arguments
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.IP "\fBint custom_2(unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP"
-.IP "" 4
-This function is available for user customisation.
-
-.br
-
-.br
-It differs from custom_1 in that it returns an array of bytes
-rather than just an integer.
-
-.br
-
-.br
-The return value is an integer indicating the number of returned bytes.
-
-.EX
- arg1: >=0
-.br
- argc: extra (byte) arguments
-.br
- count: number of extra arguments
-.br
-retBuf: buffer for returned data
-.br
-retMax: maximum number of bytes to return
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.br
-
-.br
-Note, the number of returned bytes will be retMax or less.
-
-.IP "\fBint callback(unsigned user_gpio, unsigned edge, CBFunc_t f)\fP"
-.IP "" 4
-This function initialises a new callback.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- f: the callback function.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-.br
-
-.br
-The callback is called with the GPIO, edge, and tick, whenever the
-GPIO has the identified edge.
-
-.IP "\fBint callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-This function initialises a new callback.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- f: the callback function.
-.br
- userdata: a pointer to arbitrary user data.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-.br
-
-.br
-The callback is called with the GPIO, edge, tick, and user, whenever
-the GPIO has the identified edge.
-
-.br
-
-.br
-
-.IP "\fBint callback_cancel(unsigned callback_id)\fP"
-.IP "" 4
-This function cancels a callback identified by its id.
-
-.br
-
-.br
-
-.EX
-callback_id: >=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise pigif_callback_not_found.
-
-.IP "\fBint wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)\fP"
-.IP "" 4
-This function waits for edge on the GPIO for up to timeout
-seconds.
-
-.br
-
-.br
-
-.EX
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- timeout: >=0.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 1 if the edge occurred, otherwise 0.
-
-.br
-
-.br
-The function returns when the edge occurs or after the timeout.
-.SH PARAMETERS
-
-.br
-
-.br
-
-.IP "\fBactive\fP: 0-1000000" 0
-
-.br
-
-.br
-The number of microseconds level changes are reported for once
-a noise filter has been triggered (by \fBsteady\fP microseconds of
-a stable level).
-
-.br
-
-.br
-
-.IP "\fB*addrStr\fP" 0
-A string specifying the host or IP address of the Pi running
-the pigpio daemon. It may be NULL in which case localhost
-is used unless overridden by the PIGPIO_ADDR environment
-variable.
-
-.br
-
-.br
-
-.IP "\fBarg1\fP" 0
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBarg2\fP" 0
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBargc\fP" 0
-The count of bytes passed to a user customised function.
-
-.br
-
-.br
-
-.IP "\fB*argx\fP" 0
-A pointer to an array of bytes passed to a user customised function.
-Its meaning and content is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBbaud\fP" 0
-The speed of serial communication (I2C, SPI, serial link, waves) in
-bits per second.
-
-.br
-
-.br
-
-.IP "\fBbit\fP" 0
-A value of 0 or 1.
-
-.br
-
-.br
-
-.IP "\fBbits\fP" 0
-A value used to select GPIO. If bit n of bits is set then GPIO n is
-selected.
-
-.br
-
-.br
-A convenient way to set bit n is to or in (1<=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP. This is
-passed to \fBcallback_cancel\fP to cancel the callback.
-
-.br
-
-.br
-
-.IP "\fBCBFunc_t\fP" 0
-
-.EX
-typedef void (*CBFunc_t)
-.br
- (unsigned user_gpio, unsigned level, uint32_t tick);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBCBFuncEx_t\fP" 0
-
-.EX
-typedef void (*CBFuncEx_t)
-.br
- (unsigned user_gpio, unsigned level, uint32_t tick, void * user);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBchar\fP" 0
-A single character, an 8 bit quantity able to store 0-255.
-
-.br
-
-.br
-
-.IP "\fBclkfreq\fP: 4689-250000000 (250M)" 0
-The hardware clock frequency.
-
-.br
-
-.br
-
-.IP "\fBcount\fP" 0
-The number of bytes to be transferred in an I2C, SPI, or Serial
-command.
-
-.br
-
-.br
-
-.IP "\fBdata_bits\fP: 1-32" 0
-The number of data bits in each character of serial data.
-
-.br
-
-.br
-
-.EX
-#define PI_MIN_WAVE_DATABITS 1
-.br
-#define PI_MAX_WAVE_DATABITS 32
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBdouble\fP" 0
-A floating point number.
-
-.br
-
-.br
-
-.IP "\fBdutycycle\fP: 0-range" 0
-A number representing the ratio of on time to off time for PWM.
-
-.br
-
-.br
-The number may vary between 0 and range (default 255) where
-0 is off and range is fully on.
-
-.br
-
-.br
-
-.IP "\fBedge\fP" 0
-Used to identify a GPIO level transition of interest. A rising edge is
-a level change from 0 to 1. A falling edge is a level change from 1 to 0.
-
-.br
-
-.br
-
-.EX
-RISING_EDGE 0
-.br
-FALLING_EDGE 1
-.br
-EITHER_EDGE. 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBerrnum\fP" 0
-A negative number indicating a function call failed and the nature
-of the error.
-
-.br
-
-.br
-
-.IP "\fBf\fP" 0
-A function.
-
-.br
-
-.br
-
-.IP "\fBfrequency\fP: >=0" 0
-The number of times a GPIO is swiched on and off per second. This
-can be set per GPIO and may be as little as 5Hz or as much as
-40KHz. The GPIO will be on for a proportion of the time as defined
-by its dutycycle.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fBgpio\fP" 0
-A Broadcom numbered GPIO, in the range 0-53.
-
-.br
-
-.br
-There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
-gpio53.
-
-.br
-
-.br
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
-
-.br
-
-.br
-All the GPIO which are safe for the user to read and write are in
-bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
-have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
-.br
-
-.br
-See \fBget_hardware_revision\fP.
-
-.br
-
-.br
-The user GPIO are marked with an X in the following table.
-
-.br
-
-.br
-
-.EX
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-.br
-Type 1 X X - - X - - X X X X X - - X X
-.br
-Type 2 - - X X X - - X X X X X - - X X
-.br
-Type 3 X X X X X X X X X X X X X X
-.br
-
-.br
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
-.br
-Type 1 - X X - - X X X X X - - - - - -
-.br
-Type 2 - X X - - - X X X X - X X X X X
-.br
-Type 3 X X X X X X X X X X X X - - - -
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioPulse_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
-uint32_t gpioOn;
-.br
-uint32_t gpioOff;
-.br
-uint32_t usDelay;
-.br
-} gpioPulse_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioThreadFunc_t\fP" 0
-
-.EX
-typedef void *(gpioThreadFunc_t) (void *);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBhandle\fP: >=0" 0
-A number referencing an object opened by one of \fBi2c_open\fP, \fBnotify_open\fP,
-\fBserial_open\fP, and \fBspi_open\fP.
-
-.br
-
-.br
-
-.IP "\fBi2c_addr\fP: 0-0x7F" 0
-The address of a device on the I2C bus.
-
-.br
-
-.br
-
-.IP "\fBi2c_bus\fP: >=0" 0
-An I2C bus number.
-
-.br
-
-.br
-
-.IP "\fBi2c_flags\fP: 0" 0
-Flags which modify an I2C open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fBi2c_reg\fP: 0-255" 0
-A register of an I2C device.
-
-.br
-
-.br
-
-.IP "\fB*inBuf\fP" 0
-A buffer used to pass data to a function.
-
-.br
-
-.br
-
-.IP "\fBinLen\fP" 0
-The number of bytes of data in a buffer.
-
-.br
-
-.br
-
-.IP "\fBint\fP" 0
-A whole number, negative or positive.
-
-.br
-
-.br
-
-.IP "\fBinvert\fP" 0
-A flag used to set normal or inverted bit bang serial data level logic.
-
-.br
-
-.br
-
-.IP "\fBlevel\fP" 0
-The level of a GPIO. Low or High.
-
-.br
-
-.br
-
-.EX
-PI_OFF 0
-.br
-PI_ON 1
-.br
-
-.br
-PI_CLEAR 0
-.br
-PI_SET 1
-.br
-
-.br
-PI_LOW 0
-.br
-PI_HIGH 1
-.br
-
-.EE
-
-.br
-
-.br
-There is one exception. If a watchdog expires on a GPIO the level will be
-reported as PI_TIMEOUT. See \fBset_watchdog\fP.
-
-.br
-
-.br
-
-.EX
-PI_TIMEOUT 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBmode\fP: 0-7" 0
-The operational mode of a GPIO, normally INPUT or OUTPUT.
-
-.br
-
-.br
-
-.EX
-PI_INPUT 0
-.br
-PI_OUTPUT 1
-.br
-PI_ALT0 4
-.br
-PI_ALT1 5
-.br
-PI_ALT2 6
-.br
-PI_ALT3 7
-.br
-PI_ALT4 3
-.br
-PI_ALT5 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBnumBytes\fP" 0
-The number of bytes used to store characters in a string. Depending
-on the number of bits per character there may be 1, 2, or 4 bytes
-per character.
-
-.br
-
-.br
-
-.IP "\fBnumPar\fP: 0-10" 0
-The number of parameters passed to a script.
-
-.br
-
-.br
-
-.IP "\fBnumPulses\fP" 0
-The number of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBoffset\fP" 0
-The associated data starts this number of microseconds from the start of
-the waveform.
-
-.br
-
-.br
-
-.IP "\fB*outBuf\fP" 0
-A buffer used to return data from a function.
-
-.br
-
-.br
-
-.IP "\fBoutLen\fP" 0
-The size in bytes of an output buffer.
-
-.br
-
-.br
-
-.IP "\fB*param\fP" 0
-An array of script parameters.
-
-.br
-
-.br
-
-.IP "\fB*portStr\fP" 0
-A string specifying the port address used by the Pi running
-the pigpio daemon. It may be NULL in which case "8888"
-is used unless overridden by the PIGPIO_PORT environment
-variable.
-
-.br
-
-.br
-
-.IP "\fB*pth\fP" 0
-A thread identifier, returned by \fBstart_thread\fP.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fBpthread_t\fP" 0
-A thread identifier.
-
-.br
-
-.br
-
-.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a GPIO, which may be off,
-pull-up, or pull-down.
-
-.EX
-PI_PUD_OFF 0
-.br
-PI_PUD_DOWN 1
-.br
-PI_PUD_UP 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBpulseLen\fP" 0
-1-100, the length of a trigger pulse in microseconds.
-
-.br
-
-.br
-
-.IP "\fB*pulses\fP" 0
-An array of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBpulsewidth\fP: 0, 500-2500" 0
-
-.EX
-PI_SERVO_OFF 0
-.br
-PI_MIN_SERVO_PULSEWIDTH 500
-.br
-PI_MAX_SERVO_PULSEWIDTH 2500
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0
-The hardware PWM dutycycle.
-
-.br
-
-.br
-
-.EX
-#define PI_HW_PWM_RANGE 1000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMfreq\fP: 1-125000000 (125M)" 0
-The hardware PWM frequency.
-
-.br
-
-.br
-
-.EX
-#define PI_HW_PWM_MIN_FREQ 1
-.br
-#define PI_HW_PWM_MAX_FREQ 125000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrange\fP: 25-40000" 0
-The permissible dutycycle values are 0-range.
-
-.EX
-PI_MIN_DUTYCYCLE_RANGE 25
-.br
-PI_MAX_DUTYCYCLE_RANGE 40000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*retBuf\fP" 0
-A buffer to hold a number of bytes returned to a used customised function,
-
-.br
-
-.br
-
-.IP "\fBretMax\fP" 0
-The maximum number of bytes a user customised function should return.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fB*rxBuf\fP" 0
-A pointer to a buffer to receive data.
-
-.br
-
-.br
-
-.IP "\fBSCL\fP" 0
-The user GPIO to use for the clock when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fB*script\fP" 0
-A pointer to the text of a script.
-
-.br
-
-.br
-
-.IP "\fBscript_id\fP" 0
-An id of a stored script as returned by \fBstore_script\fP.
-
-.br
-
-.br
-
-.IP "\fBSDA\fP" 0
-The user GPIO to use for data when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fBseconds\fP" 0
-The number of seconds.
-
-.br
-
-.br
-
-.IP "\fBser_flags\fP" 0
-Flags which modify a serial open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fB*ser_tty\fP" 0
-The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
-
-.br
-
-.br
-
-.IP "\fBsize_t\fP" 0
-A standard type used to indicate the size of an object in bytes.
-
-.br
-
-.br
-
-.IP "\fBspi_channel\fP" 0
-A SPI channel, 0-2.
-
-.br
-
-.br
-
-.IP "\fBspi_flags\fP" 0
-See \fBspi_open\fP.
-
-.br
-
-.br
-
-.IP "\fBsteady\fP: 0-300000" 0
-
-.br
-
-.br
-The number of microseconds level changes must be stable for
-before reporting the level changed (\fBset_glitch_filter\fP) or triggering
-the active part of a noise filter (\fBset_noise_filter\fP).
-
-.br
-
-.br
-
-.IP "\fBstop_bits\fP: 2-8" 0
-The number of (half) stop bits to be used when adding serial data
-to a waveform.
-
-.br
-
-.br
-
-.EX
-#define PI_MIN_WAVE_HALFSTOPBITS 2
-.br
-#define PI_MAX_WAVE_HALFSTOPBITS 8
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*str\fP" 0
- An array of characters.
-
-.br
-
-.br
-
-.IP "\fBthread_func\fP" 0
-A function of type gpioThreadFunc_t used as the main function of a
-thread.
-
-.br
-
-.br
-
-.IP "\fBtimeout\fP" 0
-A GPIO watchdog timeout in milliseconds.
-
-.EX
-PI_MIN_WDOG_TIMEOUT 0
-.br
-PI_MAX_WDOG_TIMEOUT 60000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*txBuf\fP" 0
-An array of bytes to transmit.
-
-.br
-
-.br
-
-.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0
-A 32-bit unsigned value.
-
-.br
-
-.br
-
-.IP "\fBunsigned\fP" 0
-A whole number >= 0.
-
-.br
-
-.br
-
-.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered GPIO.
-
-.br
-
-.br
-See \fBgpio\fP.
-
-.br
-
-.br
-
-.IP "\fB*userdata\fP" 0
-A pointer to arbitrary user data. This may be used to identify the instance.
-
-.br
-
-.br
-
-.IP "\fBvoid\fP" 0
-Denoting no parameter is required
-
-.br
-
-.br
-
-.IP "\fBwave_add_*\fP" 0
-One of \fBwave_add_new\fP, \fBwave_add_generic\fP, \fBwave_add_serial\fP.
-
-.br
-
-.br
-
-.IP "\fBwave_id\fP" 0
-A number representing a waveform created by \fBwave_create\fP.
-
-.br
-
-.br
-
-.IP "\fBwave_send_*\fP" 0
-One of \fBwave_send_once\fP, \fBwave_send_repeat\fP.
-
-.br
-
-.br
-
-.IP "\fBwVal\fP: 0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)" 0
-A 16-bit word value.
-
-.br
-
-.br
-.SH pigpiod_if Error Codes
-
-.EX
-
-.br
-typedef enum
-.br
-{
-.br
- pigif_bad_send = -2000,
-.br
- pigif_bad_recv = -2001,
-.br
- pigif_bad_getaddrinfo = -2002,
-.br
- pigif_bad_connect = -2003,
-.br
- pigif_bad_socket = -2004,
-.br
- pigif_bad_noib = -2005,
-.br
- pigif_duplicate_callback = -2006,
-.br
- pigif_bad_malloc = -2007,
-.br
- pigif_bad_callback = -2008,
-.br
- pigif_notify_failed = -2009,
-.br
- pigif_callback_not_found = -2010,
-.br
-} pigifError_t;
-.br
-
-.br
-
-.EE
-
-.SH SEE ALSO
-
-pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if2(3)
-.SH AUTHOR
-
-joan@abyz.co.uk
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.c b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.c
deleted file mode 100644
index 3840968a4..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.c
+++ /dev/null
@@ -1,1567 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-/* PIGPIOD_IF_VERSION 25 */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "pigpio.h"
-#include "command.h"
-
-#include "pigpiod_if.h"
-
-#define PISCOPE_MAX_REPORTS_PER_READ 4096
-
-#define STACK_SIZE (256*1024)
-
-typedef void (*CBF_t) ();
-
-struct callback_s
-{
-
- int id;
- int gpio;
- int edge;
- CBF_t f;
- void * user;
- int ex;
- callback_t *prev;
- callback_t *next;
-};
-
-/* GLOBALS ---------------------------------------------------------------- */
-
-static gpioReport_t gReport[PISCOPE_MAX_REPORTS_PER_READ];
-
-static int gPigCommand = -1;
-static int gPigHandle = -1;
-static int gPigNotify = -1;
-
-static uint32_t gNotifyBits;
-static uint32_t gLastLevel;
-
-callback_t *gCallBackFirst = 0;
-callback_t *gCallBackLast = 0;
-
-static int gPigStarted = 0;
-
-static pthread_t *pthNotify;
-
-static pthread_mutex_t command_mutex = PTHREAD_MUTEX_INITIALIZER;
-
-/* PRIVATE ---------------------------------------------------------------- */
-
-static int pigpio_command(int fd, int command, int p1, int p2, int rl)
-{
- cmdCmd_t cmd;
-
- cmd.cmd = command;
- cmd.p1 = p1;
- cmd.p2 = p2;
- cmd.res = 0;
-
- pthread_mutex_lock(&command_mutex);
-
- if (send(fd, &cmd, sizeof(cmd), 0) != sizeof(cmd))
- {
- pthread_mutex_unlock(&command_mutex);
- return pigif_bad_send;
- }
-
- if (recv(fd, &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd))
- {
- pthread_mutex_unlock(&command_mutex);
- return pigif_bad_recv;
- }
-
- if (rl) pthread_mutex_unlock(&command_mutex);
-
- return cmd.res;
-}
-
-static int pigpio_command_ext
- (int fd, int command, int p1, int p2, int p3,
- int extents, gpioExtent_t *ext, int rl)
-{
- int i;
- cmdCmd_t cmd;
-
- cmd.cmd = command;
- cmd.p1 = p1;
- cmd.p2 = p2;
- cmd.p3 = p3;
-
- pthread_mutex_lock(&command_mutex);
-
- if (send(fd, &cmd, sizeof(cmd), 0) != sizeof(cmd))
- {
- pthread_mutex_unlock(&command_mutex);
- return pigif_bad_send;
- }
-
- for (i=0; iai_next)
- {
- sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
-
- if (sock == -1) continue;
-
- /* Disable the Nagle algorithm. */
- opt = 1;
- setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int));
-
- if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break;
- }
-
- freeaddrinfo(res);
-
- if (rp == NULL) return pigif_bad_connect;
-
- return sock;
-}
-
-static void dispatch_notification(gpioReport_t *r)
-{
- callback_t *p;
- uint32_t changed;
- int l, g;
-
- /*
- printf("s=%d f=%d l=%8X, t=%10u\n",
- r->seqno, r->flags, r->level, r->tick);
- */
-
- if (r->flags == 0)
- {
- changed = (r->level ^ gLastLevel) & gNotifyBits;
-
- gLastLevel = r->level;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (changed & (1<<(p->gpio)))
- {
- if ((r->level) & (1<<(p->gpio))) l = 1; else l = 0;
- if ((p->edge) ^ l)
- {
- if (p->ex) (p->f)(p->gpio, l, r->tick, p->user);
- else (p->f)(p->gpio, l, r->tick);
- }
- }
- p = p->next;
- }
- }
- else
- {
- g = (r->flags) & 31;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if ((p->gpio) == g)
- {
- if (p->ex) (p->f)(g, PI_TIMEOUT, r->tick, p->user);
- else (p->f)(g, PI_TIMEOUT, r->tick);
- }
- p = p->next;
- }
- }
-}
-
-static void *pthNotifyThread(void *x)
-{
- static int got = 0;
-
- int bytes, r;
-
- while (1)
- {
- bytes = read(gPigNotify, (char*)&gReport+got, sizeof(gReport)-got);
-
- if (bytes > 0) got += bytes;
- else break;
-
- r = 0;
-
- while (got >= sizeof(gpioReport_t))
- {
- dispatch_notification(&gReport[r]);
-
- r++;
-
- got -= sizeof(gpioReport_t);
- }
-
- /* copy any partial report to start of array */
-
- if (got && r) gReport[0] = gReport[r];
- }
- return 0;
-}
-
-static void findNotifyBits(void)
-{
- callback_t *p;
- uint32_t bits = 0;
-
- p = gCallBackFirst;
-
- while (p)
- {
- bits |= (1<<(p->gpio));
- p = p->next;
- }
-
- if (bits != gNotifyBits)
- {
- gNotifyBits = bits;
- pigpio_command(gPigCommand, PI_CMD_NB, gPigHandle, gNotifyBits, 1);
- }
-}
-
-static void _wfe(unsigned user_gpio, unsigned level, uint32_t tick, void *user)
-{
- *(int *)user = 1;
-}
-
-static int intCallback(unsigned user_gpio, unsigned edge, void *f, void *user, int ex)
-{
- static int id = 0;
- callback_t *p;
-
- if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f)
- {
- /* prevent duplicates */
-
- p = gCallBackFirst;
-
- while (p)
- {
- if ((p->gpio == user_gpio) && (p->edge == edge) && (p->f == f))
- {
- return pigif_duplicate_callback;
- }
- p = p->next;
- }
-
- p = malloc(sizeof(callback_t));
-
- if (p)
- {
- if (!gCallBackFirst) gCallBackFirst = p;
-
- p->id = id++;
- p->gpio = user_gpio;
- p->edge = edge;
- p->f = f;
- p->user = user;
- p->ex = ex;
- p->next = 0;
- p->prev = gCallBackLast;
-
- if (p->prev) (p->prev)->next = p;
- gCallBackLast = p;
-
- findNotifyBits();
-
- return p->id;
- }
-
- return pigif_bad_malloc;
- }
-
- return pigif_bad_callback;
-}
-
-/* PUBLIC ----------------------------------------------------------------- */
-
-double time_time(void)
-{
- struct timeval tv;
- double t;
-
- gettimeofday(&tv, 0);
-
- t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6);
-
- return t;
-}
-
-void time_sleep(double seconds)
-{
- struct timespec ts, rem;
-
- if (seconds > 0.0)
- {
- ts.tv_sec = seconds;
- ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9;
-
- while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem))
- {
- /* copy remaining time to ts */
- ts.tv_sec = rem.tv_sec;
- ts.tv_nsec = rem.tv_nsec;
- }
- }
-}
-
-char *pigpio_error(int errnum)
-{
- if (errnum > -1000) return cmdErrStr(errnum);
- else
- {
- switch(errnum)
- {
- case pigif_bad_send:
- return "failed to send to pigpiod";
- case pigif_bad_recv:
- return "failed to receive from pigpiod";
- case pigif_bad_getaddrinfo:
- return "failed to find address of pigpiod";
- case pigif_bad_connect:
- return "failed to connect to pigpiod";
- case pigif_bad_socket:
- return "failed to create socket";
- case pigif_bad_noib:
- return "failed to open noib";
- case pigif_duplicate_callback:
- return "identical callback exists";
- case pigif_bad_malloc:
- return "failed to malloc";
- case pigif_bad_callback:
- return "bad callback parameter";
- case pigif_notify_failed:
- return "failed to create notification thread";
- case pigif_callback_not_found:
- return "callback not found";
- default:
- return "unknown error";
- }
- }
-}
-
-unsigned pigpiod_if_version(void)
-{
- return PIGPIOD_IF_VERSION;
-}
-
-pthread_t *start_thread(gpioThreadFunc_t thread_func, void *arg)
-{
- pthread_t *pth;
- pthread_attr_t pthAttr;
-
- pth = malloc(sizeof(pthread_t));
-
- if (pth)
- {
- if (pthread_attr_init(&pthAttr))
- {
- perror("pthread_attr_init failed");
- free(pth);
- return NULL;
- }
-
- if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE))
- {
- perror("pthread_attr_setstacksize failed");
- free(pth);
- return NULL;
- }
-
- if (pthread_create(pth, &pthAttr, thread_func, arg))
- {
- perror("pthread_create socket failed");
- free(pth);
- return NULL;
- }
- }
- return pth;
-}
-
-void stop_thread(pthread_t *pth)
-{
- if (pth)
- {
- pthread_cancel(*pth);
- pthread_join(*pth, NULL);
- free(pth);
- }
-}
-
-int pigpio_start(char *addrStr, char *portStr)
-{
- if (!gPigStarted)
- {
- gPigCommand = pigpioOpenSocket(addrStr, portStr);
-
- if (gPigCommand >= 0)
- {
- gPigNotify = pigpioOpenSocket(addrStr, portStr);
-
- if (gPigNotify >= 0)
- {
- gPigHandle = pigpio_command(gPigNotify, PI_CMD_NOIB, 0, 0, 1);
-
- if (gPigHandle < 0) return pigif_bad_noib;
- else
- {
- gLastLevel = read_bank_1();
-
- pthNotify = start_thread(pthNotifyThread, 0);
- if (pthNotify)
- {
- gPigStarted = 1;
- return 0;
- }
- else return pigif_notify_failed;
- }
- }
- else return gPigNotify;
- }
- else return gPigCommand;
- }
- return 0;
-}
-
-void pigpio_stop(void)
-{
- gPigStarted = 0;
-
- if (pthNotify)
- {
- stop_thread(pthNotify);
- pthNotify = 0;
- }
-
- if (gPigNotify >= 0)
- {
- if (gPigHandle >= 0)
- {
- pigpio_command(gPigNotify, PI_CMD_NC, gPigHandle, 0, 1);
- gPigHandle = -1;
- }
-
- close(gPigNotify);
- gPigNotify = -1;
- }
-
- if (gPigCommand >= 0)
- {
- if (gPigHandle >= 0)
- {
- pigpio_command(gPigCommand, PI_CMD_NC, gPigHandle, 0, 1);
- gPigHandle = -1;
- }
-
- close(gPigCommand);
- gPigCommand = -1;
- }
-}
-
-int set_mode(unsigned gpio, unsigned mode)
- {return pigpio_command(gPigCommand, PI_CMD_MODES, gpio, mode, 1);}
-
-int get_mode(unsigned gpio)
- {return pigpio_command(gPigCommand, PI_CMD_MODEG, gpio, 0, 1);}
-
-int set_pull_up_down(unsigned gpio, unsigned pud)
- {return pigpio_command(gPigCommand, PI_CMD_PUD, gpio, pud, 1);}
-
-int gpio_read(unsigned gpio)
- {return pigpio_command(gPigCommand, PI_CMD_READ, gpio, 0, 1);}
-
-int gpio_write(unsigned gpio, unsigned level)
- {return pigpio_command(gPigCommand, PI_CMD_WRITE, gpio, level, 1);}
-
-int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle)
- {return pigpio_command(gPigCommand, PI_CMD_PWM, user_gpio, dutycycle, 1);}
-
-int get_PWM_dutycycle(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_GDC, user_gpio, 0, 1);}
-
-int set_PWM_range(unsigned user_gpio, unsigned range)
- {return pigpio_command(gPigCommand, PI_CMD_PRS, user_gpio, range, 1);}
-
-int get_PWM_range(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_PRG, user_gpio, 0, 1);}
-
-int get_PWM_real_range(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_PRRG, user_gpio, 0, 1);}
-
-int set_PWM_frequency(unsigned user_gpio, unsigned frequency)
- {return pigpio_command(gPigCommand, PI_CMD_PFS, user_gpio, frequency, 1);}
-
-int get_PWM_frequency(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_PFG, user_gpio, 0, 1);}
-
-int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth)
- {return pigpio_command(gPigCommand, PI_CMD_SERVO, user_gpio, pulsewidth, 1);}
-
-int get_servo_pulsewidth(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_GPW, user_gpio, 0, 1);}
-
-int notify_open(void)
- {return pigpio_command(gPigCommand, PI_CMD_NO, 0, 0, 1);}
-
-int notify_begin(unsigned handle, uint32_t bits)
- {return pigpio_command(gPigCommand, PI_CMD_NB, handle, bits, 1);}
-
-int notify_pause(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_NB, handle, 0, 1);}
-
-int notify_close(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_NC, handle, 0, 1);}
-
-int set_watchdog(unsigned user_gpio, unsigned timeout)
- {return pigpio_command(gPigCommand, PI_CMD_WDOG, user_gpio, timeout, 1);}
-
-uint32_t read_bank_1(void)
- {return pigpio_command(gPigCommand, PI_CMD_BR1, 0, 0, 1);}
-
-uint32_t read_bank_2(void)
- {return pigpio_command(gPigCommand, PI_CMD_BR2, 0, 0, 1);}
-
-int clear_bank_1(uint32_t levels)
- {return pigpio_command(gPigCommand, PI_CMD_BC1, levels, 0, 1);}
-
-int clear_bank_2(uint32_t levels)
- {return pigpio_command(gPigCommand, PI_CMD_BC2, levels, 0, 1);}
-
-int set_bank_1(uint32_t levels)
- {return pigpio_command(gPigCommand, PI_CMD_BS1, levels, 0, 1);}
-
-int set_bank_2(uint32_t levels)
- {return pigpio_command(gPigCommand, PI_CMD_BS2, levels, 0, 1);}
-
-int hardware_clock(unsigned gpio, unsigned frequency)
- {return pigpio_command(gPigCommand, PI_CMD_HC, gpio, frequency, 1);}
-
-int hardware_PWM(unsigned gpio, unsigned frequency, uint32_t dutycycle)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=gpio
- p2=frequency
- p3=4
- ## extension ##
- uint32_t dutycycle
- */
-
- ext[0].size = sizeof(dutycycle);
- ext[0].ptr = &dutycycle;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_HP, gpio, frequency, sizeof(dutycycle), 1, ext, 1);
-}
-
-uint32_t get_current_tick(void)
- {return pigpio_command(gPigCommand, PI_CMD_TICK, 0, 0, 1);}
-
-uint32_t get_hardware_revision(void)
- {return pigpio_command(gPigCommand, PI_CMD_HWVER, 0, 0, 1);}
-
-uint32_t get_pigpio_version(void)
- {return pigpio_command(gPigCommand, PI_CMD_PIGPV, 0, 0, 1);}
-
-int wave_clear(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVCLR, 0, 0, 1);}
-
-int wave_add_new(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVNEW, 0, 0, 1);}
-
-int wave_add_generic(unsigned numPulses, gpioPulse_t *pulses)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=pulses*sizeof(gpioPulse_t)
- ## extension ##
- gpioPulse_t[] pulses
- */
-
- if (!numPulses) return 0;
-
- ext[0].size = numPulses * sizeof(gpioPulse_t);
- ext[0].ptr = pulses;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_WVAG, 0, 0, ext[0].size, 1, ext, 1);
-}
-
-int wave_add_serial(
- unsigned user_gpio, unsigned baud, uint32_t databits,
- uint32_t stophalfbits, uint32_t offset, unsigned numChar, char *str)
-{
- uint8_t buf[12];
- gpioExtent_t ext[2];
-
- /*
- p1=user_gpio
- p2=baud
- p3=len+12
- ## extension ##
- uint32_t databits
- uint32_t stophalfbits
- uint32_t offset
- char[len] str
- */
-
- if (!numChar) return 0;
-
- memcpy(buf, &databits, 4);
- memcpy(buf+4, &stophalfbits, 4);
- memcpy(buf+8, &offset, 4);
-
- ext[0].size = sizeof(buf);
- ext[0].ptr = buf;
-
- ext[1].size = numChar;
- ext[1].ptr = str;
-
- return pigpio_command_ext(gPigCommand, PI_CMD_WVAS,
- user_gpio, baud, numChar+sizeof(buf), 2, ext, 1);
-}
-
-int wave_create(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVCRE, 0, 0, 1);}
-
-int wave_delete(unsigned wave_id)
- {return pigpio_command(gPigCommand, PI_CMD_WVDEL, wave_id, 0, 1);}
-
-int wave_tx_start(void) /* DEPRECATED */
- {return pigpio_command(gPigCommand, PI_CMD_WVGO, 0, 0, 1);}
-
-int wave_tx_repeat(void) /* DEPRECATED */
- {return pigpio_command(gPigCommand, PI_CMD_WVGOR, 0, 0, 1);}
-
-int wave_send_once(unsigned wave_id)
- {return pigpio_command(gPigCommand, PI_CMD_WVTX, wave_id, 0, 1);}
-
-int wave_send_repeat(unsigned wave_id)
- {return pigpio_command(gPigCommand, PI_CMD_WVTXR, wave_id, 0, 1);}
-
-int wave_chain(char *buf, unsigned bufSize)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=bufSize
- ## extension ##
- char buf[bufSize]
- */
-
- ext[0].size = bufSize;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1);
-}
-
-int wave_tx_busy(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVBSY, 0, 0, 1);}
-
-int wave_tx_stop(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVHLT, 0, 0, 1);}
-
-int wave_get_micros(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSM, 0, 0, 1);}
-
-int wave_get_high_micros(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSM, 1, 0, 1);}
-
-int wave_get_max_micros(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSM, 2, 0, 1);}
-
-int wave_get_pulses(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSP, 0, 0, 1);}
-
-int wave_get_high_pulses(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSP, 1, 0, 1);}
-
-int wave_get_max_pulses(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSP, 2, 0, 1);}
-
-int wave_get_cbs(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSC, 0, 0, 1);}
-
-int wave_get_high_cbs(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSC, 1, 0, 1);}
-
-int wave_get_max_cbs(void)
- {return pigpio_command(gPigCommand, PI_CMD_WVSC, 2, 0, 1);}
-
-int gpio_trigger(unsigned user_gpio, unsigned pulseLen, uint32_t level)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=pulseLen
- p3=4
- ## extension ##
- unsigned level
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &level;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext, 1);
-}
-
-int set_glitch_filter(unsigned user_gpio, unsigned steady)
- {return pigpio_command(gPigCommand, PI_CMD_FG, user_gpio, steady, 1);}
-
-int set_noise_filter(unsigned user_gpio, unsigned steady, unsigned active)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=steady
- p3=4
- ## extension ##
- unsigned active
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &active;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_FN, user_gpio, steady, 4, 1, ext, 1);
-}
-
-int store_script(char *script)
-{
- unsigned len;
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=len
- ## extension ##
- char[len] script
- */
-
- len = strlen(script);
-
- if (!len) return 0;
-
- ext[0].size = len;
- ext[0].ptr = script;
-
- return pigpio_command_ext(gPigCommand, PI_CMD_PROC, 0, 0, len, 1, ext, 1);
-}
-
-int run_script(unsigned script_id, unsigned numPar, uint32_t *param)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=script id
- p2=0
- p3=numPar * 4
- ## extension ##
- uint32_t[numPar] pars
- */
-
- ext[0].size = 4 * numPar;
- ext[0].ptr = param;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1);
-}
-
-int recvMax(void *buf, int bufsize, int sent)
-{
- uint8_t scratch[4096];
- int remaining, fetch, count;
-
- if (sent < bufsize) count = sent; else count = bufsize;
-
- if (count) recv(gPigCommand, buf, count, MSG_WAITALL);
-
- remaining = sent - count;
-
- while (remaining)
- {
- fetch = remaining;
- if (fetch > sizeof(scratch)) fetch = sizeof(scratch);
- recv(gPigCommand, scratch, fetch, MSG_WAITALL);
- remaining -= fetch;
- }
-
- return count;
-}
-
-int script_status(unsigned script_id, uint32_t *param)
-{
- int status;
- uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */
-
- status = pigpio_command(gPigCommand, PI_CMD_PROCP, script_id, 0, 0);
-
- if (status > 0)
- {
- recvMax(p, sizeof(p), status);
- status = p[0];
- if (param) memcpy(param, p+1, sizeof(p)-4);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return status;
-}
-
-int stop_script(unsigned script_id)
- {return pigpio_command(gPigCommand, PI_CMD_PROCS, script_id, 0, 1);}
-
-int delete_script(unsigned script_id)
- {return pigpio_command(gPigCommand, PI_CMD_PROCD, script_id, 0, 1);}
-
-int bb_serial_read_open(unsigned user_gpio, unsigned baud, uint32_t bbBits)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=baud
- p3=4
- ## extension ##
- unsigned bbBits
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &bbBits;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1);
-}
-
-int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize)
-{
- int bytes;
-
- bytes = pigpio_command(gPigCommand, PI_CMD_SLR, user_gpio, bufSize, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, bufSize, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int bb_serial_read_close(unsigned user_gpio)
- {return pigpio_command(gPigCommand, PI_CMD_SLRC, user_gpio, 0, 1);}
-
-int bb_serial_invert(unsigned user_gpio, unsigned invert)
- {return pigpio_command(gPigCommand, PI_CMD_SLRI, user_gpio, invert, 1);}
-
-int i2c_open(unsigned i2c_bus, unsigned i2c_addr, uint32_t i2c_flags)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=i2c_bus
- p2=i2c_addr
- p3=4
- ## extension ##
- uint32_t i2c_flags
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &i2c_flags;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext, 1);
-}
-
-int i2c_close(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_I2CC, handle, 0, 1);}
-
-int i2c_write_quick(unsigned handle, unsigned bit)
- {return pigpio_command(gPigCommand, PI_CMD_I2CWQ, handle, bit, 1);}
-
-int i2c_write_byte(unsigned handle, unsigned val)
- {return pigpio_command(gPigCommand, PI_CMD_I2CWS, handle, val, 1);}
-
-int i2c_read_byte(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_I2CRS, handle, 0, 1);}
-
-int i2c_write_byte_data(unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CWB, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_write_word_data(unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CWW, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_read_byte_data(unsigned handle, unsigned reg)
- {return pigpio_command(gPigCommand, PI_CMD_I2CRB, handle, reg, 1);}
-
-int i2c_read_word_data(unsigned handle, unsigned reg)
- {return pigpio_command(gPigCommand, PI_CMD_I2CRW, handle, reg, 1);}
-
-int i2c_process_call(unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CPK, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_write_block_data(
- unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CWK, handle, reg, count, 1, ext, 1);
-}
-
-int i2c_read_block_data(unsigned handle, unsigned reg, char *buf)
-{
- int bytes;
-
- bytes = pigpio_command(gPigCommand, PI_CMD_I2CRK, handle, reg, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, 32, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int i2c_block_process_call(
- unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, 32, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int i2c_read_i2c_block_data(
- unsigned handle, unsigned reg, char *buf, uint32_t count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t count
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &count;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, count, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-
-int i2c_write_i2c_block_data(
- unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CWI, handle, reg, count, 1, ext, 1);
-}
-
-int i2c_read_device(unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command(gPigCommand, PI_CMD_I2CRD, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, count, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int i2c_write_device(unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_I2CWD, handle, 0, count, 1, ext, 1);
-}
-
-int i2c_zip(
- unsigned handle,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=inLen
- ## extension ##
- char inBuf[inLen]
- */
-
- ext[0].size = inLen;
- ext[0].ptr = inBuf;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_I2CZ, handle, 0, inLen, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(outBuf, outLen, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=SDA
- p2=SCL
- p3=4
- ## extension ##
- uint32_t baud
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &baud;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_BI2CO, SDA, SCL, 4, 1, ext, 1);
-}
-
-int bb_i2c_close(unsigned SDA)
- {return pigpio_command(gPigCommand, PI_CMD_BI2CC, SDA, 0, 1);}
-
-int bb_i2c_zip(
- unsigned SDA,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=SDA
- p2=0
- p3=inLen
- ## extension ##
- char inBuf[inLen]
- */
-
- ext[0].size = inLen;
- ext[0].ptr = inBuf;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(outBuf, outLen, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int spi_open(unsigned channel, unsigned speed, uint32_t flags)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=channel
- p2=speed
- p3=4
- ## extension ##
- uint32_t flags
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &flags;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_SPIO, channel, speed, 4, 1, ext, 1);
-}
-
-int spi_close(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_SPIC, handle, 0, 1);}
-
-int spi_read(unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command
- (gPigCommand, PI_CMD_SPIR, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, count, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int spi_write(unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_SPIW, handle, 0, count, 1, ext, 1);
-}
-
-int spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = txBuf;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_SPIX, handle, 0, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(rxBuf, count, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int serial_open(char *dev, unsigned baud, unsigned flags)
-{
- int len;
- gpioExtent_t ext[1];
-
- len = strlen(dev);
-
- /*
- p1=baud
- p2=flags
- p3=len
- ## extension ##
- char dev[len]
- */
-
- ext[0].size = len;
- ext[0].ptr = dev;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_SERO, baud, flags, len, 1, ext, 1);
-}
-
-int serial_close(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_SERC, handle, 0, 1);}
-
-int serial_write_byte(unsigned handle, unsigned val)
- {return pigpio_command(gPigCommand, PI_CMD_SERWB, handle, val, 1);}
-
-int serial_read_byte(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_SERRB, handle, 0, 1);}
-
-int serial_write(unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (gPigCommand, PI_CMD_SERW, handle, 0, count, 1, ext, 1);
-}
-
-int serial_read(unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command
- (gPigCommand, PI_CMD_SERR, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(buf, count, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-int serial_data_available(unsigned handle)
- {return pigpio_command(gPigCommand, PI_CMD_SERDA, handle, 0, 1);}
-
-int custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=arg1
- p2=arg2
- p3=count
- ## extension ##
- char argx[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = argx;
-
- return pigpio_command_ext(
- gPigCommand, PI_CMD_CF1, arg1, arg2, count, 1, ext, 1);
-}
-
-
-int custom_2(unsigned arg1, char *argx, unsigned count,
- char *retBuf, uint32_t retMax)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=arg1
- p2=retMax
- p3=count
- ## extension ##
- char argx[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = argx;
-
- bytes = pigpio_command_ext
- (gPigCommand, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(retBuf, retMax, bytes);
- }
-
- pthread_mutex_unlock(&command_mutex);
-
- return bytes;
-}
-
-
-int callback(unsigned user_gpio, unsigned edge, CBFunc_t f)
- {return intCallback(user_gpio, edge, f, 0, 0);}
-
-int callback_ex(unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user)
- {return intCallback(user_gpio, edge, f, user, 1);}
-
-int callback_cancel(unsigned id)
-{
- callback_t *p;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (p->id == id)
- {
- if (p->prev) p->prev->next = p->next;
- else gCallBackFirst = p->next;
-
- if (p->next) p->next->prev = p->prev;
- else gCallBackLast = p->prev;
-
- free(p);
-
- findNotifyBits();
-
- return 0;
- }
- p = p->next;
- }
- return pigif_callback_not_found;
-}
-
-int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout)
-{
- int triggered = 0;
- int id;
- double due;
-
- if (timeout <= 0.0) return 0;
-
- due = time_time() + timeout;
-
- id = callback_ex(user_gpio, edge, _wfe, &triggered);
-
- while (!triggered && (time_time() < due)) time_sleep(0.1);
-
- callback_cancel(id);
-
- return triggered;
-}
-
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.h b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.h
deleted file mode 100644
index 6706b9dd6..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.h
+++ /dev/null
@@ -1,2915 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-#ifndef PIGPIOD_IF_H
-#define PIGPIOD_IF_H
-
-#include "pigpio.h"
-
-#define PIGPIOD_IF_VERSION 25
-
-/*TEXT
-
-THIS LIBRARY IS DEPRECATED. NEW CODE SHOULD BE WRITTEN TO
-USE THE MORE VERSATILE pigpiod_if2 LIBRARY.
-
-pigpiod_if is a C library for the Raspberry which allows control
-of the GPIO via the socket interface to the pigpio daemon.
-
-*Features*
-
-o hardware timed PWM on any of GPIO 0-31
-
-o hardware timed servo pulses on any of GPIO 0-31
-
-o callbacks when any of GPIO 0-31 change state
-
-o callbacks at timed intervals
-
-o reading/writing all of the GPIO in a bank as one operation
-
-o individually setting GPIO modes, reading and writing
-
-o notifications when any of GPIO 0-31 change state
-
-o the construction of output waveforms with microsecond timing
-
-o rudimentary permission control over GPIO
-
-o a simple interface to start and stop new threads
-
-o I2C, SPI, and serial link wrappers
-
-o creating and running scripts on the pigpio daemon
-
-*GPIO*
-
-ALL GPIO are identified by their Broadcom number.
-
-*Notes*
-
-The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals.
-
-*Usage*
-
-Include in your source files.
-
-Assuming your source is in prog.c use the following command to build
-
-. .
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if -lrt
-. .
-
-to run make sure the pigpio daemon is running
-
-. .
-sudo pigpiod
-
- ./prog # sudo is not required to run programs linked to pigpiod_if
-. .
-
-For examples see x_pigpiod_if.c within the pigpio archive file.
-
-*Notes*
-
-All the functions which return an int return < 0 on error
-
-TEXT*/
-
-/*OVERVIEW
-
-ESSENTIAL
-
-pigpio_start Connects to the pigpio daemon
-pigpio_stop Disconnects from the pigpio daemon
-
-BEGINNER
-
-set_mode Set a GPIO mode
-get_mode Get a GPIO mode
-
-set_pull_up_down Set/clear GPIO pull up/down resistor
-
-gpio_read Read a GPIO
-gpio_write Write a GPIO
-
-set_PWM_dutycycle Start/stop PWM pulses on a GPIO
-get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-
-set_servo_pulsewidth Start/stop servo pulses on a GPIO
-get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-
-callback Create GPIO level change callback
-callback_ex Create GPIO level change callback
-callback_cancel Cancel a callback
-wait_for_edge Wait for GPIO level change
-
-INTERMEDIATE
-
-gpio_trigger Send a trigger pulse to a GPIO.
-
-set_watchdog Set a watchdog on a GPIO.
-
-set_PWM_range Configure PWM range for a GPIO
-get_PWM_range Get configured PWM range for a GPIO
-
-set_PWM_frequency Configure PWM frequency for a GPIO
-get_PWM_frequency Get configured PWM frequency for a GPIO
-
-read_bank_1 Read all GPIO in bank 1
-read_bank_2 Read all GPIO in bank 2
-
-clear_bank_1 Clear selected GPIO in bank 1
-clear_bank_2 Clear selected GPIO in bank 2
-
-set_bank_1 Set selected GPIO in bank 1
-set_bank_2 Set selected GPIO in bank 2
-
-start_thread Start a new thread
-stop_thread Stop a previously started thread
-
-ADVANCED
-
-get_PWM_real_range Get underlying PWM range for a GPIO
-
-notify_open Request a notification handle
-notify_begin Start notifications for selected GPIO
-notify_pause Pause notifications
-notify_close Close a notification
-
-bb_serial_read_open Opens a GPIO for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a GPIO
-bb_serial_read_close Closes a GPIO for bit bang serial reads
-bb_serial_invert Invert serial logic (1 invert, 0 normal)
-
-hardware_clock Start hardware clock on supported GPIO
-hardware_PWM Start hardware PWM on supported GPIO
-
-set_glitch_filter Set a glitch filter on a GPIO
-set_noise_filter Set a noise filter on a GPIO
-
-SCRIPTS
-
-store_script Store a script
-run_script Run a stored script
-script_status Get script status and parameters
-stop_script Stop a running script
-delete_script Delete a stored script
-
-WAVES
-
-wave_clear Deletes all waveforms
-
-wave_add_new Starts a new waveform
-wave_add_generic Adds a series of pulses to the waveform
-wave_add_serial Adds serial data to the waveform
-
-wave_create Creates a waveform from added data
-wave_delete Deletes one or more waveforms
-
-wave_send_once Transmits a waveform once
-wave_send_repeat Transmits a waveform repeatedly
-
-wave_chain Transmits a chain of waveforms
-
-wave_tx_busy Checks to see if the waveform has ended
-wave_tx_stop Aborts the current waveform
-
-wave_get_micros Length in microseconds of the current waveform
-wave_get_high_micros Length of longest waveform so far
-wave_get_max_micros Absolute maximum allowed micros
-
-wave_get_pulses Length in pulses of the current waveform
-wave_get_high_pulses Length of longest waveform so far
-wave_get_max_pulses Absolute maximum allowed pulses
-
-wave_get_cbs Length in cbs of the current waveform
-wave_get_high_cbs Length of longest waveform so far
-wave_get_max_cbs Absolute maximum allowed cbs
-
-I2C
-
-i2c_open Opens an I2C device
-i2c_close Closes an I2C device
-
-i2c_write_quick smbus write quick
-i2c_write_byte smbus write byte
-i2c_read_byte smbus read byte
-i2c_write_byte_data smbus write byte data
-i2c_write_word_data smbus write word data
-i2c_read_byte_data smbus read byte data
-i2c_read_word_data smbus read word data
-i2c_process_call smbus process call
-i2c_write_block_data smbus write block data
-i2c_read_block_data smbus read block data
-i2c_block_process_call smbus block process call
-
-i2c_write_i2c_block_data smbus write I2C block data
-i2c_read_i2c_block_data smbus read I2C block data
-
-i2c_read_device Reads the raw I2C device
-i2c_write_device Writes the raw I2C device
-
-i2c_zip Performs multiple I2C transactions
-
-bb_i2c_open Opens GPIO for bit banging I2C
-bb_i2c_close Closes GPIO for bit banging I2C
-bb_i2c_zip Performs multiple bit banged I2C transactions
-
-SPI
-
-spi_open Opens a SPI device
-spi_close Closes a SPI device
-
-spi_read Reads bytes from a SPI device
-spi_write Writes bytes to a SPI device
-spi_xfer Transfers bytes with a SPI device
-
-SERIAL
-
-serial_open Opens a serial device
-serial_close Closes a serial device
-
-serial_write_byte Writes a byte to a serial device
-serial_read_byte Reads a byte from a serial device
-serial_write Writes bytes to a serial device
-serial_read Reads bytes from a serial device
-
-serial_data_available Returns number of bytes ready to be read
-
-CUSTOM
-
-custom_1 User custom function 1
-custom_2 User custom function 2
-
-UTILITIES
-
-get_current_tick Get current tick (microseconds)
-
-get_hardware_revision Get hardware revision
-get_pigpio_version Get the pigpio version
-pigpiod_if_version Get the pigpiod_if version
-
-pigpio_error Get a text description of an error code.
-
-time_sleep Sleeps for a float number of seconds
-time_time Float number of seconds since the epoch
-
-OVERVIEW*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*CBFunc_t) (unsigned user_gpio, unsigned level, uint32_t tick);
-
-typedef void (*CBFuncEx_t)
- (unsigned user_gpio, unsigned level, uint32_t tick, void * user);
-
-typedef struct callback_s callback_t;
-
-/*F*/
-double time_time(void);
-/*D
-Return the current time in seconds since the Epoch.
-D*/
-
-/*F*/
-void time_sleep(double seconds);
-/*D
-Delay execution for a given number of seconds.
-
-. .
-seconds: the number of seconds to delay.
-. .
-D*/
-
-/*F*/
-char *pigpio_error(int errnum);
-/*D
-Return a text description for an error code.
-
-. .
-errnum: the error code.
-. .
-D*/
-
-/*F*/
-unsigned pigpiod_if_version(void);
-/*D
-Return the pigpiod_if version.
-D*/
-
-/*F*/
-pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata);
-/*D
-Starts a new thread of execution with thread_func as the main routine.
-
-. .
-thread_func: the main function for the new thread.
- userdata: a pointer to an arbitrary argument.
-. .
-
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-The function is passed the single argument userdata.
-
-The thread can be cancelled by passing the pointer to pthread_t to
-[*stop_thread*].
-D*/
-
-/*F*/
-void stop_thread(pthread_t *pth);
-/*D
-Cancels the thread pointed at by pth.
-
-. .
-pth: the thread to be stopped.
-. .
-
-No value is returned.
-
-The thread to be stopped should have been started with [*start_thread*].
-D*/
-
-/*F*/
-int pigpio_start(char *addrStr, char *portStr);
-/*D
-Connect to the pigpio daemon. Reserving command and
-notification streams.
-
-. .
-addrStr: specifies the host or IP address of the Pi running the
- pigpio daemon. It may be NULL in which case localhost
- is used unless overridden by the PIGPIO_ADDR environment
- variable.
-
-portStr: specifies the port address used by the Pi running the
- pigpio daemon. It may be NULL in which case "8888"
- is used unless overridden by the PIGPIO_PORT environment
- variable.
-. .
-D*/
-
-/*F*/
-void pigpio_stop(void);
-/*D
-Terminates the connection to the pigpio daemon and releases
-resources used by the library.
-D*/
-
-/*F*/
-int set_mode(unsigned gpio, unsigned mode);
-/*D
-Set the GPIO mode.
-
-. .
-gpio: 0-53.
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
- PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE,
-or PI_NOT_PERMITTED.
-D*/
-
-/*F*/
-int get_mode(unsigned gpio);
-/*D
-Get the GPIO mode.
-
-. .
-gpio: 0-53.
-. .
-
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-D*/
-
-/*F*/
-int set_pull_up_down(unsigned gpio, unsigned pud);
-/*D
-Set or clear the GPIO pull-up/down resistor.
-
-. .
-gpio: 0-53.
- pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD,
-or PI_NOT_PERMITTED.
-D*/
-
-/*F*/
-int gpio_read(unsigned gpio);
-/*D
-Read the GPIO level.
-
-. .
-gpio:0-53.
-. .
-
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-D*/
-
-/*F*/
-int gpio_write(unsigned gpio, unsigned level);
-/*D
-Write the GPIO level.
-
-. .
- gpio: 0-53.
-level: 0, 1.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL,
-or PI_NOT_PERMITTED.
-
-Notes
-
-If PWM or servo pulses are active on the GPIO they are switched off.
-D*/
-
-/*F*/
-int set_PWM_dutycycle(unsigned user_gpio, unsigned dutycycle);
-/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
-
-. .
-user_gpio: 0-31.
-dutycycle: 0-range (range defaults to 255).
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE,
-or PI_NOT_PERMITTED.
-Notes
-
-The [*set_PWM_range*] function may be used to change the
-default range of 255.
-D*/
-
-/*F*/
-int get_PWM_dutycycle(unsigned user_gpio);
-/*D
-Return the PWM dutycycle in use on a GPIO.
-
-. .
-user_gpio: 0-31.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see [*get_PWM_range*]).
-
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-D*/
-
-/*F*/
-int set_PWM_range(unsigned user_gpio, unsigned range);
-/*D
-Set the range of PWM values to be used on the GPIO.
-
-. .
-user_gpio: 0-31.
- range: 25-40000.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE,
-or PI_NOT_PERMITTED.
-
-Notes
-
-If PWM is currently active on the GPIO its dutycycle will be
-scaled to reflect the new range.
-
-The real range, the number of steps between fully off and fully on
-for each of the 18 available GPIO frequencies is
-
-. .
- 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
- 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12),
-2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18)
-. .
-
-The real value set by set_PWM_range is (dutycycle * real range) / range.
-D*/
-
-/*F*/
-int get_PWM_range(unsigned user_gpio);
-/*D
-Get the range of PWM values being used on the GPIO.
-
-. .
-user_gpio: 0-31.
-. .
-
-Returns the dutycycle range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-If a hardware clock or hardware PWM is active on the GPIO the
-reported range will be 1000000 (1M).
-D*/
-
-/*F*/
-int get_PWM_real_range(unsigned user_gpio);
-/*D
-Get the real underlying range of PWM values being used on the GPIO.
-
-. .
-user_gpio: 0-31.
-. .
-
-Returns the real range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-If a hardware clock is active on the GPIO the reported
-real range will be 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-D*/
-
-/*F*/
-int set_PWM_frequency(unsigned user_gpio, unsigned frequency);
-/*D
-Set the frequency (in Hz) of the PWM to be used on the GPIO.
-
-. .
-user_gpio: 0-31.
-frequency: >=0 (Hz).
-. .
-
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-
-If PWM is currently active on the GPIO it will be switched
-off and then back on at the new frequency.
-
-Each GPIO can be independently set to one of 18 different
-PWM frequencies.
-
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the pigpio daemon is started.
-
-The frequencies for each sample rate are:
-
-. .
- Hertz
-
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
- 1250 1000 800 500 400 250 200 100 50
-
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
- 625 500 400 250 200 125 100 50 25
-
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
- 313 250 200 125 100 63 50 25 13
-sample
- rate
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
- 250 200 160 100 80 50 40 20 10
-
- 8: 5000 2500 1250 1000 625 500 313 250 200
- 156 125 100 63 50 31 25 13 6
-
- 10: 4000 2000 1000 800 500 400 250 200 160
- 125 100 80 50 40 25 20 10 5
-. .
-D*/
-
-/*F*/
-int get_PWM_frequency(unsigned user_gpio);
-/*D
-Get the frequency of PWM being used on the GPIO.
-
-. .
-user_gpio: 0-31.
-. .
-
-For normal PWM the frequency will be that defined for the GPIO by
-[*set_PWM_frequency*].
-
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by [*hardware_clock*].
-
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by [*hardware_PWM*].
-
-Returns the frequency (in hertz) used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-D*/
-
-/*F*/
-int set_servo_pulsewidth(unsigned user_gpio, unsigned pulsewidth);
-/*D
-Start (500-2500) or stop (0) servo pulses on the GPIO.
-
-. .
- user_gpio: 0-31.
-pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise).
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or
-PI_NOT_PERMITTED.
-
-The selected pulsewidth will continue to be transmitted until
-changed by a subsequent call to set_servo_pulsewidth.
-
-The pulsewidths supported by servos varies and should probably be
-determined by experiment. A value of 1500 should always be safe and
-represents the mid-point of rotation.
-
-You can DAMAGE a servo if you command it to move beyond its limits.
-
-OTHER UPDATE RATES:
-
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-. .
-Update Rate (Hz) 50 100 200 400 500
-1E6/Hz 20000 10000 5000 2500 2000
-. .
-
-Firstly set the desired PWM frequency using [*set_PWM_frequency*].
-
-Then set the PWM range using [*set_PWM_range*] to 1E6/Hz.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-E.g. If you want to update a servo connected to GPIO 25 at 400Hz
-
-. .
-set_PWM_frequency(25, 400);
-set_PWM_range(25, 2500);
-. .
-
-Thereafter use the [*set_PWM_dutycycle*] function to move the servo,
-e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
-D*/
-
-/*F*/
-int get_servo_pulsewidth(unsigned user_gpio);
-/*D
-Return the servo pulsewidth in use on a GPIO.
-
-. .
-user_gpio: 0-31.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-D*/
-
-/*F*/
-int notify_open(void);
-/*D
-Get a free notification handle.
-
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-A notification is a method for being notified of GPIO state
-changes via a pipe.
-
-Pipes are only accessible from the local machine so this function
-serves no purpose if you are using the library from a remote machine.
-The in-built (socket) notifications provided by [*callback*]
-should be used instead.
-
-Notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number).
-E.g. if the function returns 15 then the notifications must be
-read from /dev/pigpio15.
-D*/
-
-/*F*/
-int notify_begin(unsigned handle, uint32_t bits);
-/*D
-Start notifications on a previously opened handle.
-
-. .
-handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the GPIO to be notified.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-The notification sends state changes for each GPIO whose
-corresponding bit in bits is set.
-
-Each notification occupies 12 bytes in the fifo as follows:
-
-. .
-typedef struct
-{
- uint16_t seqno;
- uint16_t flags;
- uint32_t tick;
- uint32_t level;
-} gpioReport_t;
-. .
-
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-level: indicates the level of each GPIO. If bit 1<=0
- numBytes: >=1
- str: an array of chars.
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-NOTES:
-
-The serial data is formatted as one start bit, [*data_bits*] data bits,
-and [*stop_bits*]/2 stop bits.
-
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-[*numBytes*] is the number of bytes of data in str.
-
-The bytes required for each character depend upon [*data_bits*].
-
-For [*data_bits*] 1-8 there will be one byte per character.
-For [*data_bits*] 9-16 there will be two bytes per character.
-For [*data_bits*] 17-32 there will be four bytes per character.
-D*/
-
-/*F*/
-int wave_create(void);
-/*D
-This function creates a waveform from the data provided by the prior
-calls to the [*wave_add_**] functions. Upon success a wave id
-greater than or equal to 0 is returned, otherwise PI_EMPTY_WAVEFORM,
-PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
-
-The data provided by the [*wave_add_**] functions is consumed by this
-function.
-
-As many waveforms may be created as there is space available. The
-wave id is passed to [*wave_send_**] to specify the waveform to transmit.
-
-Normal usage would be
-
-Step 1. [*wave_clear*] to clear all waveforms and added data.
-
-Step 2. [*wave_add_**] calls to supply the waveform data.
-
-Step 3. [*wave_create*] to create the waveform and get a unique id
-
-Repeat steps 2 and 3 as needed.
-
-Step 4. [*wave_send_**] with the id of the waveform to transmit.
-
-A waveform comprises one or more pulses. Each pulse consists of a
-[*gpioPulse_t*] structure.
-
-. .
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
-} gpioPulse_t;
-. .
-
-The fields specify
-
-1) the GPIO to be switched on at the start of the pulse.
-2) the GPIO to be switched off at the start of the pulse.
-3) the delay in microseconds before the next pulse.
-
-Any or all the fields can be zero. It doesn't make any sense to
-set all the fields to zero (the pulse will be ignored).
-
-When a waveform is started each pulse is executed in order with the
-specified delay between the pulse and the next.
-
-Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
-PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
-D*/
-
-
-/*F*/
-int wave_delete(unsigned wave_id);
-/*D
-This function deletes the waveform with id wave_id.
-
-. .
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-D*/
-
-/*F*/
-int wave_send_once(unsigned wave_id);
-/*D
-This function transmits the waveform with id wave_id. The waveform
-is sent once.
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-. .
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-/*F*/
-int wave_send_repeat(unsigned wave_id);
-/*D
-This function transmits the waveform with id wave_id. The waveform
-cycles until cancelled (either by the sending of a new waveform or
-by [*wave_tx_stop*]).
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-. .
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-/*F*/
-int wave_chain(char *buf, unsigned bufSize);
-/*D
-This function transmits a chain of waveforms.
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of [*wave_id*]s and optional command
-codes and related data.
-
-. .
- buf: pointer to the wave_ids and optional command codes
-bufSize: the number of bytes in buf
-. .
-
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-Delays between waves may be added with the delay command.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-Loop Start @ 255 0 @ Identify start of a wave block
-Loop Repeat @ 255 1 x y @ loop x + y*256 times
-Delay @ 255 2 x y @ delay x + y*256 microseconds
-Loop Forever @ 255 3 @ loop forever
-
-If present Loop Forever must be the last entry in the chain.
-
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-...
-#include
-#include
-
-#define WAVES 5
-#define GPIO 4
-
-int main(int argc, char *argv[])
-{
- int i, wid[WAVES];
-
- if (pigpio_start(0, 0)<0) return -1;
-
- set_mode(GPIO, PI_OUTPUT);
-
- for (i=0; i=0, as returned by [*store_script*].
- numPar: 0-10, the number of parameters.
- param: an array of parameters.
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
-PI_TOO_MANY_PARAM
-
-param is an array of up to 10 parameters which may be referenced in
-the script as p0 to p9.
-D*/
-
-/*F*/
-int script_status(unsigned script_id, uint32_t *param);
-/*D
-This function returns the run status of a stored script as well
-as the current values of parameters 0 to 9.
-
-. .
-script_id: >=0, as returned by [*store_script*].
- param: an array to hold the returned 10 parameters.
-. .
-
-The function returns greater than or equal to 0 if OK,
-otherwise PI_BAD_SCRIPT_ID.
-
-The run status may be
-
-. .
-PI_SCRIPT_INITING
-PI_SCRIPT_HALTED
-PI_SCRIPT_RUNNING
-PI_SCRIPT_WAITING
-PI_SCRIPT_FAILED
-. .
-
-The current value of script parameters 0 to 9 are returned in param.
-D*/
-
-/*F*/
-int stop_script(unsigned script_id);
-/*D
-This function stops a running script.
-
-. .
-script_id: >=0, as returned by [*store_script*].
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-D*/
-
-/*F*/
-int delete_script(unsigned script_id);
-/*D
-This function deletes a stored script.
-
-. .
-script_id: >=0, as returned by [*store_script*].
-. .
-
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-D*/
-
-/*F*/
-int bb_serial_read_open(unsigned user_gpio, unsigned baud, unsigned data_bits);
-/*D
-This function opens a GPIO for bit bang reading of serial data.
-
-. .
-user_gpio: 0-31.
- baud: 50-250000
-data_bits: 1-32
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
-or PI_GPIO_IN_USE.
-
-The serial data is returned in a cyclic buffer and is read using
-bb_serial_read.
-
-It is the caller's responsibility to read data from the cyclic buffer
-in a timely fashion.
-D*/
-
-/*F*/
-int bb_serial_read(unsigned user_gpio, void *buf, size_t bufSize);
-/*D
-This function copies up to bufSize bytes of data read from the
-bit bang serial cyclic buffer to the buffer starting at buf.
-
-. .
-user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
- buf: an array to receive the read bytes.
- bufSize: >=0
-. .
-
-Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
-or PI_NOT_SERIAL_GPIO.
-
-The bytes returned for each character depend upon the number of
-data bits [*data_bits*] specified in the [*bb_serial_read_open*] command.
-
-For [*data_bits*] 1-8 there will be one byte per character.
-For [*data_bits*] 9-16 there will be two bytes per character.
-For [*data_bits*] 17-32 there will be four bytes per character.
-D*/
-
-/*F*/
-int bb_serial_read_close(unsigned user_gpio);
-/*D
-This function closes a GPIO for bit bang reading of serial data.
-
-. .
-user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
-D*/
-
-/*F*/
-int bb_serial_invert(unsigned user_gpio, unsigned invert);
-/*D
-This function inverts serial logic for big bang serial reads.
-
-. .
-user_gpio: 0-31, previously opened with [*bb_serial_read_open*].
- invert: 0-1, 1 invert, 0 normal.
-. .
-
-Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
-D*/
-
-/*F*/
-int i2c_open(unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags);
-/*D
-This returns a handle for the device at address i2c_addr on bus i2c_bus.
-
-. .
- i2c_bus: >=0.
- i2c_addr: 0-0x7F.
-i2c_flags: 0.
-. .
-
-No flags are currently defined. This parameter should be set to zero.
-
-Physically buses 0 and 1 are available on the Pi. Higher numbered buses
-will be available if a kernel supported bus multiplexor is being used.
-
-Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
-PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
-
-For the SMBus commands the low level transactions are shown at the end
-of the function description. The following abbreviations are used.
-
-. .
-S (1 bit) : Start bit
-P (1 bit) : Stop bit
-Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
-A, NA (1 bit) : Accept and not accept bit.
-Addr (7 bits): I2C 7 bit address.
-Comm (8 bits): Command byte, a data byte which often selects a register.
-Data (8 bits): A data byte.
-Count (8 bits): A data byte containing the length of a block operation.
-
-[..]: Data sent by the device.
-. .
-D*/
-
-/*F*/
-int i2c_close(unsigned handle);
-/*D
-This closes the I2C device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int i2c_write_quick(unsigned handle, unsigned bit);
-/*D
-This sends a single bit (in the Rd/Wr bit) to the device associated
-with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
- bit: 0-1, the value to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Quick command. SMBus 2.0 5.5.1
-. .
-S Addr Rd/Wr [A] P
-. .
-D*/
-
-/*F*/
-int i2c_write_byte(unsigned handle, unsigned bVal);
-/*D
-This sends a single byte to the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
- bVal: 0-0xFF, the value to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Send byte. SMBus 2.0 5.5.2
-. .
-S Addr Wr [A] Data [A] P
-. .
-D*/
-
-/*F*/
-int i2c_read_byte(unsigned handle);
-/*D
-This reads a single byte from the device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
-. .
-
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-or PI_I2C_READ_FAILED.
-
-Receive byte. SMBus 2.0 5.5.3
-. .
-S Addr Rd [A] [Data] NA P
-. .
-D*/
-
-/*F*/
-int i2c_write_byte_data(unsigned handle, unsigned i2c_reg, unsigned bVal);
-/*D
-This writes a single byte to the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write.
- bVal: 0-0xFF, the value to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Write byte. SMBus 2.0 5.5.4
-. .
-S Addr Wr [A] Comm [A] Data [A] P
-. .
-D*/
-
-/*F*/
-int i2c_write_word_data(unsigned handle, unsigned i2c_reg, unsigned wVal);
-/*D
-This writes a single 16 bit word to the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write.
- wVal: 0-0xFFFF, the value to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Write word. SMBus 2.0 5.5.4
-. .
-S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A] P
-. .
-D*/
-
-/*F*/
-int i2c_read_byte_data(unsigned handle, unsigned i2c_reg);
-/*D
-This reads a single byte from the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to read.
-. .
-
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Read byte. SMBus 2.0 5.5.5
-. .
-S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
-. .
-D*/
-
-/*F*/
-int i2c_read_word_data(unsigned handle, unsigned i2c_reg);
-/*D
-This reads a single 16 bit word from the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to read.
-. .
-
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Read word. SMBus 2.0 5.5.5
-. .
-S Addr Wr [A] Comm [A] S Addr Rd [A] [DataLow] A [DataHigh] NA P
-. .
-D*/
-
-/*F*/
-int i2c_process_call(unsigned handle, unsigned i2c_reg, unsigned wVal);
-/*D
-This writes 16 bits of data to the specified register of the device
-associated with handle and and reads 16 bits of data in return.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write/read.
- wVal: 0-0xFFFF, the value to write.
-. .
-
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Process call. SMBus 2.0 5.5.6
-. .
-S Addr Wr [A] Comm [A] DataLow [A] DataHigh [A]
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-. .
-D*/
-
-/*F*/
-int i2c_write_block_data(
-unsigned handle, unsigned i2c_reg, char *buf, unsigned count);
-/*D
-This writes up to 32 bytes to the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write.
- buf: an array with the data to send.
- count: 1-32, the number of bytes to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-Block write. SMBus 2.0 5.5.7
-. .
-S Addr Wr [A] Comm [A] Count [A] Data [A] Data [A] ... [A] Data [A] P
-. .
-D*/
-
-/*F*/
-int i2c_read_block_data(unsigned handle, unsigned i2c_reg, char *buf);
-/*D
-This reads a block of up to 32 bytes from the specified register of
-the device associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to read.
- buf: an array to receive the read data.
-. .
-
-The amount of returned data is set by the device.
-
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-Block read. SMBus 2.0 5.5.7
-. .
-S Addr Wr [A] Comm [A]
- S Addr Rd [A] [Count] A [Data] A [Data] A ... A [Data] NA P
-. .
-D*/
-
-/*F*/
-int i2c_block_process_call(
-unsigned handle, unsigned i2c_reg, char *buf, unsigned count);
-/*D
-This writes data bytes to the specified register of the device
-associated with handle and reads a device specified number
-of bytes of data in return.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write/read.
- buf: an array with the data to send and to receive the read data.
- count: 1-32, the number of bytes to write.
-. .
-
-
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-The smbus 2.0 documentation states that a minimum of 1 byte may be
-sent and a minimum of 1 byte may be received. The total number of
-bytes sent/received must be 32 or less.
-
-Block write-block read. SMBus 2.0 5.5.8
-. .
-S Addr Wr [A] Comm [A] Count [A] Data [A] ...
- S Addr Rd [A] [Count] A [Data] ... A P
-. .
-D*/
-
-/*F*/
-int i2c_read_i2c_block_data(
-unsigned handle, unsigned i2c_reg, char *buf, unsigned count);
-/*D
-This reads count bytes from the specified register of the device
-associated with handle . The count may be 1-32.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to read.
- buf: an array to receive the read data.
- count: 1-32, the number of bytes to read.
-. .
-
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-. .
-S Addr Wr [A] Comm [A]
- S Addr Rd [A] [Data] A [Data] A ... A [Data] NA P
-. .
-D*/
-
-
-/*F*/
-int i2c_write_i2c_block_data(
-unsigned handle, unsigned i2c_reg, char *buf, unsigned count);
-/*D
-This writes 1 to 32 bytes to the specified register of the device
-associated with handle.
-
-. .
- handle: >=0, as returned by a call to [*i2c_open*].
-i2c_reg: 0-255, the register to write.
- buf: the data to write.
- count: 1-32, the number of bytes to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-. .
-S Addr Wr [A] Comm [A] Data [A] Data [A] ... [A] Data [A] P
-. .
-D*/
-
-/*F*/
-int i2c_read_device(unsigned handle, char *buf, unsigned count);
-/*D
-This reads count bytes from the raw device into buf.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
- buf: an array to receive the read data bytes.
- count: >0, the number of bytes to read.
-. .
-
-Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_READ_FAILED.
-D*/
-
-/*F*/
-int i2c_write_device(unsigned handle, char *buf, unsigned count);
-/*D
-This writes count bytes from buf to the raw device.
-
-. .
-handle: >=0, as returned by a call to [*i2c_open*].
- buf: an array containing the data bytes to write.
- count: >0, the number of bytes to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-D*/
-
-/*F*/
-int i2c_zip(
- unsigned handle,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen);
-/*D
-This function executes a sequence of I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-. .
-handle: >=0, as returned by a call to [*i2cOpen*]
- inBuf: pointer to the concatenated I2C commands, see below
- inLen: size of command buffer
-outBuf: pointer to buffer to hold returned data
-outLen: size of output buffer
-. .
-
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN.
-PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-End @ 0 @ No more commands
-Escape @ 1 @ Next P is two bytes
-On @ 2 @ Switch combined flag on
-Off @ 3 @ Switch combined flag off
-Address @ 4 P @ Set I2C address to P
-Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
-Read @ 6 P @ Read P bytes of data
-Write @ 7 P ... @ Write P bytes of data
-
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-The address defaults to that associated with the handle.
-The flags default to 0. The address and flags maintain their
-previous value until updated.
-
-The returned I2C data is stored in consecutive locations of outBuf.
-
-...
-Set address 0x53, write 0x32, read 6 bytes
-Set address 0x1E, write 0x03, read 6 bytes
-Set address 0x68, write 0x1B, read 8 bytes
-End
-
-0x04 0x53 0x07 0x01 0x32 0x06 0x06
-0x04 0x1E 0x07 0x01 0x03 0x06 0x06
-0x04 0x68 0x07 0x01 0x1B 0x06 0x08
-0x00
-...
-
-D*/
-
-/*F*/
-int bb_i2c_open(unsigned SDA, unsigned SCL, unsigned baud);
-/*D
-This function selects a pair of GPIO for bit banging I2C at a
-specified baud rate.
-
-Bit banging I2C allows for certain operations which are not possible
-with the standard I2C driver.
-
-o baud rates as low as 50
-o repeated starts
-o clock stretching
-o I2C on any pair of spare GPIO
-
-. .
- SDA: 0-31
- SCL: 0-31
-baud: 50-500000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
-PI_GPIO_IN_USE.
-
-NOTE:
-
-The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
-a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-D*/
-
-/*F*/
-int bb_i2c_close(unsigned SDA);
-/*D
-This function stops bit banging I2C on a pair of GPIO previously
-opened with [*bb_i2c_open*].
-
-. .
-SDA: 0-31, the SDA GPIO used in a prior call to [*bb_i2c_open*]
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-D*/
-
-/*F*/
-int bb_i2c_zip(
- unsigned SDA,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen);
-/*D
-This function executes a sequence of bit banged I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-. .
- SDA: 0-31 (as used in a prior call to [*bb_i2c_open*])
- inBuf: pointer to the concatenated I2C commands, see below
- inLen: size of command buffer
-outBuf: pointer to buffer to hold returned data
-outLen: size of output buffer
-. .
-
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER,
-PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN,
-PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-End @ 0 @ No more commands
-Escape @ 1 @ Next P is two bytes
-Start @ 2 @ Start condition
-Stop @ 3 @ Stop condition
-Address @ 4 P @ Set I2C address to P
-Flags @ 5 lsb msb @ Set I2C flags to lsb + (msb << 8)
-Read @ 6 P @ Read P bytes of data
-Write @ 7 P ... @ Write P bytes of data
-
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-The address and flags default to 0. The address and flags maintain
-their previous value until updated.
-
-No flags are currently defined.
-
-The returned I2C data is stored in consecutive locations of outBuf.
-
-...
-Set address 0x53
-start, write 0x32, (re)start, read 6 bytes, stop
-Set address 0x1E
-start, write 0x03, (re)start, read 6 bytes, stop
-Set address 0x68
-start, write 0x1B, (re)start, read 8 bytes, stop
-End
-
-0x04 0x53
-0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-
-0x04 0x1E
-0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-
-0x04 0x68
-0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-
-0x00
-...
-D*/
-
-/*F*/
-int spi_open(unsigned spi_channel, unsigned baud, unsigned spi_flags);
-/*D
-This function returns a handle for the SPI device on channel.
-Data will be transferred at baud bits per second. The flags may
-be used to modify the default behaviour of 4-wire operation, mode 0,
-active low chip select.
-
-An auxiliary SPI device is available on all models but the
-A and B and may be selected by setting the A bit in the
-flags. The auxiliary device has 3 chip selects and a
-selectable word size in bits.
-
-. .
-spi_channel: 0-1 (0-2 for the auxiliary SPI device).
- baud: 32K-125M (values above 30M are unlikely to work).
- spi_flags: see below.
-. .
-
-Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
-PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
-
-spi_flags consists of the least significant 22 bits.
-
-. .
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
-. .
-
-mm defines the SPI mode.
-
-Warning: modes 1 and 3 do not appear to work on the auxiliary device.
-
-. .
-Mode POL PHA
- 0 0 0
- 1 0 1
- 2 1 0
- 3 1 1
-. .
-
-px is 0 if CEx is active low (default) and 1 for active high.
-
-ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-
-A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
-W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
-SPI device only.
-
-nnnn defines the number of bytes (0-15) to write before switching
-the MOSI line to MISO to read data. This field is ignored
-if W is not set. Standard SPI device only.
-
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first. Auxiliary SPI
-device only.
-
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first. Auxiliary SPI
-device only.
-
-bbbbbb defines the word size in bits (0-32). The default (0)
-sets 8 bits per word. Auxiliary SPI device only.
-
-The other bits in flags should be set to zero.
-D*/
-
-/*F*/
-int spi_close(unsigned handle);
-/*D
-This functions closes the SPI device identified by the handle.
-
-. .
-handle: >=0, as returned by a call to [*spi_open*].
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int spi_read(unsigned handle, char *buf, unsigned count);
-/*D
-This function reads count bytes of data from the SPI
-device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*spi_open*].
- buf: an array to receive the read data bytes.
- count: the number of bytes to read.
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-/*F*/
-int spi_write(unsigned handle, char *buf, unsigned count);
-/*D
-This function writes count bytes of data from buf to the SPI
-device associated with the handle.
-
-. .
-handle: >=0, as returned by a call to [*spi_open*].
- buf: the data bytes to write.
- count: the number of bytes to write.
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-/*F*/
-int spi_xfer(unsigned handle, char *txBuf, char *rxBuf, unsigned count);
-/*D
-This function transfers count bytes of data from txBuf to the SPI
-device associated with the handle. Simultaneously count bytes of
-data are read from the device and placed in rxBuf.
-
-. .
-handle: >=0, as returned by a call to [*spi_open*].
- txBuf: the data bytes to write.
- rxBuf: the received data bytes.
- count: the number of bytes to transfer.
-. .
-
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-D*/
-
-/*F*/
-int serial_open(char *ser_tty, unsigned baud, unsigned ser_flags);
-/*D
-This function opens a serial device at a specified baud rate
-with specified flags. The device name must start with
-/dev/tty or /dev/serial.
-
-. .
- ser_tty: the serial device to open.
- baud: the baud rate in bits per second, see below.
-ser_flags: 0.
-. .
-
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
-PI_SER_OPEN_FAILED.
-
-The baud rate must be one of 50, 75, 110, 134, 150,
-200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
-38400, 57600, 115200, or 230400.
-
-No flags are currently defined. This parameter should be set to zero.
-D*/
-
-/*F*/
-int serial_close(unsigned handle);
-/*D
-This function closes the serial device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int serial_write_byte(unsigned handle, unsigned bVal);
-/*D
-This function writes bVal to the serial port associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-D*/
-
-/*F*/
-int serial_read_byte(unsigned handle);
-/*D
-This function reads a byte from the serial port associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
-. .
-
-Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
-D*/
-
-/*F*/
-int serial_write(unsigned handle, char *buf, unsigned count);
-/*D
-This function writes count bytes from buf to the the serial port
-associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
- buf: the array of bytes to write.
- count: the number of bytes to write.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-D*/
-
-/*F*/
-int serial_read(unsigned handle, char *buf, unsigned count);
-/*D
-This function reads up to count bytes from the the serial port
-associated with handle and writes them to buf.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
- buf: an array to receive the read data.
- count: the maximum number of bytes to read.
-. .
-
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
-D*/
-
-/*F*/
-int serial_data_available(unsigned handle);
-/*D
-Returns the number of bytes available to be read from the
-device associated with handle.
-
-. .
-handle: >=0, as returned by a call to [*serial_open*].
-. .
-
-Returns the number of bytes of data available (>=0) if OK,
-otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int custom_1(unsigned arg1, unsigned arg2, char *argx, unsigned argc);
-/*D
-This function is available for user customisation.
-
-It returns a single integer value.
-
-. .
-arg1: >=0
-arg2: >=0
-argx: extra (byte) arguments
-argc: number of extra arguments
-. .
-
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-D*/
-
-
-/*F*/
-int custom_2(unsigned arg1, char *argx, unsigned argc,
- char *retBuf, unsigned retMax);
-/*D
-This function is available for user customisation.
-
-It differs from custom_1 in that it returns an array of bytes
-rather than just an integer.
-
-The return value is an integer indicating the number of returned bytes.
-. .
- arg1: >=0
- argc: extra (byte) arguments
- count: number of extra arguments
-retBuf: buffer for returned data
-retMax: maximum number of bytes to return
-. .
-
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-Note, the number of returned bytes will be retMax or less.
-D*/
-
-
-/*F*/
-int callback(unsigned user_gpio, unsigned edge, CBFunc_t f);
-/*D
-This function initialises a new callback.
-
-. .
-user_gpio: 0-31.
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
- f: the callback function.
-. .
-
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-The callback is called with the GPIO, edge, and tick, whenever the
-GPIO has the identified edge.
-D*/
-
-/*F*/
-int callback_ex
- (unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata);
-/*D
-This function initialises a new callback.
-
-. .
-user_gpio: 0-31.
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
- f: the callback function.
- userdata: a pointer to arbitrary user data.
-. .
-
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-The callback is called with the GPIO, edge, tick, and user, whenever
-the GPIO has the identified edge.
-
-D*/
-
-/*F*/
-int callback_cancel(unsigned callback_id);
-/*D
-This function cancels a callback identified by its id.
-
-. .
-callback_id: >=0, as returned by a call to [*callback*] or [*callback_ex*].
-. .
-
-The function returns 0 if OK, otherwise pigif_callback_not_found.
-D*/
-
-/*F*/
-int wait_for_edge(unsigned user_gpio, unsigned edge, double timeout);
-/*D
-This function waits for edge on the GPIO for up to timeout
-seconds.
-
-. .
-user_gpio: 0-31.
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
- timeout: >=0.
-. .
-
-The function returns 1 if the edge occurred, otherwise 0.
-
-The function returns when the edge occurs or after the timeout.
-D*/
-
-/*PARAMS
-
-active :: 0-1000000
-
-The number of microseconds level changes are reported for once
-a noise filter has been triggered (by [*steady*] microseconds of
-a stable level).
-
-*addrStr::
-A string specifying the host or IP address of the Pi running
-the pigpio daemon. It may be NULL in which case localhost
-is used unless overridden by the PIGPIO_ADDR environment
-variable.
-
-arg1::
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-arg2::
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-argc::
-The count of bytes passed to a user customised function.
-
-*argx::
-A pointer to an array of bytes passed to a user customised function.
-Its meaning and content is defined by the customiser.
-
-baud::
-The speed of serial communication (I2C, SPI, serial link, waves) in
-bits per second.
-
-bit::
-A value of 0 or 1.
-
-bits::
-A value used to select GPIO. If bit n of bits is set then GPIO n is
-selected.
-
-A convenient way to set bit n is to or in (1<=0, as returned by a call to [*callback*] or [*callback_ex*]. This is
-passed to [*callback_cancel*] to cancel the callback.
-
-CBFunc_t::
-. .
-typedef void (*CBFunc_t)
- (unsigned user_gpio, unsigned level, uint32_t tick);
-. .
-
-CBFuncEx_t::
-. .
-typedef void (*CBFuncEx_t)
- (unsigned user_gpio, unsigned level, uint32_t tick, void * user);
-. .
-
-char::
-A single character, an 8 bit quantity able to store 0-255.
-
-clkfreq::4689-250000000 (250M)
-The hardware clock frequency.
-
-count::
-The number of bytes to be transferred in an I2C, SPI, or Serial
-command.
-
-data_bits::1-32
-The number of data bits in each character of serial data.
-
-. .
-#define PI_MIN_WAVE_DATABITS 1
-#define PI_MAX_WAVE_DATABITS 32
-. .
-
-double::
-A floating point number.
-
-dutycycle::0-range
-A number representing the ratio of on time to off time for PWM.
-
-The number may vary between 0 and range (default 255) where
-0 is off and range is fully on.
-
-edge::
-Used to identify a GPIO level transition of interest. A rising edge is
-a level change from 0 to 1. A falling edge is a level change from 1 to 0.
-
-. .
-RISING_EDGE 0
-FALLING_EDGE 1
-EITHER_EDGE. 2
-. .
-
-errnum::
-A negative number indicating a function call failed and the nature
-of the error.
-
-f::
-A function.
-
-frequency::>=0
-The number of times a GPIO is swiched on and off per second. This
-can be set per GPIO and may be as little as 5Hz or as much as
-40KHz. The GPIO will be on for a proportion of the time as defined
-by its dutycycle.
-
-
-gpio::
-A Broadcom numbered GPIO, in the range 0-53.
-
-There are 54 General Purpose Input Outputs (GPIO) named gpio0 through
-gpio53.
-
-They are split into two banks. Bank 1 consists of gpio0 through
-gpio31. Bank 2 consists of gpio32 through gpio53.
-
-All the GPIO which are safe for the user to read and write are in
-bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
-have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
-See [*get_hardware_revision*].
-
-The user GPIO are marked with an X in the following table.
-
-. .
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-Type 1 X X - - X - - X X X X X - - X X
-Type 2 - - X X X - - X X X X X - - X X
-Type 3 X X X X X X X X X X X X X X
-
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
-Type 1 - X X - - X X X X X - - - - - -
-Type 2 - X X - - - X X X X - X X X X X
-Type 3 X X X X X X X X X X X X - - - -
-. .
-
-gpioPulse_t::
-. .
-typedef struct
-{
-uint32_t gpioOn;
-uint32_t gpioOff;
-uint32_t usDelay;
-} gpioPulse_t;
-. .
-
-gpioThreadFunc_t::
-. .
-typedef void *(gpioThreadFunc_t) (void *);
-. .
-
-handle::>=0
-A number referencing an object opened by one of [*i2c_open*], [*notify_open*],
-[*serial_open*], and [*spi_open*].
-
-i2c_addr:: 0-0x7F
-The address of a device on the I2C bus.
-
-i2c_bus::>=0
-An I2C bus number.
-
-i2c_flags::0
-Flags which modify an I2C open command. None are currently defined.
-
-i2c_reg:: 0-255
-A register of an I2C device.
-
-*inBuf::
-A buffer used to pass data to a function.
-
-inLen::
-The number of bytes of data in a buffer.
-
-int::
-A whole number, negative or positive.
-
-invert::
-A flag used to set normal or inverted bit bang serial data level logic.
-
-level::
-The level of a GPIO. Low or High.
-
-. .
-PI_OFF 0
-PI_ON 1
-
-PI_CLEAR 0
-PI_SET 1
-
-PI_LOW 0
-PI_HIGH 1
-. .
-
-There is one exception. If a watchdog expires on a GPIO the level will be
-reported as PI_TIMEOUT. See [*set_watchdog*].
-
-. .
-PI_TIMEOUT 2
-. .
-
-mode::0-7
-The operational mode of a GPIO, normally INPUT or OUTPUT.
-
-. .
-PI_INPUT 0
-PI_OUTPUT 1
-PI_ALT0 4
-PI_ALT1 5
-PI_ALT2 6
-PI_ALT3 7
-PI_ALT4 3
-PI_ALT5 2
-. .
-
-numBytes::
-The number of bytes used to store characters in a string. Depending
-on the number of bits per character there may be 1, 2, or 4 bytes
-per character.
-
-numPar:: 0-10
-The number of parameters passed to a script.
-
-numPulses::
-The number of pulses to be added to a waveform.
-
-offset::
-The associated data starts this number of microseconds from the start of
-the waveform.
-
-*outBuf::
-A buffer used to return data from a function.
-
-outLen::
-The size in bytes of an output buffer.
-
-*param::
-An array of script parameters.
-
-*portStr::
-A string specifying the port address used by the Pi running
-the pigpio daemon. It may be NULL in which case "8888"
-is used unless overridden by the PIGPIO_PORT environment
-variable.
-
-*pth::
-A thread identifier, returned by [*start_thread*].
-
-
-pthread_t::
-A thread identifier.
-
-pud::0-2
-The setting of the pull up/down resistor for a GPIO, which may be off,
-pull-up, or pull-down.
-. .
-PI_PUD_OFF 0
-PI_PUD_DOWN 1
-PI_PUD_UP 2
-. .
-
-pulseLen::
-1-100, the length of a trigger pulse in microseconds.
-
-*pulses::
-An array of pulses to be added to a waveform.
-
-pulsewidth::0, 500-2500
-. .
-PI_SERVO_OFF 0
-PI_MIN_SERVO_PULSEWIDTH 500
-PI_MAX_SERVO_PULSEWIDTH 2500
-. .
-
-PWMduty::0-1000000 (1M)
-The hardware PWM dutycycle.
-
-. .
-#define PI_HW_PWM_RANGE 1000000
-. .
-
-PWMfreq::1-125000000 (125M)
-The hardware PWM frequency.
-
-. .
-#define PI_HW_PWM_MIN_FREQ 1
-#define PI_HW_PWM_MAX_FREQ 125000000
-. .
-
-range::25-40000
-The permissible dutycycle values are 0-range.
-. .
-PI_MIN_DUTYCYCLE_RANGE 25
-PI_MAX_DUTYCYCLE_RANGE 40000
-. .
-
-*retBuf::
-A buffer to hold a number of bytes returned to a used customised function,
-
-retMax::
-The maximum number of bytes a user customised function should return.
-
-
-*rxBuf::
-A pointer to a buffer to receive data.
-
-SCL::
-The user GPIO to use for the clock when bit banging I2C.
-
-*script::
-A pointer to the text of a script.
-
-script_id::
-An id of a stored script as returned by [*store_script*].
-
-SDA::
-The user GPIO to use for data when bit banging I2C.
-
-seconds::
-The number of seconds.
-
-ser_flags::
-Flags which modify a serial open command. None are currently defined.
-
-*ser_tty::
-The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
-
-size_t::
-A standard type used to indicate the size of an object in bytes.
-
-spi_channel::
-A SPI channel, 0-2.
-
-spi_flags::
-See [*spi_open*].
-
-steady :: 0-300000
-
-The number of microseconds level changes must be stable for
-before reporting the level changed ([*set_glitch_filter*]) or triggering
-the active part of a noise filter ([*set_noise_filter*]).
-
-stop_bits::2-8
-The number of (half) stop bits to be used when adding serial data
-to a waveform.
-
-. .
-#define PI_MIN_WAVE_HALFSTOPBITS 2
-#define PI_MAX_WAVE_HALFSTOPBITS 8
-. .
-
-*str::
- An array of characters.
-
-thread_func::
-A function of type gpioThreadFunc_t used as the main function of a
-thread.
-
-timeout::
-A GPIO watchdog timeout in milliseconds.
-. .
-PI_MIN_WDOG_TIMEOUT 0
-PI_MAX_WDOG_TIMEOUT 60000
-. .
-
-*txBuf::
-An array of bytes to transmit.
-
-uint32_t::0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)
-A 32-bit unsigned value.
-
-unsigned::
-A whole number >= 0.
-
-user_gpio::
-0-31, a Broadcom numbered GPIO.
-
-See [*gpio*].
-
-*userdata::
-A pointer to arbitrary user data. This may be used to identify the instance.
-
-void::
-Denoting no parameter is required
-
-wave_add_*::
-One of [*wave_add_new*], [*wave_add_generic*], [*wave_add_serial*].
-
-wave_id::
-A number representing a waveform created by [*wave_create*].
-
-wave_send_*::
-One of [*wave_send_once*], [*wave_send_repeat*].
-
-wVal::0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)
-A 16-bit word value.
-
-PARAMS*/
-
-/*DEF_S pigpiod_if Error Codes*/
-
-typedef enum
-{
- pigif_bad_send = -2000,
- pigif_bad_recv = -2001,
- pigif_bad_getaddrinfo = -2002,
- pigif_bad_connect = -2003,
- pigif_bad_socket = -2004,
- pigif_bad_noib = -2005,
- pigif_duplicate_callback = -2006,
- pigif_bad_malloc = -2007,
- pigif_bad_callback = -2008,
- pigif_notify_failed = -2009,
- pigif_callback_not_found = -2010,
-} pigifError_t;
-
-/*DEF_E*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.o b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.o
deleted file mode 100644
index 3bad02a5e..000000000
Binary files a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if.o and /dev/null differ
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.3 b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.3
deleted file mode 100644
index 66ad4e05c..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.3
+++ /dev/null
@@ -1,6586 +0,0 @@
-
-." Process this file with
-." groff -man -Tascii pigpiod_if2.3
-."
-.TH pigpiod_if2 3 2012-2015 Linux "pigpio archive"
-.SH NAME
-pigpiod_if2 - A C library to interface to the pigpio daemon.
-
-.SH SYNOPSIS
-
-#include
-
-
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt
-
- ./prog
-.SH DESCRIPTION
-
-
-.ad l
-
-.nh
-
-.br
-
-.br
-pigpiod_if2 is a C library for the Raspberry which allows control
-of the GPIO via the socket interface to the pigpio daemon.
-.br
-
-.br
-
-.br
-.SS Features
-.br
-
-.br
-o hardware timed PWM on any of GPIO 0-31
-
-.br
-
-.br
-o hardware timed servo pulses on any of GPIO 0-31
-
-.br
-
-.br
-o callbacks when any of GPIO 0-31 change state
-
-.br
-
-.br
-o callbacks at timed intervals
-
-.br
-
-.br
-o reading/writing all of the GPIO in a bank as one operation
-
-.br
-
-.br
-o individually setting GPIO modes, reading and writing
-
-.br
-
-.br
-o notifications when any of GPIO 0-31 change state
-
-.br
-
-.br
-o the construction of output waveforms with microsecond timing
-
-.br
-
-.br
-o rudimentary permission control over GPIO
-
-.br
-
-.br
-o a simple interface to start and stop new threads
-
-.br
-
-.br
-o I2C, SPI, and serial link wrappers
-
-.br
-
-.br
-o creating and running scripts on the pigpio daemon
-
-.br
-
-.br
-.SS GPIO
-.br
-
-.br
-ALL GPIO are identified by their Broadcom number.
-
-.br
-
-.br
-.SS Notes
-.br
-
-.br
-The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals.
-
-.br
-
-.br
-.SS Usage
-.br
-
-.br
-Include in your source files.
-
-.br
-
-.br
-Assuming your source is in prog.c use the following command to build
-
-.br
-
-.br
-
-.EX
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt
-.br
-
-.EE
-
-.br
-
-.br
-to run make sure the pigpio daemon is running
-
-.br
-
-.br
-
-.EX
-sudo pigpiod
-.br
-
-.br
- ./prog # sudo is not required to run programs linked to pigpiod_if2
-.br
-
-.EE
-
-.br
-
-.br
-For examples see x_pigpiod_if2.c within the pigpio archive file.
-
-.br
-
-.br
-.SS Notes
-.br
-
-.br
-All the functions which return an int return < 0 on error
-
-.br
-
-.br
-.SH FUNCTIONS
-
-.IP "\fBdouble time_time(void)\fP"
-.IP "" 4
-Return the current time in seconds since the Epoch.
-
-.IP "\fBvoid time_sleep(double seconds)\fP"
-.IP "" 4
-Delay execution for a given number of seconds.
-
-.br
-
-.br
-
-.EX
-seconds: the number of seconds to delay.
-.br
-
-.EE
-
-.IP "\fBchar *pigpio_error(int errnum)\fP"
-.IP "" 4
-Return a text description for an error code.
-
-.br
-
-.br
-
-.EX
-errnum: the error code.
-.br
-
-.EE
-
-.IP "\fBunsigned pigpiod_if_version(void)\fP"
-.IP "" 4
-Return the pigpiod_if2 version.
-
-.IP "\fBpthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata)\fP"
-.IP "" 4
-Starts a new thread of execution with thread_func as the main routine.
-
-.br
-
-.br
-
-.EX
-thread_func: the main function for the new thread.
-.br
- userdata: a pointer to an arbitrary argument.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-.br
-
-.br
-The function is passed the single argument userdata.
-
-.br
-
-.br
-The thread can be cancelled by passing the pointer to pthread_t to
-\fBstop_thread\fP.
-
-.IP "\fBvoid stop_thread(pthread_t *pth)\fP"
-.IP "" 4
-Cancels the thread pointed at by pth.
-
-.br
-
-.br
-
-.EX
-pth: the thread to be stopped.
-.br
-
-.EE
-
-.br
-
-.br
-No value is returned.
-
-.br
-
-.br
-The thread to be stopped should have been started with \fBstart_thread\fP.
-
-.IP "\fBint pigpio_start(char *addrStr, char *portStr)\fP"
-.IP "" 4
-Connect to the pigpio daemon. Reserving command and
-notification streams.
-
-.br
-
-.br
-
-.EX
-addrStr: specifies the host or IP address of the Pi running the
-.br
- pigpio daemon. It may be NULL in which case localhost
-.br
- is used unless overridden by the PIGPIO_ADDR environment
-.br
- variable.
-.br
-
-.br
-portStr: specifies the port address used by the Pi running the
-.br
- pigpio daemon. It may be NULL in which case "8888"
-.br
- is used unless overridden by the PIGPIO_PORT environment
-.br
- variable.
-.br
-
-.EE
-
-.br
-
-.br
-Returns an integer value greater than or equal to zero if OK.
-
-.br
-
-.br
-This value is passed to the GPIO routines to specify the Pi
-to be operated on.
-
-.IP "\fBvoid pigpio_stop(int pi)\fP"
-.IP "" 4
-Terminates the connection to a pigpio daemon and releases
-resources used by the library.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint set_mode(int pi, unsigned gpio, unsigned mode)\fP"
-.IP "" 4
-Set the GPIO mode.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-gpio: 0-53.
-.br
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
-.br
- PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE,
-or PI_NOT_PERMITTED.
-
-.IP "\fBint get_mode(int pi, unsigned gpio)\fP"
-.IP "" 4
-Get the GPIO mode.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-gpio: 0-53.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-
-.IP "\fBint set_pull_up_down(int pi, unsigned gpio, unsigned pud)\fP"
-.IP "" 4
-Set or clear the GPIO pull-up/down resistor.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-gpio: 0-53.
-.br
- pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD,
-or PI_NOT_PERMITTED.
-
-.IP "\fBint gpio_read(int pi, unsigned gpio)\fP"
-.IP "" 4
-Read the GPIO level.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-gpio:0-53.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-
-.IP "\fBint gpio_write(int pi, unsigned gpio, unsigned level)\fP"
-.IP "" 4
-Write the GPIO level.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- gpio: 0-53.
-.br
-level: 0, 1.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL,
-or PI_NOT_PERMITTED.
-
-.br
-
-.br
-Notes
-
-.br
-
-.br
-If PWM or servo pulses are active on the GPIO they are switched off.
-
-.IP "\fBint set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle)\fP"
-.IP "" 4
-Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-dutycycle: 0-range (range defaults to 255).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE,
-or PI_NOT_PERMITTED.
-Notes
-
-.br
-
-.br
-The \fBset_PWM_range\fP function may be used to change the
-default range of 255.
-
-.IP "\fBint get_PWM_dutycycle(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-Return the PWM dutycycle in use on a GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-.br
-
-.br
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see \fBget_PWM_range\fP).
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-
-.IP "\fBint set_PWM_range(int pi, unsigned user_gpio, unsigned range)\fP"
-.IP "" 4
-Set the range of PWM values to be used on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- range: 25-40000.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE,
-or PI_NOT_PERMITTED.
-
-.br
-
-.br
-Notes
-
-.br
-
-.br
-If PWM is currently active on the GPIO its dutycycle will be
-scaled to reflect the new range.
-
-.br
-
-.br
-The real range, the number of steps between fully off and fully on
-for each of the 18 available GPIO frequencies is
-
-.br
-
-.br
-
-.EX
- 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
-.br
- 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12),
-.br
-2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18)
-.br
-
-.EE
-
-.br
-
-.br
-The real value set by set_PWM_range is (dutycycle * real range) / range.
-
-.IP "\fBint get_PWM_range(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-Get the range of PWM values being used on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the dutycycle range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-If a hardware clock or hardware PWM is active on the GPIO the
-reported range will be 1000000 (1M).
-
-.IP "\fBint get_PWM_real_range(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-Get the real underlying range of PWM values being used on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the real range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported
-real range will be 1000000 (1M).
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-.br
-
-.br
-
-.IP "\fBint set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency)\fP"
-.IP "" 4
-Set the frequency (in Hz) of the PWM to be used on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-frequency: >=0 (Hz).
-.br
-
-.EE
-
-.br
-
-.br
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-
-.br
-
-.br
-If PWM is currently active on the GPIO it will be switched
-off and then back on at the new frequency.
-
-.br
-
-.br
-Each GPIO can be independently set to one of 18 different
-PWM frequencies.
-
-.br
-
-.br
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the pigpio daemon is started.
-
-.br
-
-.br
-The frequencies for each sample rate are:
-
-.br
-
-.br
-
-.EX
- Hertz
-.br
-
-.br
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
-.br
- 1250 1000 800 500 400 250 200 100 50
-.br
-
-.br
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
-.br
- 625 500 400 250 200 125 100 50 25
-.br
-
-.br
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
-.br
- 313 250 200 125 100 63 50 25 13
-.br
-sample
-.br
- rate
-.br
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
-.br
- 250 200 160 100 80 50 40 20 10
-.br
-
-.br
- 8: 5000 2500 1250 1000 625 500 313 250 200
-.br
- 156 125 100 63 50 31 25 13 6
-.br
-
-.br
- 10: 4000 2000 1000 800 500 400 250 200 160
-.br
- 125 100 80 50 40 25 20 10 5
-.br
-
-.EE
-
-.IP "\fBint get_PWM_frequency(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-Get the frequency of PWM being used on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-For normal PWM the frequency will be that defined for the GPIO by
-\fBset_PWM_frequency\fP.
-
-.br
-
-.br
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by \fBhardware_clock\fP.
-
-.br
-
-.br
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by \fBhardware_PWM\fP.
-
-.br
-
-.br
-Returns the frequency (in hertz) used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-.IP "\fBint set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth)\fP"
-.IP "" 4
-Start (500-2500) or stop (0) servo pulses on the GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- user_gpio: 0-31.
-.br
-pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or
-PI_NOT_PERMITTED.
-
-.br
-
-.br
-The selected pulsewidth will continue to be transmitted until
-changed by a subsequent call to set_servo_pulsewidth.
-
-.br
-
-.br
-The pulsewidths supported by servos varies and should probably be
-determined by experiment. A value of 1500 should always be safe and
-represents the mid-point of rotation.
-
-.br
-
-.br
-You can DAMAGE a servo if you command it to move beyond its limits.
-
-.br
-
-.br
-OTHER UPDATE RATES:
-
-.br
-
-.br
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-.br
-
-.br
-
-.EX
-Update Rate (Hz) 50 100 200 400 500
-.br
-1E6/Hz 20000 10000 5000 2500 2000
-.br
-
-.EE
-
-.br
-
-.br
-Firstly set the desired PWM frequency using \fBset_PWM_frequency\fP.
-
-.br
-
-.br
-Then set the PWM range using \fBset_PWM_range\fP to 1E6/Hz.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-.br
-
-.br
-E.g. If you want to update a servo connected to GPIO 25 at 400Hz
-
-.br
-
-.br
-
-.EX
-set_PWM_frequency(25, 400);
-.br
-set_PWM_range(25, 2500);
-.br
-
-.EE
-
-.br
-
-.br
-Thereafter use the \fBset_PWM_dutycycle\fP function to move the servo,
-e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
-.br
-
-.IP "\fBint get_servo_pulsewidth(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-Return the servo pulsewidth in use on a GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-
-.IP "\fBint notify_open(int pi)\fP"
-.IP "" 4
-Get a free notification handle.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-.br
-
-.br
-A notification is a method for being notified of GPIO state
-changes via a pipe.
-
-.br
-
-.br
-Pipes are only accessible from the local machine so this function
-serves no purpose if you are using the library from a remote machine.
-The in-built (socket) notifications provided by \fBcallback\fP
-should be used instead.
-
-.br
-
-.br
-Notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number).
-E.g. if the function returns 15 then the notifications must be
-read from /dev/pigpio15.
-
-.IP "\fBint notify_begin(int pi, unsigned handle, uint32_t bits)\fP"
-.IP "" 4
-Start notifications on a previously opened handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: 0-31 (as returned by \fBnotify_open\fP)
-.br
- bits: a mask indicating the GPIO to be notified.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-The notification sends state changes for each GPIO whose
-corresponding bit in bits is set.
-
-.br
-
-.br
-Each notification occupies 12 bytes in the fifo as follows:
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint16_t seqno;
-.br
- uint16_t flags;
-.br
- uint32_t tick;
-.br
- uint32_t level;
-.br
-} gpioReport_t;
-.br
-
-.EE
-
-.br
-
-.br
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-.br
-
-.br
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-.br
-
-.br
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-.br
-
-.br
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-.br
-
-.br
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-.br
-
-.br
-level: indicates the level of each GPIO. If bit 1<=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: 0-31 (as returned by \fBnotify_open\fP)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-Notifications for the handle are suspended until
-\fBnotify_begin\fP is called again.
-
-.IP "\fBint notify_close(int pi, unsigned handle)\fP"
-.IP "" 4
-Stop notifications on a previously opened handle and
-release the handle for reuse.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: 0-31 (as returned by \fBnotify_open\fP)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint set_watchdog(int pi, unsigned user_gpio, unsigned timeout)\fP"
-.IP "" 4
-Sets a watchdog for a GPIO.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- timeout: 0-60000.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO
-or PI_BAD_WDOG_TIMEOUT.
-
-.br
-
-.br
-The watchdog is nominally in milliseconds.
-
-.br
-
-.br
-Only one watchdog may be registered per GPIO.
-
-.br
-
-.br
-The watchdog may be cancelled by setting timeout to 0.
-
-.br
-
-.br
-If no level change has been detected for the GPIO for timeout
-milliseconds any notification for the GPIO has a report written
-to the fifo with the flags set to indicate a watchdog timeout.
-
-.br
-
-.br
-The \fBcallback\fP and \fBcallback_ex\fP functions interpret the flags
-and will call registered callbacks for the GPIO with level TIMEOUT.
-
-.IP "\fBint set_glitch_filter(int pi, unsigned user_gpio, unsigned steady)\fP"
-.IP "" 4
-Sets a glitch filter on a GPIO.
-
-.br
-
-.br
-Level changes on the GPIO are not reported unless the level
-has been stable for at least \fBsteady\fP microseconds. The
-level is then reported. Level changes of less than
-\fBsteady\fP microseconds are ignored.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31
-.br
- steady: 0-300000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-.br
-
-.br
-Note, each (stable) edge will be timestamped \fBsteady\fP microseconds
-after it was first detected.
-
-.IP "\fBint set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)\fP"
-.IP "" 4
-Sets a noise filter on a GPIO.
-
-.br
-
-.br
-Level changes on the GPIO are ignored until a level which has
-been stable for \fBsteady\fP microseconds is detected. Level changes
-on the GPIO are then reported for \fBactive\fP microseconds after
-which the process repeats.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31
-.br
- steady: 0-300000
-.br
- active: 0-1000000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-.br
-
-.br
-Note, level changes before and after the active period may
-be reported. Your software must be designed to cope with
-such reports.
-
-.IP "\fBuint32_t read_bank_1(int pi)\fP"
-.IP "" 4
-Read the levels of the bank 1 GPIO (GPIO 0-31).
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-The returned 32 bit integer has a bit set if the corresponding
-GPIO is logic 1. GPIO n has bit value (1<=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-The returned 32 bit integer has a bit set if the corresponding
-GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
-
-.IP "\fBint clear_bank_1(int pi, uint32_t bits)\fP"
-.IP "" 4
-Clears GPIO 0-31 if the corresponding bit in bits is set.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-bits: a bit mask with 1 set if the corresponding GPIO is
-.br
- to be cleared.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-.br
-
-.br
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-
-.IP "\fBint clear_bank_2(int pi, uint32_t bits)\fP"
-.IP "" 4
-Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-bits: a bit mask with 1 set if the corresponding GPIO is
-.br
- to be cleared.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-.br
-
-.br
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-
-.IP "\fBint set_bank_1(int pi, uint32_t bits)\fP"
-.IP "" 4
-Sets GPIO 0-31 if the corresponding bit in bits is set.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-bits: a bit mask with 1 set if the corresponding GPIO is
-.br
- to be set.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-.br
-
-.br
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-
-.IP "\fBint set_bank_2(int pi, uint32_t bits)\fP"
-.IP "" 4
-Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-bits: a bit mask with 1 set if the corresponding GPIO is
-.br
- to be set.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-.br
-
-.br
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-
-.IP "\fBint hardware_clock(int pi, unsigned gpio, unsigned clkfreq)\fP"
-.IP "" 4
-Starts a hardware clock on a GPIO at the specified frequency.
-Frequencies above 30MHz are unlikely to work.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- gpio: see description
-.br
-frequency: 0 (off) or 4689-250000000 (250M)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
-PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-
-.br
-
-.br
-The same clock is available on multiple GPIO. The latest
-frequency setting will be used by all GPIO which share a clock.
-
-.br
-
-.br
-The GPIO must be one of the following.
-
-.br
-
-.br
-
-.EX
-4 clock 0 All models
-.br
-5 clock 1 All models but A and B (reserved for system use)
-.br
-6 clock 2 All models but A and B
-.br
-20 clock 0 All models but A and B
-.br
-21 clock 1 All models but A and Rev.2 B (reserved for system use)
-.br
-
-.br
-32 clock 0 Compute module only
-.br
-34 clock 0 Compute module only
-.br
-42 clock 1 Compute module only (reserved for system use)
-.br
-43 clock 2 Compute module only
-.br
-44 clock 1 Compute module only (reserved for system use)
-.br
-
-.EE
-
-.br
-
-.br
-Access to clock 1 is protected by a password as its use will likely
-crash the Pi. The password is given by or'ing 0x5A000000 with the
-GPIO number.
-
-.IP "\fBint hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty)\fP"
-.IP "" 4
-Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
-Frequencies above 30MHz are unlikely to work.
-
-.br
-
-.br
-NOTE: Any waveform started by \fBwave_send_*\fP or \fBwave_chain\fP
-will be cancelled.
-
-.br
-
-.br
-This function is only valid if the pigpio main clock is PCM. The
-main clock defaults to PCM but may be overridden when the pigpio
-daemon is started (option -t).
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- gpio: see descripton
-.br
-PWMfreq: 0 (off) or 1-125000000 (125M)
-.br
-PWMduty: 0 (off) to 1000000 (1M)(fully on)
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
-PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ,
-or PI_HPWM_ILLEGAL.
-
-.br
-
-.br
-The same PWM channel is available on multiple GPIO. The latest
-frequency and dutycycle setting will be used by all GPIO which
-share a PWM channel.
-
-.br
-
-.br
-The GPIO must be one of the following.
-
-.br
-
-.br
-
-.EX
-12 PWM channel 0 All models but A and B
-.br
-13 PWM channel 1 All models but A and B
-.br
-18 PWM channel 0 All models
-.br
-19 PWM channel 1 All models but A and B
-.br
-
-.br
-40 PWM channel 0 Compute module only
-.br
-41 PWM channel 1 Compute module only
-.br
-45 PWM channel 1 Compute module only
-.br
-52 PWM channel 0 Compute module only
-.br
-53 PWM channel 1 Compute module only
-.br
-
-.EE
-
-.br
-
-.br
-The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
-
-.br
-
-.br
-The actual frequency set is 250 million / steps.
-
-.br
-
-.br
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
-frequencies will have fewer steps. PWMduty is
-automatically scaled to take this into account.
-
-.IP "\fBuint32_t get_current_tick(int pi)\fP"
-.IP "" 4
-Gets the current system tick.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Tick is the number of microseconds since system boot.
-
-.br
-
-.br
-As tick is an unsigned 32 bit quantity it wraps around after
-2**32 microseconds, which is approximately 1 hour 12 minutes.
-
-.br
-
-.br
-
-.IP "\fBuint32_t get_hardware_revision(int pi)\fP"
-.IP "" 4
-Get the Pi's hardware revision number.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-The hardware revision is the last few characters on the Revision line
-of /proc/cpuinfo.
-
-.br
-
-.br
-If the hardware revision can not be found or is not a valid
-hexadecimal number the function returns 0.
-
-.br
-
-.br
-The revision number can be used to determine the assignment of GPIO
-to pins (see \fBgpio\fP).
-
-.br
-
-.br
-There are at least three types of board.
-
-.br
-
-.br
-Type 1 boards have hardware revision numbers of 2 and 3.
-
-.br
-
-.br
-Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
-
-.br
-
-.br
-Type 3 boards have hardware revision numbers of 16 or greater.
-
-.IP "\fBuint32_t get_pigpio_version(int pi)\fP"
-.IP "" 4
-Returns the pigpio version.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_clear(int pi)\fP"
-.IP "" 4
-This function clears all waveforms and any data added by calls to the
-\fBwave_add_*\fP functions.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.IP "\fBint wave_add_new(int pi)\fP"
-.IP "" 4
-This function starts a new empty waveform. You wouldn't normally need
-to call this function as it is automatically called after a waveform is
-created with the \fBwave_create\fP function.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.IP "\fBint wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses)\fP"
-.IP "" 4
-This function adds a number of pulses to the current waveform.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-numPulses: the number of pulses.
-.br
- pulses: an array of pulses.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-.br
-
-.br
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-.br
-
-.br
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist solely of a delay.
-
-.IP "\fBint wave_add_serial(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits, unsigned stop_bits, unsigned offset, unsigned numBytes, char *str)\fP"
-.IP "" 4
-This function adds a waveform representing serial data to the
-existing waveform (if any). The serial data starts offset
-microseconds from the start of the waveform.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- baud: 50-1000000
-.br
-data_bits: number of data bits (1-32)
-.br
-stop_bits: number of stop half bits (2-8)
-.br
- offset: >=0
-.br
- numBytes: >=1
-.br
- str: an array of chars.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-.br
-
-.br
-NOTES:
-
-.br
-
-.br
-The serial data is formatted as one start bit, \fBdata_bits\fP data bits,
-and \fBstop_bits\fP/2 stop bits.
-
-.br
-
-.br
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-.br
-
-.br
-\fBnumBytes\fP is the number of bytes of data in str.
-
-.br
-
-.br
-The bytes required for each character depend upon \fBdata_bits\fP.
-
-.br
-
-.br
-For \fBdata_bits\fP 1-8 there will be one byte per character.
-.br
-For \fBdata_bits\fP 9-16 there will be two bytes per character.
-.br
-For \fBdata_bits\fP 17-32 there will be four bytes per character.
-
-.IP "\fBint wave_create(int pi)\fP"
-.IP "" 4
-This function creates a waveform from the data provided by the prior
-calls to the \fBwave_add_*\fP functions. Upon success a wave id
-greater than or equal to 0 is returned, otherwise PI_EMPTY_WAVEFORM,
-PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-The data provided by the \fBwave_add_*\fP functions is consumed by this
-function.
-
-.br
-
-.br
-As many waveforms may be created as there is space available. The
-wave id is passed to \fBwave_send_*\fP to specify the waveform to transmit.
-
-.br
-
-.br
-Normal usage would be
-
-.br
-
-.br
-Step 1. \fBwave_clear\fP to clear all waveforms and added data.
-
-.br
-
-.br
-Step 2. \fBwave_add_*\fP calls to supply the waveform data.
-
-.br
-
-.br
-Step 3. \fBwave_create\fP to create the waveform and get a unique id
-
-.br
-
-.br
-Repeat steps 2 and 3 as needed.
-
-.br
-
-.br
-Step 4. \fBwave_send_*\fP with the id of the waveform to transmit.
-
-.br
-
-.br
-A waveform comprises one or more pulses. Each pulse consists of a
-\fBgpioPulse_t\fP structure.
-
-.br
-
-.br
-
-.EX
-typedef struct
-.br
-{
-.br
- uint32_t gpioOn;
-.br
- uint32_t gpioOff;
-.br
- uint32_t usDelay;
-.br
-} gpioPulse_t;
-.br
-
-.EE
-
-.br
-
-.br
-The fields specify
-
-.br
-
-.br
-1) the GPIO to be switched on at the start of the pulse.
-.br
-2) the GPIO to be switched off at the start of the pulse.
-.br
-3) the delay in microseconds before the next pulse.
-.br
-
-.br
-
-.br
-Any or all the fields can be zero. It doesn't make any sense to
-set all the fields to zero (the pulse will be ignored).
-
-.br
-
-.br
-When a waveform is started each pulse is executed in order with the
-specified delay between the pulse and the next.
-
-.br
-
-.br
-Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
-PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
-
-.IP "\fBint wave_delete(int pi, unsigned wave_id)\fP"
-.IP "" 4
-This function deletes the waveform with id wave_id.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-
-.IP "\fBint wave_send_once(int pi, unsigned wave_id)\fP"
-.IP "" 4
-This function transmits the waveform with id wave_id. The waveform
-is sent once.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint wave_send_repeat(int pi, unsigned wave_id)\fP"
-.IP "" 4
-This function transmits the waveform with id wave_id. The waveform
-cycles until cancelled (either by the sending of a new waveform or
-by \fBwave_tx_stop\fP).
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)\fP"
-.IP "" 4
-Transmits the waveform with id wave_id using mode mode.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-wave_id: >=0, as returned by \fBwave_create\fP.
-.br
- mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
-.br
- PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
-.br
-
-.EE
-
-.br
-
-.br
-PI_WAVE_MODE_ONE_SHOT: same as \fBwave_send_once\fP.
-
-.br
-
-.br
-PI_WAVE_MODE_REPEAT same as \fBwave_send_repeat\fP.
-
-.br
-
-.br
-PI_WAVE_MODE_ONE_SHOT_SYNC same as \fBwave_send_once\fP but tries
-to sync with the previous waveform.
-
-.br
-
-.br
-PI_WAVE_MODE_REPEAT_SYNC same as \fBwave_send_repeat\fP but tries
-to sync with the previous waveform.
-
-.br
-
-.br
-WARNING: bad things may happen if you delete the previous
-waveform before it has been synced to the new waveform.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-
-.IP "\fBint wave_chain(int pi, char *buf, unsigned bufSize)\fP"
-.IP "" 4
-This function transmits a chain of waveforms.
-
-.br
-
-.br
-NOTE: Any hardware PWM started by \fBhardware_PWM\fP will be cancelled.
-
-.br
-
-.br
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of \fBwave_id\fPs and optional command
-codes and related data.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- buf: pointer to the wave_ids and optional command codes
-.br
-bufSize: the number of bytes in buf
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-.br
-
-.br
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-.br
-
-.br
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-.br
-
-.br
-Delays between waves may be added with the delay command.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-Loop Start 255 0 Identify start of a wave block
-.br
-Loop Repeat 255 1 x y loop x + y*256 times
-.br
-Delay 255 2 x y delay x + y*256 microseconds
-.br
-Loop Forever 255 3 loop forever
-.br
-
-.br
-
-.br
-If present Loop Forever must be the last entry in the chain.
-
-.br
-
-.br
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-#define WAVES 5
-.br
-#define GPIO 4
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int i, pi, wid[WAVES];
-.br
-
-.br
- pi = pigpio_start(0, 0);
-.br
- if (pi<0) return -1;
-.br
-
-.br
- set_mode(pi, GPIO, PI_OUTPUT);
-.br
-
-.br
- for (i=0; i=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns the waveform id or one of the following special values:
-
-.br
-
-.br
-PI_WAVE_NOT_FOUND (9998) - transmitted wave not found.
-.br
-PI_NO_TX_WAVE (9999) - no wave being transmitted.
-
-.IP "\fBint wave_tx_busy(int pi)\fP"
-.IP "" 4
-This function checks to see if a waveform is currently being
-transmitted.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 1 if a waveform is currently being transmitted, otherwise 0.
-
-.IP "\fBint wave_tx_stop(int pi)\fP"
-.IP "" 4
-This function stops the transmission of the current waveform.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK.
-
-.br
-
-.br
-This function is intended to stop a waveform started with the repeat mode.
-
-.IP "\fBint wave_get_micros(int pi)\fP"
-.IP "" 4
-This function returns the length in microseconds of the current
-waveform.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_high_micros(int pi)\fP"
-.IP "" 4
-This function returns the length in microseconds of the longest waveform
-created since the pigpio daemon was started.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_max_micros(int pi)\fP"
-.IP "" 4
-This function returns the maximum possible size of a waveform in
-.br
-microseconds.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_pulses(int pi)\fP"
-.IP "" 4
-This function returns the length in pulses of the current waveform.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_high_pulses(int pi)\fP"
-.IP "" 4
-This function returns the length in pulses of the longest waveform
-created since the pigpio daemon was started.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_max_pulses(int pi)\fP"
-.IP "" 4
-This function returns the maximum possible size of a waveform in pulses.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_cbs(int pi)\fP"
-.IP "" 4
-This function returns the length in DMA control blocks of the current
-waveform.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_high_cbs(int pi)\fP"
-.IP "" 4
-This function returns the length in DMA control blocks of the longest
-waveform created since the pigpio daemon was started.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint wave_get_max_cbs(int pi)\fP"
-.IP "" 4
-This function returns the maximum possible size of a waveform in DMA
-control blocks.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-
-.EE
-
-.IP "\fBint gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, unsigned level)\fP"
-.IP "" 4
-This function sends a trigger pulse to a GPIO. The GPIO is set to
-level for pulseLen microseconds and then reset to not level.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- pulseLen: 1-100.
-.br
- level: 0,1.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_LEVEL,
-PI_BAD_PULSELEN, or PI_NOT_PERMITTED.
-
-.IP "\fBint store_script(int pi, char *script)\fP"
-.IP "" 4
-This function stores a script for later execution.
-
-.br
-
-.br
-See \fBhttp://abyz.co.uk/rpi/pigpio/pigs.html#Scripts\fP for details.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-script: the text of the script.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a script id if the script is valid,
-otherwise PI_BAD_SCRIPT.
-
-.IP "\fBint run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)\fP"
-.IP "" 4
-This function runs a stored script.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
- numPar: 0-10, the number of parameters.
-.br
- param: an array of parameters.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID, or
-PI_TOO_MANY_PARAM
-
-.br
-
-.br
-param is an array of up to 10 parameters which may be referenced in
-the script as p0 to p9.
-
-.IP "\fBint script_status(int pi, unsigned script_id, uint32_t *param)\fP"
-.IP "" 4
-This function returns the run status of a stored script as well
-as the current values of parameters 0 to 9.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
- param: an array to hold the returned 10 parameters.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns greater than or equal to 0 if OK,
-otherwise PI_BAD_SCRIPT_ID.
-
-.br
-
-.br
-The run status may be
-
-.br
-
-.br
-
-.EX
-PI_SCRIPT_INITING
-.br
-PI_SCRIPT_HALTED
-.br
-PI_SCRIPT_RUNNING
-.br
-PI_SCRIPT_WAITING
-.br
-PI_SCRIPT_FAILED
-.br
-
-.EE
-
-.br
-
-.br
-The current value of script parameters 0 to 9 are returned in param.
-
-.IP "\fBint stop_script(int pi, unsigned script_id)\fP"
-.IP "" 4
-This function stops a running script.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint delete_script(int pi, unsigned script_id)\fP"
-.IP "" 4
-This function deletes a stored script.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-script_id: >=0, as returned by \fBstore_script\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise PI_BAD_SCRIPT_ID.
-
-.IP "\fBint bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, unsigned data_bits)\fP"
-.IP "" 4
-This function opens a GPIO for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- baud: 50-250000
-.br
-data_bits: 1-32
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD,
-or PI_GPIO_IN_USE.
-
-.br
-
-.br
-The serial data is returned in a cyclic buffer and is read using
-bb_serial_read.
-
-.br
-
-.br
-It is the caller's responsibility to read data from the cyclic buffer
-in a timely fashion.
-
-.IP "\fBint bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize)\fP"
-.IP "" 4
-This function copies up to bufSize bytes of data read from the
-bit bang serial cyclic buffer to the buffer starting at buf.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
- buf: an array to receive the read bytes.
-.br
- bufSize: >=0
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes copied if OK, otherwise PI_BAD_USER_GPIO
-or PI_NOT_SERIAL_GPIO.
-
-.br
-
-.br
-The bytes returned for each character depend upon the number of
-data bits \fBdata_bits\fP specified in the \fBbb_serial_read_open\fP command.
-
-.br
-
-.br
-For \fBdata_bits\fP 1-8 there will be one byte per character.
-.br
-For \fBdata_bits\fP 9-16 there will be two bytes per character.
-.br
-For \fBdata_bits\fP 17-32 there will be four bytes per character.
-
-.IP "\fBint bb_serial_read_close(int pi, unsigned user_gpio)\fP"
-.IP "" 4
-This function closes a GPIO for bit bang reading of serial data.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SERIAL_GPIO.
-
-.IP "\fBint bb_serial_invert(int pi, unsigned user_gpio, unsigned invert)\fP"
-.IP "" 4
-This function inverts serial logic for big bang serial reads.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31, previously opened with \fBbb_serial_read_open\fP.
-.br
- invert: 0-1, 1 invert, 0 normal.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_NOT_SERIAL_GPIO or PI_BAD_SER_INVERT.
-
-.IP "\fBint i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, unsigned i2c_flags)\fP"
-.IP "" 4
-This returns a handle for the device at address i2c_addr on bus i2c_bus.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- i2c_bus: >=0.
-.br
- i2c_addr: 0-0x7F.
-.br
-i2c_flags: 0.
-.br
-
-.EE
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.br
-
-.br
-Physically buses 0 and 1 are available on the Pi. Higher numbered buses
-will be available if a kernel supported bus multiplexor is being used.
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_I2C_BUS, PI_BAD_I2C_ADDR,
-PI_BAD_FLAGS, PI_NO_HANDLE, or PI_I2C_OPEN_FAILED.
-
-.br
-
-.br
-For the SMBus commands the low level transactions are shown at the end
-of the function description. The following abbreviations are used.
-
-.br
-
-.br
-
-.EX
-S (1 bit) : Start bit
-.br
-P (1 bit) : Stop bit
-.br
-Rd/Wr (1 bit) : Read/Write bit. Rd equals 1, Wr equals 0.
-.br
-A, NA (1 bit) : Accept and not accept bit.
-.br
-.br
-.br
-Addr (7 bits): I2C 7 bit address.
-.br
-i2c_reg (8 bits): A byte which often selects a register.
-.br
-Data (8 bits): A data byte.
-.br
-Count (8 bits): A byte defining the length of a block operation.
-.br
-
-.br
-[..]: Data sent by the device.
-.br
-
-.EE
-
-.IP "\fBint i2c_close(int pi, unsigned handle)\fP"
-.IP "" 4
-This closes the I2C device associated with the handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint i2c_write_quick(int pi, unsigned handle, unsigned bit)\fP"
-.IP "" 4
-This sends a single bit (in the Rd/Wr bit) to the device associated
-with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- bit: 0-1, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Quick command. SMBus 2.0 5.5.1
-
-.EX
-S Addr bit [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_byte(int pi, unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This sends a single byte to the device associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- bVal: 0-0xFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Send byte. SMBus 2.0 5.5.2
-
-.EX
-S Addr Wr [A] bVal [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_byte(int pi, unsigned handle)\fP"
-.IP "" 4
-This reads a single byte from the device associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Receive byte. SMBus 2.0 5.5.3
-
-.EX
-S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_byte_data(int pi, unsigned handle, unsigned i2c_reg, unsigned bVal)\fP"
-.IP "" 4
-This writes a single byte to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- bVal: 0-0xFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write byte. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] i2c_reg [A] bVal [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_word_data(int pi, unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
-.IP "" 4
-This writes a single 16 bit word to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- wVal: 0-0xFFFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Write word. SMBus 2.0 5.5.4
-
-.EX
-S Addr Wr [A] i2c_reg [A] wval_Low [A] wVal_High [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_byte_data(int pi, unsigned handle, unsigned i2c_reg)\fP"
-.IP "" 4
-This reads a single byte from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the byte read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read byte. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] i2c_reg [A] S Addr Rd [A] [Data] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_word_data(int pi, unsigned handle, unsigned i2c_reg)\fP"
-.IP "" 4
-This reads a single 16 bit word from the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Read word. SMBus 2.0 5.5.5
-
-.EX
-S Addr Wr [A] i2c_reg [A]
-.br
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_process_call(int pi, unsigned handle, unsigned i2c_reg, unsigned wVal)\fP"
-.IP "" 4
-This writes 16 bits of data to the specified register of the device
-associated with handle and and reads 16 bits of data in return.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write/read.
-.br
- wVal: 0-0xFFFF, the value to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the word read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Process call. SMBus 2.0 5.5.6
-
-.EX
-S Addr Wr [A] i2c_reg [A] wVal_Low [A] wVal_High [A]
-.br
- S Addr Rd [A] [DataLow] A [DataHigh] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes up to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- buf: an array with the data to send.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-Block write. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] buf1 [A] ...
-.br
- [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf)\fP"
-.IP "" 4
-This reads a block of up to 32 bytes from the specified register of
-the device associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
- buf: an array to receive the read data.
-.br
-
-.EE
-
-.br
-
-.br
-The amount of returned data is set by the device.
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-Block read. SMBus 2.0 5.5.7
-
-.EX
-S Addr Wr [A] i2c_reg [A]
-.br
- S Addr Rd [A] [Count] A [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_block_process_call(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes data bytes to the specified register of the device
-associated with handle and reads a device specified number
-of bytes of data in return.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write/read.
-.br
- buf: an array with the data to send and to receive the read data.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-
-.br
-
-.br
-Returns the number of bytes read (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-The smbus 2.0 documentation states that a minimum of 1 byte may be
-sent and a minimum of 1 byte may be received. The total number of
-bytes sent/received must be 32 or less.
-
-.br
-
-.br
-Block write-block read. SMBus 2.0 5.5.8
-
-.EX
-S Addr Wr [A] i2c_reg [A] count [A] buf0 [A] ...
-.br
- S Addr Rd [A] [Count] A [Data] ... A P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_i2c_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the specified register of the device
-associated with handle . The count may be 1-32.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to read.
-.br
- buf: an array to receive the read data.
-.br
- count: 1-32, the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, or PI_I2C_READ_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] i2c_reg [A]
-.br
- S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_i2c_block_data(int pi, unsigned handle, unsigned i2c_reg, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes 1 to 32 bytes to the specified register of the device
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
-i2c_reg: 0-255, the register to write.
-.br
- buf: the data to write.
-.br
- count: 1-32, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] i2c_reg [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_read_device(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This reads count bytes from the raw device into buf.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- buf: an array to receive the read data bytes.
-.br
- count: >0, the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns count (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_READ_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Rd [A] [buf0] A [buf1] A ... A [bufn] NA P
-.br
-
-.EE
-
-.IP "\fBint i2c_write_device(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This writes count bytes from buf to the raw device.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2c_open\fP.
-.br
- buf: an array containing the data bytes to write.
-.br
- count: >0, the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-
-.EX
-S Addr Wr [A] buf0 [A] buf1 [A] ... [A] bufn [A] P
-.br
-
-.EE
-
-.IP "\fBint i2c_zip(int pi, unsigned handle, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBi2cOpen\fP
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_HANDLE, PI_BAD_POINTER, PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN.
-PI_BAD_I2C_WLEN, or PI_BAD_I2C_SEG.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-On 2 Switch combined flag on
-.br
-Off 3 Switch combined flag off
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address defaults to that associated with the handle.
-The flags default to 0. The address and flags maintain their
-previous value until updated.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53, write 0x32, read 6 bytes
-.br
-Set address 0x1E, write 0x03, read 6 bytes
-.br
-Set address 0x68, write 0x1B, read 8 bytes
-.br
-End
-.br
-
-.br
-0x04 0x53 0x07 0x01 0x32 0x06 0x06
-.br
-0x04 0x1E 0x07 0x01 0x03 0x06 0x06
-.br
-0x04 0x68 0x07 0x01 0x1B 0x06 0x08
-.br
-0x00
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBint bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud)\fP"
-.IP "" 4
-This function selects a pair of GPIO for bit banging I2C at a
-specified baud rate.
-
-.br
-
-.br
-Bit banging I2C allows for certain operations which are not possible
-with the standard I2C driver.
-
-.br
-
-.br
-o baud rates as low as 50
-.br
-o repeated starts
-.br
-o clock stretching
-.br
-o I2C on any pair of spare GPIO
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- SDA: 0-31
-.br
- SCL: 0-31
-.br
-baud: 50-500000
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_I2C_BAUD, or
-PI_GPIO_IN_USE.
-
-.br
-
-.br
-NOTE:
-
-.br
-
-.br
-The GPIO used for SDA and SCL must have pull-ups to 3V3 connected. As
-a guide the hardware pull-ups on pins 3 and 5 are 1k8 in value.
-
-.IP "\fBint bb_i2c_close(int pi, unsigned SDA)\fP"
-.IP "" 4
-This function stops bit banging I2C on a pair of GPIO previously
-opened with \fBbb_i2c_open\fP.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-SDA: 0-31, the SDA GPIO used in a prior call to \fBbb_i2c_open\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_I2C_GPIO.
-
-.IP "\fBint bb_i2c_zip(int pi, unsigned SDA, char *inBuf, unsigned inLen, char *outBuf, unsigned outLen)\fP"
-.IP "" 4
-This function executes a sequence of bit banged I2C operations. The
-operations to be performed are specified by the contents of inBuf
-which contains the concatenated command codes and associated data.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- SDA: 0-31 (as used in a prior call to \fBbb_i2c_open\fP)
-.br
- inBuf: pointer to the concatenated I2C commands, see below
-.br
- inLen: size of command buffer
-.br
-outBuf: pointer to buffer to hold returned data
-.br
-outLen: size of output buffer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_I2C_GPIO, PI_BAD_POINTER,
-PI_BAD_I2C_CMD, PI_BAD_I2C_RLEN, PI_BAD_I2C_WLEN,
-PI_I2C_READ_FAILED, or PI_I2C_WRITE_FAILED.
-
-.br
-
-.br
-The following command codes are supported:
-
-.br
-
-.br
-Name Cmd & Data Meaning
-.br
-End 0 No more commands
-.br
-Escape 1 Next P is two bytes
-.br
-Start 2 Start condition
-.br
-Stop 3 Stop condition
-.br
-Address 4 P Set I2C address to P
-.br
-Flags 5 lsb msb Set I2C flags to lsb + (msb << 8)
-.br
-Read 6 P Read P bytes of data
-.br
-Write 7 P ... Write P bytes of data
-.br
-
-.br
-
-.br
-The address, read, and write commands take a parameter P.
-Normally P is one byte (0-255). If the command is preceded by
-the Escape command then P is two bytes (0-65535, least significant
-byte first).
-
-.br
-
-.br
-The address and flags default to 0. The address and flags maintain
-their previous value until updated.
-
-.br
-
-.br
-No flags are currently defined.
-
-.br
-
-.br
-The returned I2C data is stored in consecutive locations of outBuf.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-Set address 0x53
-.br
-start, write 0x32, (re)start, read 6 bytes, stop
-.br
-Set address 0x1E
-.br
-start, write 0x03, (re)start, read 6 bytes, stop
-.br
-Set address 0x68
-.br
-start, write 0x1B, (re)start, read 8 bytes, stop
-.br
-End
-.br
-
-.br
-0x04 0x53
-.br
-0x02 0x07 0x01 0x32 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x1E
-.br
-0x02 0x07 0x01 0x03 0x02 0x06 0x06 0x03
-.br
-
-.br
-0x04 0x68
-.br
-0x02 0x07 0x01 0x1B 0x02 0x06 0x08 0x03
-.br
-
-.br
-0x00
-.br
-
-.EE
-
-.IP "\fBint bb_spi_open(int pi, unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK, unsigned baud, unsigned spi_flags)\fP"
-.IP "" 4
-This function selects a set of GPIO for bit banging SPI at a
-specified baud rate.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- CS: 0-31
-.br
- MISO: 0-31
-.br
- MOSI: 0-31
-.br
- SCLK: 0-31
-.br
- baud: 50-250000
-.br
-spi_flags: see below
-.br
-
-.EE
-
-.br
-
-.br
-spi_flags consists of the least significant 22 bits.
-
-.br
-
-.br
-
-.EX
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-.br
- 0 0 0 0 0 0 R T 0 0 0 0 0 0 0 0 0 0 0 p m m
-.br
-
-.EE
-
-.br
-
-.br
-mm defines the SPI mode, defaults to 0
-
-.br
-
-.br
-
-.EX
-Mode CPOL CPHA
-.br
- 0 0 0
-.br
- 1 0 1
-.br
- 2 1 0
-.br
- 3 1 1
-.br
-
-.EE
-
-.br
-
-.br
-p is 0 if CS is active low (default) and 1 for active high.
-
-.br
-
-.br
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first.
-
-.br
-
-.br
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first.
-
-.br
-
-.br
-The other bits in flags should be set to zero.
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_SPI_BAUD, or
-PI_GPIO_IN_USE.
-
-.br
-
-.br
-If more than one device is connected to the SPI bus (defined by
-SCLK, MOSI, and MISO) each must have its own CS.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-bb_spi_open(pi,10, MISO, MOSI, SCLK, 10000, 0); // device 1
-.br
-bb_spi_open(pi,11, MISO, MOSI, SCLK, 20000, 3); // device 2
-.br
-
-.EE
-
-.IP "\fBint bb_spi_close(int pi, unsigned CS)\fP"
-.IP "" 4
-This function stops bit banging SPI on a set of GPIO
-opened with \fBbbSPIOpen\fP.
-
-.br
-
-.br
-
-.EX
-pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-CS: 0-31, the CS GPIO used in a prior call to \fBbb_spi_open\fP
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_NOT_SPI_GPIO.
-
-.IP "\fBint bb_spi_xfer(int pi, unsigned CS, char *txBuf, char *rxBuf, unsigned count)\fP"
-.IP "" 4
-This function executes a bit banged SPI transfer.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- CS: 0-31 (as used in a prior call to \fBbb_spi_open\fP)
-.br
-txBuf: pointer to buffer to hold data to be sent
-.br
-rxBuf: pointer to buffer to hold returned data
-.br
-count: size of data transfer
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK (the number of bytes read), otherwise
-PI_BAD_USER_GPIO, PI_NOT_SPI_GPIO or PI_BAD_POINTER.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// gcc -Wall -pthread -o bb_spi_x_test bb_spi_x_test.c -lpigpiod_if2
-.br
-// ./bb_spi_x_test
-.br
-
-.br
-#include
-.br
-
-.br
-#include "pigpiod_if2.h"
-.br
-
-.br
-#define CE0 5
-.br
-#define CE1 6
-.br
-#define MISO 13
-.br
-#define MOSI 19
-.br
-#define SCLK 12
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int i, pi, count, set_val, read_val;
-.br
- unsigned char inBuf[3];
-.br
- char cmd1[] = {0, 0};
-.br
- char cmd2[] = {12, 0};
-.br
- char cmd3[] = {1, 128, 0};
-.br
-
-.br
- if ((pi = pigpio_start(0, 0)) < 0)
-.br
- {
-.br
- fprintf(stderr, "pigpio initialisation failed (%d).\n", pi);
-.br
- return 1;
-.br
- }
-.br
-
-.br
- bb_spi_open(pi, CE0, MISO, MOSI, SCLK, 10000, 0); // MCP4251 DAC
-.br
- bb_spi_open(pi, CE1, MISO, MOSI, SCLK, 20000, 3); // MCP3008 ADC
-.br
-
-.br
- for (i=0; i<256; i++)
-.br
- {
-.br
- cmd1[1] = i;
-.br
-
-.br
- count = bb_spi_xfer(pi, CE0, cmd1, (char *)inBuf, 2); // > DAC
-.br
-
-.br
- if (count == 2)
-.br
- {
-.br
- count = bb_spi_xfer(pi, CE0, cmd2, (char *)inBuf, 2); // < DAC
-.br
-
-.br
- if (count == 2)
-.br
- {
-.br
- set_val = inBuf[1];
-.br
-
-.br
- count = bb_spi_xfer(pi, CE1, cmd3, (char *)inBuf, 3); // < ADC
-.br
-
-.br
- if (count == 3)
-.br
- {
-.br
- read_val = ((inBuf[1]&3)<<8) | inBuf[2];
-.br
- printf("%d %d\n", set_val, read_val);
-.br
- }
-.br
- }
-.br
- }
-.br
- }
-.br
-
-.br
- bb_spi_close(pi, CE0);
-.br
- bb_spi_close(pi, CE1);
-.br
-
-.br
- pigpio_stop(pi);
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint spi_open(int pi, unsigned spi_channel, unsigned baud, unsigned spi_flags)\fP"
-.IP "" 4
-This function returns a handle for the SPI device on channel.
-Data will be transferred at baud bits per second. The flags may
-be used to modify the default behaviour of 4-wire operation, mode 0,
-active low chip select.
-
-.br
-
-.br
-An auxiliary SPI device is available on all models but the
-A and B and may be selected by setting the A bit in the
-flags. The auxiliary device has 3 chip selects and a
-selectable word size in bits.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-spi_channel: 0-1 (0-2 for the auxiliary device).
-.br
- baud: 32K-125M (values above 30M are unlikely to work).
-.br
- spi_flags: see below.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_BAD_SPI_CHANNEL,
-PI_BAD_SPI_SPEED, PI_BAD_FLAGS, PI_NO_AUX_SPI, or PI_SPI_OPEN_FAILED.
-
-.br
-
-.br
-spi_flags consists of the least significant 22 bits.
-
-.br
-
-.br
-
-.EX
-21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
-.br
- b b b b b b R T n n n n W A u2 u1 u0 p2 p1 p0 m m
-.br
-
-.EE
-
-.br
-
-.br
-mm defines the SPI mode.
-
-.br
-
-.br
-Warning: modes 1 and 3 do not appear to work on the auxiliary device.
-
-.br
-
-.br
-
-.EX
-Mode POL PHA
-.br
- 0 0 0
-.br
- 1 0 1
-.br
- 2 1 0
-.br
- 3 1 1
-.br
-
-.EE
-
-.br
-
-.br
-px is 0 if CEx is active low (default) and 1 for active high.
-
-.br
-
-.br
-ux is 0 if the CEx GPIO is reserved for SPI (default) and 1 otherwise.
-
-.br
-
-.br
-A is 0 for the standard SPI device, 1 for the auxiliary SPI.
-
-.br
-
-.br
-W is 0 if the device is not 3-wire, 1 if the device is 3-wire. Standard
-SPI device only.
-
-.br
-
-.br
-nnnn defines the number of bytes (0-15) to write before switching
-the MOSI line to MISO to read data. This field is ignored
-if W is not set. Standard SPI device only.
-
-.br
-
-.br
-T is 1 if the least significant bit is transmitted on MOSI first, the
-default (0) shifts the most significant bit out first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-R is 1 if the least significant bit is received on MISO first, the
-default (0) receives the most significant bit first. Auxiliary SPI
-device only.
-
-.br
-
-.br
-bbbbbb defines the word size in bits (0-32). The default (0)
-sets 8 bits per word. Auxiliary SPI device only.
-
-.br
-
-.br
-The \fBspi_read\fP, \fBspi_write\fP, and \fBspi_xfer\fP functions
-transfer data packed into 1, 2, or 4 bytes according to
-the word size in bits.
-
-.br
-
-.br
-For bits 1-8 there will be one byte per character.
-.br
-For bits 9-16 there will be two bytes per character.
-.br
-For bits 17-32 there will be four bytes per character.
-
-.br
-
-.br
-E.g. to transfer 32 12-bit words buf should contain 64 bytes
-and count should be 64.
-
-.br
-
-.br
-The other bits in flags should be set to zero.
-
-.IP "\fBint spi_close(int pi, unsigned handle)\fP"
-.IP "" 4
-This functions closes the SPI device identified by the handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint spi_read(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads count bytes of data from the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- buf: an array to receive the read data bytes.
-.br
- count: the number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spi_write(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes of data from buf to the SPI
-device associated with the handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- buf: the data bytes to write.
-.br
- count: the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count)\fP"
-.IP "" 4
-This function transfers count bytes of data from txBuf to the SPI
-device associated with the handle. Simultaneously count bytes of
-data are read from the device and placed in rxBuf.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBspi_open\fP.
-.br
- txBuf: the data bytes to write.
-.br
- rxBuf: the received data bytes.
-.br
- count: the number of bytes to transfer.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes transferred if OK, otherwise
-PI_BAD_HANDLE, PI_BAD_SPI_COUNT, or PI_SPI_XFER_FAILED.
-
-.IP "\fBint serial_open(int pi, char *ser_tty, unsigned baud, unsigned ser_flags)\fP"
-.IP "" 4
-This function opens a serial device at a specified baud rate
-with specified flags. The device name must start with
-/dev/tty or /dev/serial.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- ser_tty: the serial device to open.
-.br
- baud: the baud rate in bits per second, see below.
-.br
-ser_flags: 0.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, or
-PI_SER_OPEN_FAILED.
-
-.br
-
-.br
-The baud rate must be one of 50, 75, 110, 134, 150,
-200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200,
-38400, 57600, 115200, or 230400.
-
-.br
-
-.br
-No flags are currently defined. This parameter should be set to zero.
-
-.IP "\fBint serial_close(int pi, unsigned handle)\fP"
-.IP "" 4
-This function closes the serial device associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.IP "\fBint serial_write_byte(int pi, unsigned handle, unsigned bVal)\fP"
-.IP "" 4
-This function writes bVal to the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_read_byte(int pi, unsigned handle)\fP"
-.IP "" 4
-This function reads a byte from the serial port associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the read byte (>=0) if OK, otherwise PI_BAD_HANDLE,
-PI_SER_READ_NO_DATA, or PI_SER_READ_FAILED.
-
-.IP "\fBint serial_write(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes from buf to the the serial port
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
- buf: the array of bytes to write.
-.br
- count: the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, or
-PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_read(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads up to count bytes from the the serial port
-associated with handle and writes them to buf.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
- buf: an array to receive the read data.
-.br
- count: the maximum number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE,
-PI_BAD_PARAM, PI_SER_READ_NO_DATA, or PI_SER_WRITE_FAILED.
-
-.IP "\fBint serial_data_available(int pi, unsigned handle)\fP"
-.IP "" 4
-Returns the number of bytes available to be read from the
-device associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0, as returned by a call to \fBserial_open\fP.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes of data available (>=0) if OK,
-otherwise PI_BAD_HANDLE.
-
-.IP "\fBint custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned argc)\fP"
-.IP "" 4
-This function is available for user customisation.
-
-.br
-
-.br
-It returns a single integer value.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-arg1: >=0
-.br
-arg2: >=0
-.br
-argx: extra (byte) arguments
-.br
-argc: number of extra arguments
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.IP "\fBint custom_2(int pi, unsigned arg1, char *argx, unsigned argc, char *retBuf, unsigned retMax)\fP"
-.IP "" 4
-This function is available for user customisation.
-
-.br
-
-.br
-It differs from custom_1 in that it returns an array of bytes
-rather than just an integer.
-
-.br
-
-.br
-The return value is an integer indicating the number of returned bytes.
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- arg1: >=0
-.br
- argc: extra (byte) arguments
-.br
- count: number of extra arguments
-.br
-retBuf: buffer for returned data
-.br
-retMax: maximum number of bytes to return
-.br
-
-.EE
-
-.br
-
-.br
-Returns >= 0 if OK, less than 0 indicates a user defined error.
-
-.br
-
-.br
-Note, the number of returned bytes will be retMax or less.
-
-.IP "\fBint get_pad_strength(int pi, unsigned pad)\fP"
-.IP "" 4
-This function returns the pad drive strength in mA.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-pad: 0-2, the pad to get.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the pad drive strength if OK, otherwise PI_BAD_PAD.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-strength = get_pad_strength(pi, 0); // get pad 0 strength
-.br
-
-.EE
-
-.IP "\fBint set_pad_strength(int pi, unsigned pad, unsigned padStrength)\fP"
-.IP "" 4
-This function sets the pad drive strength in mA.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- pad: 0-2, the pad to set.
-.br
-padStrength: 1-16 mA.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_PAD, or PI_BAD_STRENGTH.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-set_pad_strength(pi, 0, 10); // set pad 0 strength to 10 mA
-.br
-
-.EE
-
-.IP "\fBint shell_(int pi, char *scriptName, char *scriptString)\fP"
-.IP "" 4
-This function uses the system call to execute a shell script
-with the given string as its parameter.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- scriptName: the name of the script, only alphanumeric characters,
-.br
- '-' and '_' are allowed in the name.
-.br
-scriptString: the string to pass to the script.
-.br
-
-.EE
-
-.br
-
-.br
-The exit status of the system call is returned if OK, otherwise
-PI_BAD_SHELL_STATUS.
-
-.br
-
-.br
-scriptName must exist in /opt/pigpio/cgi and must be executable.
-
-.br
-
-.br
-The returned exit status is normally 256 times that set by the
-shell script exit function. If the script can't be found 32512 will
-be returned.
-
-.br
-
-.br
-The following table gives some example returned statuses.
-
-.br
-
-.br
-Script exit status Returned system call status
-.br
-1 256
-.br
-5 1280
-.br
-10 2560
-.br
-200 51200
-.br
-script not found 32512
-.br
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-// pass two parameters, hello and world
-.br
-status = shell_(pi, "scr1", "hello world");
-.br
-
-.br
-// pass three parameters, hello, string with spaces, and world
-.br
-status = shell_(pi, "scr1", "hello 'string with spaces' world");
-.br
-
-.br
-// pass one parameter, hello string with spaces world
-.br
-status = shell_(pi, "scr1", "\"hello string with spaces world\"");
-.br
-
-.EE
-
-.IP "\fBint file_open(int pi, char *file, unsigned mode)\fP"
-.IP "" 4
-This function returns a handle to a file opened in a specified mode.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-file: the file to open.
-.br
-mode: the file open mode.
-.br
-
-.EE
-
-.br
-
-.br
-Returns a handle (>=0) if OK, otherwise PI_NO_HANDLE, PI_NO_FILE_ACCESS,
-PI_BAD_FILE_MODE, PI_FILE_OPEN_FAILED, or PI_FILE_IS_A_DIR.
-
-.br
-
-.br
-File
-
-.br
-
-.br
-A file may only be opened if permission is granted by an entry in
-/opt/pigpio/access. This is intended to allow remote access to files
-in a more or less controlled manner.
-
-.br
-
-.br
-Each entry in /opt/pigpio/access takes the form of a file path
-which may contain wildcards followed by a single letter permission.
-The permission may be R for read, W for write, U for read/write,
-and N for no access.
-
-.br
-
-.br
-Where more than one entry matches a file the most specific rule
-applies. If no entry matches a file then access is denied.
-
-.br
-
-.br
-Suppose /opt/pigpio/access contains the following entries
-
-.br
-
-.br
-
-.EX
-/home/* n
-.br
-/home/pi/shared/dir_1/* w
-.br
-/home/pi/shared/dir_2/* r
-.br
-/home/pi/shared/dir_3/* u
-.br
-/home/pi/shared/dir_1/file.txt n
-.br
-
-.EE
-
-.br
-
-.br
-Files may be written in directory dir_1 with the exception
-of file.txt.
-
-.br
-
-.br
-Files may be read in directory dir_2.
-
-.br
-
-.br
-Files may be read and written in directory dir_3.
-
-.br
-
-.br
-If a directory allows read, write, or read/write access then files may
-be created in that directory.
-
-.br
-
-.br
-In an attempt to prevent risky permissions the following paths are
-ignored in /opt/pigpio/access.
-
-.br
-
-.br
-
-.EX
-a path containing ..
-.br
-a path containing only wildcards (*?)
-.br
-a path containing less than two non-wildcard parts
-.br
-
-.EE
-
-.br
-
-.br
-Mode
-
-.br
-
-.br
-The mode may have the following values.
-
-.br
-
-.br
-Macro Value Meaning
-.br
-PI_FILE_READ 1 open file for reading
-.br
-PI_FILE_WRITE 2 open file for writing
-.br
-PI_FILE_RW 3 open file for reading and writing
-.br
-
-.br
-
-.br
-The following values may be or'd into the mode.
-
-.br
-
-.br
-Macro Value Meaning
-.br
-PI_FILE_APPEND 4 Writes append data to the end of the file
-.br
-PI_FILE_CREATE 8 The file is created if it doesn't exist
-.br
-PI_FILE_TRUNC 16 The file is truncated
-.br
-
-.br
-
-.br
-Newly created files are owned by root with permissions owner read and write.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int pi, handle, c;
-.br
- char buf[60000];
-.br
-
-.br
- pi = pigpio_start(NULL, NULL);
-.br
-
-.br
- if (pi < 0) return 1;
-.br
-
-.br
- // assumes /opt/pigpio/access contains the following line
-.br
- // /ram/*.c r
-.br
-
-.br
- handle = file_open(pi, "/ram/pigpio.c", PI_FILE_READ);
-.br
-
-.br
- if (handle >= 0)
-.br
- {
-.br
- while ((c=file_read(pi, handle, buf, sizeof(buf)-1)))
-.br
- {
-.br
- buf[c] = 0;
-.br
- printf("%s", buf);
-.br
- }
-.br
-
-.br
- file_close(pi, handle);
-.br
- }
-.br
-
-.br
- pigpio_stop(pi);
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint file_close(int pi, unsigned handle)\fP"
-.IP "" 4
-This function closes the file associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0 (as returned by \fBfile_open\fP).
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-file_close(pi, handle);
-.br
-
-.EE
-
-.IP "\fBint file_write(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function writes count bytes from buf to the the file
-associated with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0 (as returned by \fBfile_open\fP).
-.br
- buf: the array of bytes to write.
-.br
- count: the number of bytes to write.
-.br
-
-.EE
-
-.br
-
-.br
-Returns 0 if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM,
-PI_FILE_NOT_WOPEN, or PI_BAD_FILE_WRITE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-if (file_write(pi, handle, buf, 100) == 0)
-.br
-{
-.br
- // file written okay
-.br
-}
-.br
-else
-.br
-{
-.br
- // error
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint file_read(int pi, unsigned handle, char *buf, unsigned count)\fP"
-.IP "" 4
-This function reads up to count bytes from the the file
-associated with handle and writes them to buf.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-handle: >=0 (as returned by \fBfile_open\fP).
-.br
- buf: an array to receive the read data.
-.br
- count: the maximum number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of bytes read (>0) if OK, otherwise PI_BAD_HANDLE, PI_BAD_PARAM, PI_FILE_NOT_ROPEN, or PI_BAD_FILE_WRITE.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
- bytes = file_read(pi, handle, buf, sizeof(buf));
-.br
-
-.br
- if (bytes >= 0)
-.br
- {
-.br
- // process read data
-.br
- }
-.br
-
-.EE
-
-.IP "\fBint file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom)\fP"
-.IP "" 4
-This function seeks to a position within the file associated
-with handle.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- handle: >=0 (as returned by \fBfile_open\fP).
-.br
-seekOffset: the number of bytes to move. Positive offsets
-.br
- move forward, negative offsets backwards.
-.br
- seekFrom: one of PI_FROM_START (0), PI_FROM_CURRENT (1),
-.br
- or PI_FROM_END (2).
-.br
-
-.EE
-
-.br
-
-.br
-Returns the new byte position within the file (>=0) if OK, otherwise PI_BAD_HANDLE, or PI_BAD_FILE_SEEK.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-file_seek(pi, handle, 123, PI_FROM_START); // Start plus 123
-.br
-
-.br
-size = file_seek(pi, handle, 0, PI_FROM_END); // End, return size
-.br
-
-.br
-pos = file_seek(pi, handle, 0, PI_FROM_CURRENT); // Current position
-.br
-
-.EE
-
-.IP "\fBint file_list(int pi, char *fpat, char *buf, unsigned count)\fP"
-.IP "" 4
-This function returns a list of files which match a pattern.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
- fpat: file pattern to match.
-.br
- buf: an array to receive the matching file names.
-.br
-count: the maximum number of bytes to read.
-.br
-
-.EE
-
-.br
-
-.br
-Returns the number of returned bytes if OK, otherwise PI_NO_FILE_ACCESS,
-or PI_NO_FILE_MATCH.
-
-.br
-
-.br
-The pattern must match an entry in /opt/pigpio/access. The pattern
-may contain wildcards. See \fBfile_open\fP.
-
-.br
-
-.br
-NOTE
-
-.br
-
-.br
-The returned value is not the number of files, it is the number
-of bytes in the buffer. The file names are separated by newline
-characters.
-
-.br
-
-.br
-\fBExample\fP
-.br
-
-.EX
-#include
-.br
-#include
-.br
-
-.br
-int main(int argc, char *argv[])
-.br
-{
-.br
- int pi, handle, c;
-.br
- char buf[60000];
-.br
-
-.br
- pi = pigpio_start(NULL, NULL);
-.br
-
-.br
- if (pi < 0) return 1;
-.br
-
-.br
- // assumes /opt/pigpio/access contains the following line
-.br
- // /ram/*.c r
-.br
-
-.br
- c = file_list(pi, "/ram/p*.c", buf, sizeof(buf));
-.br
-
-.br
- if (c >= 0)
-.br
- {
-.br
- buf[c] = 0;
-.br
- printf("%s", buf);
-.br
- }
-.br
-
-.br
- pigpio_stop(pi);
-.br
-}
-.br
-
-.EE
-
-.IP "\fBint callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)\fP"
-.IP "" 4
-This function initialises a new callback.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- f: the callback function.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-.br
-
-.br
-The callback is called with the GPIO, edge, and tick, whenever the
-GPIO has the identified edge.
-
-.IP "\fBint callback_ex(int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *userdata)\fP"
-.IP "" 4
-This function initialises a new callback.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- f: the callback function.
-.br
- userdata: a pointer to arbitrary user data.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns a callback id if OK, otherwise pigif_bad_malloc,
-pigif_duplicate_callback, or pigif_bad_callback.
-
-.br
-
-.br
-The callback is called with the GPIO, edge, tick, and user, whenever
-the GPIO has the identified edge.
-
-.IP "\fBint callback_cancel(unsigned callback_id)\fP"
-.IP "" 4
-This function cancels a callback identified by its id.
-
-.br
-
-.br
-
-.EX
-callback_id: >=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns 0 if OK, otherwise pigif_callback_not_found.
-
-.IP "\fBint wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)\fP"
-.IP "" 4
-This function waits for edge on the GPIO for up to timeout
-seconds.
-
-.br
-
-.br
-
-.EX
- pi: >=0 (as returned by \fBpigpio_start\fP).
-.br
-user_gpio: 0-31.
-.br
- edge: RISING_EDGE, FALLING_EDGE, or EITHER_EDGE.
-.br
- timeout: >=0.
-.br
-
-.EE
-
-.br
-
-.br
-The function returns when the edge occurs or after the timeout.
-
-.br
-
-.br
-Do not use this function for precise timing purposes,
-the edge is only checked 20 times a second. Whenever
-you need to know the accurate time of GPIO events use
-a \fBcallback\fP function.
-
-.br
-
-.br
-The function returns 1 if the edge occurred, otherwise 0.
-.SH PARAMETERS
-
-.br
-
-.br
-
-.IP "\fBactive\fP: 0-1000000" 0
-
-.br
-
-.br
-The number of microseconds level changes are reported for once
-a noise filter has been triggered (by \fBsteady\fP microseconds of
-a stable level).
-
-.br
-
-.br
-
-.IP "\fB*addrStr\fP" 0
-A string specifying the host or IP address of the Pi running
-the pigpio daemon. It may be NULL in which case localhost
-is used unless overridden by the PIGPIO_ADDR environment
-variable.
-
-.br
-
-.br
-
-.IP "\fBarg1\fP" 0
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBarg2\fP" 0
-An unsigned argument passed to a user customised function. Its
-meaning is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBargc\fP" 0
-The count of bytes passed to a user customised function.
-
-.br
-
-.br
-
-.IP "\fB*argx\fP" 0
-A pointer to an array of bytes passed to a user customised function.
-Its meaning and content is defined by the customiser.
-
-.br
-
-.br
-
-.IP "\fBbaud\fP" 0
-The speed of serial communication (I2C, SPI, serial link, waves) in
-bits per second.
-
-.br
-
-.br
-
-.IP "\fBbit\fP" 0
-A value of 0 or 1.
-
-.br
-
-.br
-
-.IP "\fBbits\fP" 0
-A value used to select GPIO. If bit n of bits is set then GPIO n is
-selected.
-
-.br
-
-.br
-A convenient way to set bit n is to or in (1<=0, as returned by a call to \fBcallback\fP or \fBcallback_ex\fP. This is
-passed to \fBcallback_cancel\fP to cancel the callback.
-
-.br
-
-.br
-
-.IP "\fBCBFunc_t\fP" 0
-
-.EX
-typedef void (*CBFunc_t)
-.br
- (unsigned user_gpio, unsigned level, uint32_t tick);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBCBFuncEx_t\fP" 0
-
-.EX
-typedef void (*CBFuncEx_t)
-.br
- (unsigned user_gpio, unsigned level, uint32_t tick, void * user);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBchar\fP" 0
-A single character, an 8 bit quantity able to store 0-255.
-
-.br
-
-.br
-
-.IP "\fBclkfreq\fP: 4689-250000000 (250M)" 0
-The hardware clock frequency.
-
-.br
-
-.br
-
-.IP "\fBcount\fP" 0
-The number of bytes to be transferred in a file, I2C, SPI, or serial
-command.
-
-.br
-
-.br
-
-.IP "\fBCS\fP" 0
-The GPIO used for the slave select signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fBdata_bits\fP: 1-32" 0
-The number of data bits in each character of serial data.
-
-.br
-
-.br
-
-.EX
-#define PI_MIN_WAVE_DATABITS 1
-.br
-#define PI_MAX_WAVE_DATABITS 32
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBdouble\fP" 0
-A floating point number.
-
-.br
-
-.br
-
-.IP "\fBdutycycle\fP: 0-range" 0
-A number representing the ratio of on time to off time for PWM.
-
-.br
-
-.br
-The number may vary between 0 and range (default 255) where
-0 is off and range is fully on.
-
-.br
-
-.br
-
-.IP "\fBedge\fP" 0
-Used to identify a GPIO level transition of interest. A rising edge is
-a level change from 0 to 1. A falling edge is a level change from 1 to 0.
-
-.br
-
-.br
-
-.EX
-RISING_EDGE 0
-.br
-FALLING_EDGE 1
-.br
-EITHER_EDGE. 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBerrnum\fP" 0
-A negative number indicating a function call failed and the nature
-of the error.
-
-.br
-
-.br
-
-.IP "\fBf\fP" 0
-A function.
-
-.br
-
-.br
-
-.IP "\fB*file\fP" 0
-A full file path. To be accessible the path must match an entry in
-/opt/pigpio/access.
-
-.br
-
-.br
-
-.IP "\fB*fpat\fP" 0
-A file path which may contain wildcards. To be accessible the path
-must match an entry in /opt/pigpio/access.
-
-.br
-
-.br
-
-.IP "\fBfrequency\fP: >=0" 0
-The number of times a GPIO is swiched on and off per second. This
-can be set per GPIO and may be as little as 5Hz or as much as
-40KHz. The GPIO will be on for a proportion of the time as defined
-by its dutycycle.
-
-.br
-
-.br
-
-.IP "\fBgpio\fP" 0
-A Broadcom numbered GPIO, in the range 0-53.
-
-.br
-
-.br
-There are 54 General Purpose Input Outputs (GPIO) named GPIO0 through
-GPIO53.
-
-.br
-
-.br
-They are split into two banks. Bank 1 consists of GPIO0 through
-GPIO31. Bank 2 consists of GPIO32 through GPIO53.
-
-.br
-
-.br
-All the GPIO which are safe for the user to read and write are in
-bank 1. Not all GPIO in bank 1 are safe though. Type 1 boards
-have 17 safe GPIO. Type 2 boards have 21. Type 3 boards have 26.
-
-.br
-
-.br
-See \fBget_hardware_revision\fP.
-
-.br
-
-.br
-The user GPIO are marked with an X in the following table.
-
-.br
-
-.br
-
-.EX
- 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
-.br
-Type 1 X X - - X - - X X X X X - - X X
-.br
-Type 2 - - X X X - - X X X X X - - X X
-.br
-Type 3 X X X X X X X X X X X X X X
-.br
-
-.br
- 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
-.br
-Type 1 - X X - - X X X X X - - - - - -
-.br
-Type 2 - X X - - - X X X X - X X X X X
-.br
-Type 3 X X X X X X X X X X X X - - - -
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioPulse_t\fP" 0
-
-.EX
-typedef struct
-.br
-{
-.br
-uint32_t gpioOn;
-.br
-uint32_t gpioOff;
-.br
-uint32_t usDelay;
-.br
-} gpioPulse_t;
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBgpioThreadFunc_t\fP" 0
-
-.EX
-typedef void *(gpioThreadFunc_t) (void *);
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBhandle\fP: >=0" 0
-A number referencing an object opened by one of \fBfile_open\fP,
-\fBi2c_open\fP, \fBnotify_open\fP, \fBserial_open\fP, and \fBspi_open\fP.
-
-.br
-
-.br
-
-.IP "\fBi2c_addr\fP: 0-0x7F" 0
-The address of a device on the I2C bus.
-
-.br
-
-.br
-
-.IP "\fBi2c_bus\fP: >=0" 0
-An I2C bus number.
-
-.br
-
-.br
-
-.IP "\fBi2c_flags\fP: 0" 0
-Flags which modify an I2C open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fBi2c_reg\fP: 0-255" 0
-A register of an I2C device.
-
-.br
-
-.br
-
-.IP "\fB*inBuf\fP" 0
-A buffer used to pass data to a function.
-
-.br
-
-.br
-
-.IP "\fBinLen\fP" 0
-The number of bytes of data in a buffer.
-
-.br
-
-.br
-
-.IP "\fBint\fP" 0
-A whole number, negative or positive.
-
-.br
-
-.br
-
-.IP "\fBint32_t\fP" 0
-A 32-bit signed value.
-
-.br
-
-.br
-
-.IP "\fBinvert\fP" 0
-A flag used to set normal or inverted bit bang serial data level logic.
-
-.br
-
-.br
-
-.IP "\fBlevel\fP" 0
-The level of a GPIO. Low or High.
-
-.br
-
-.br
-
-.EX
-PI_OFF 0
-.br
-PI_ON 1
-.br
-
-.br
-PI_CLEAR 0
-.br
-PI_SET 1
-.br
-
-.br
-PI_LOW 0
-.br
-PI_HIGH 1
-.br
-
-.EE
-
-.br
-
-.br
-There is one exception. If a watchdog expires on a GPIO the level will be
-reported as PI_TIMEOUT. See \fBset_watchdog\fP.
-
-.br
-
-.br
-
-.EX
-PI_TIMEOUT 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBMISO\fP" 0
-The GPIO used for the MISO signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fBmode\fP" 0
-1. The operational mode of a GPIO, normally INPUT or OUTPUT.
-
-.br
-
-.br
-
-.EX
-PI_INPUT 0
-.br
-PI_OUTPUT 1
-.br
-PI_ALT0 4
-.br
-PI_ALT1 5
-.br
-PI_ALT2 6
-.br
-PI_ALT3 7
-.br
-PI_ALT4 3
-.br
-PI_ALT5 2
-.br
-
-.EE
-
-.br
-
-.br
-2. The mode of waveform transmission.
-
-.br
-
-.br
-
-.EX
-PI_WAVE_MODE_ONE_SHOT 0
-.br
-PI_WAVE_MODE_REPEAT 1
-.br
-PI_WAVE_MODE_ONE_SHOT_SYNC 2
-.br
-PI_WAVE_MODE_REPEAT_SYNC 3
-.br
-
-.EE
-
-.br
-
-.br
-3. A file open mode.
-
-.br
-
-.br
-
-.EX
-PI_FILE_READ 1
-.br
-PI_FILE_WRITE 2
-.br
-PI_FILE_RW 3
-.br
-
-.EE
-
-.br
-
-.br
-The following values can be or'd into the mode.
-
-.br
-
-.br
-
-.EX
-PI_FILE_APPEND 4
-.br
-PI_FILE_CREATE 8
-.br
-PI_FILE_TRUNC 16
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBMOSI\fP" 0
-The GPIO used for the MOSI signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fBnumBytes\fP" 0
-The number of bytes used to store characters in a string. Depending
-on the number of bits per character there may be 1, 2, or 4 bytes
-per character.
-
-.br
-
-.br
-
-.IP "\fBnumPar\fP: 0-10" 0
-The number of parameters passed to a script.
-
-.br
-
-.br
-
-.IP "\fBnumPulses\fP" 0
-The number of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBoffset\fP" 0
-The associated data starts this number of microseconds from the start of
-the waveform.
-
-.br
-
-.br
-
-.IP "\fB*outBuf\fP" 0
-A buffer used to return data from a function.
-
-.br
-
-.br
-
-.IP "\fBoutLen\fP" 0
-The size in bytes of an output buffer.
-
-.br
-
-.br
-
-.IP "\fBpad\fP: 0-2" 0
-A set of GPIO which share common drivers.
-
-.br
-
-.br
-Pad GPIO
-.br
-0 0-27
-.br
-1 28-45
-.br
-2 46-53
-.br
-
-.br
-
-.br
-
-.IP "\fBpadStrength\fP: 1-16" 0
-The mA which may be drawn from each GPIO whilst still guaranteeing the
-high and low levels.
-
-.br
-
-.br
-
-.IP "\fB*param\fP" 0
-An array of script parameters.
-
-.br
-
-.br
-
-.IP "\fBpi\fP" 0
-An integer defining a connected Pi. The value is returned by
-\fBpigpio_start\fP upon success.
-
-.br
-
-.br
-
-.IP "\fB*portStr\fP" 0
-A string specifying the port address used by the Pi running
-the pigpio daemon. It may be NULL in which case "8888"
-is used unless overridden by the PIGPIO_PORT environment
-variable.
-
-.br
-
-.br
-
-.IP "\fB*pth\fP" 0
-A thread identifier, returned by \fBstart_thread\fP.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fBpthread_t\fP" 0
-A thread identifier.
-
-.br
-
-.br
-
-.IP "\fBpud\fP: 0-2" 0
-The setting of the pull up/down resistor for a GPIO, which may be off,
-pull-up, or pull-down.
-
-.EX
-PI_PUD_OFF 0
-.br
-PI_PUD_DOWN 1
-.br
-PI_PUD_UP 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBpulseLen\fP" 0
-1-100, the length of a trigger pulse in microseconds.
-
-.br
-
-.br
-
-.IP "\fB*pulses\fP" 0
-An array of pulses to be added to a waveform.
-
-.br
-
-.br
-
-.IP "\fBpulsewidth\fP: 0, 500-2500" 0
-
-.EX
-PI_SERVO_OFF 0
-.br
-PI_MIN_SERVO_PULSEWIDTH 500
-.br
-PI_MAX_SERVO_PULSEWIDTH 2500
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMduty\fP: 0-1000000 (1M)" 0
-The hardware PWM dutycycle.
-
-.br
-
-.br
-
-.EX
-#define PI_HW_PWM_RANGE 1000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBPWMfreq\fP: 1-125000000 (125M)" 0
-The hardware PWM frequency.
-
-.br
-
-.br
-
-.EX
-#define PI_HW_PWM_MIN_FREQ 1
-.br
-#define PI_HW_PWM_MAX_FREQ 125000000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBrange\fP: 25-40000" 0
-The permissible dutycycle values are 0-range.
-
-.EX
-PI_MIN_DUTYCYCLE_RANGE 25
-.br
-PI_MAX_DUTYCYCLE_RANGE 40000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*retBuf\fP" 0
-A buffer to hold a number of bytes returned to a used customised function,
-
-.br
-
-.br
-
-.IP "\fBretMax\fP" 0
-The maximum number of bytes a user customised function should return.
-
-.br
-
-.br
-
-.br
-
-.br
-
-.IP "\fB*rxBuf\fP" 0
-A pointer to a buffer to receive data.
-
-.br
-
-.br
-
-.IP "\fBSCL\fP" 0
-The user GPIO to use for the clock when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fBSCLK\fP" 0
-The GPIO used for the SCLK signal when bit banging SPI.
-
-.br
-
-.br
-
-.IP "\fB*script\fP" 0
-A pointer to the text of a script.
-
-.br
-
-.br
-
-.IP "\fBscript_id\fP" 0
-An id of a stored script as returned by \fBstore_script\fP.
-
-.br
-
-.br
-
-.IP "\fB*scriptName\fP" 0
-The name of a \fBshell_\fP script to be executed. The script must be present in
-/opt/pigpio/cgi and must have execute permission.
-
-.br
-
-.br
-
-.IP "\fB*scriptString\fP" 0
-The string to be passed to a \fBshell_\fP script to be executed.
-
-.br
-
-.br
-
-.IP "\fBSDA\fP" 0
-The user GPIO to use for data when bit banging I2C.
-
-.br
-
-.br
-
-.IP "\fBseconds\fP" 0
-The number of seconds.
-
-.br
-
-.br
-
-.IP "\fBseekFrom\fP" 0
-
-.br
-
-.br
-
-.EX
-PI_FROM_START 0
-.br
-PI_FROM_CURRENT 1
-.br
-PI_FROM_END 2
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fBseekOffset\fP" 0
-The number of bytes to move forward (positive) or backwards (negative)
-from the seek position (start, current, or end of file).
-
-.br
-
-.br
-
-.IP "\fBser_flags\fP" 0
-Flags which modify a serial open command. None are currently defined.
-
-.br
-
-.br
-
-.IP "\fB*ser_tty\fP" 0
-The name of a serial tty device, e.g. /dev/ttyAMA0, /dev/ttyUSB0, /dev/tty1.
-
-.br
-
-.br
-
-.IP "\fBsize_t\fP" 0
-A standard type used to indicate the size of an object in bytes.
-
-.br
-
-.br
-
-.IP "\fBspi_channel\fP" 0
-A SPI channel, 0-2.
-
-.br
-
-.br
-
-.IP "\fBspi_flags\fP" 0
-See \fBspi_open\fP and \fBbb_spi_open\fP.
-
-.br
-
-.br
-
-.IP "\fBsteady\fP: 0-300000" 0
-
-.br
-
-.br
-The number of microseconds level changes must be stable for
-before reporting the level changed (\fBset_glitch_filter\fP) or triggering
-the active part of a noise filter (\fBset_noise_filter\fP).
-
-.br
-
-.br
-
-.IP "\fBstop_bits\fP: 2-8" 0
-The number of (half) stop bits to be used when adding serial data
-to a waveform.
-
-.br
-
-.br
-
-.EX
-#define PI_MIN_WAVE_HALFSTOPBITS 2
-.br
-#define PI_MAX_WAVE_HALFSTOPBITS 8
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*str\fP" 0
- An array of characters.
-
-.br
-
-.br
-
-.IP "\fBthread_func\fP" 0
-A function of type gpioThreadFunc_t used as the main function of a
-thread.
-
-.br
-
-.br
-
-.IP "\fBtimeout\fP" 0
-A GPIO watchdog timeout in milliseconds.
-
-.EX
-PI_MIN_WDOG_TIMEOUT 0
-.br
-PI_MAX_WDOG_TIMEOUT 60000
-.br
-
-.EE
-
-.br
-
-.br
-
-.IP "\fB*txBuf\fP" 0
-An array of bytes to transmit.
-
-.br
-
-.br
-
-.IP "\fBuint32_t\fP: 0-0-4,294,967,295 (Hex 0x0-0xFFFFFFFF)" 0
-A 32-bit unsigned value.
-
-.br
-
-.br
-
-.IP "\fBunsigned\fP" 0
-A whole number >= 0.
-
-.br
-
-.br
-
-.IP "\fBuser_gpio\fP" 0
-0-31, a Broadcom numbered GPIO.
-
-.br
-
-.br
-See \fBgpio\fP.
-
-.br
-
-.br
-
-.IP "\fB*userdata\fP" 0
-
-.br
-
-.br
-A pointer to arbitrary user data. This may be used to identify the instance.
-
-.br
-
-.br
-You must ensure that the pointer is in scope at the time it is processed. If
-it is a pointer to a global this is automatic. Do not pass the address of a
-local variable. If you want to pass a transient object then use the
-following technique.
-
-.br
-
-.br
-In the calling function:
-
-.br
-
-.br
-user_type *userdata;
-.br
-user_type my_userdata;
-
-.br
-
-.br
-userdata = malloc(sizeof(user_type));
-.br
-*userdata = my_userdata;
-
-.br
-
-.br
-In the receiving function:
-
-.br
-
-.br
-user_type my_userdata = *(user_type*)userdata;
-
-.br
-
-.br
-free(userdata);
-
-.br
-
-.br
-
-.IP "\fBvoid\fP" 0
-Denoting no parameter is required
-
-.br
-
-.br
-
-.IP "\fBwave_add_*\fP" 0
-One of \fBwave_add_new\fP, \fBwave_add_generic\fP, \fBwave_add_serial\fP.
-
-.br
-
-.br
-
-.IP "\fBwave_id\fP" 0
-A number representing a waveform created by \fBwave_create\fP.
-
-.br
-
-.br
-
-.IP "\fBwave_send_*\fP" 0
-One of \fBwave_send_once\fP, \fBwave_send_repeat\fP.
-
-.br
-
-.br
-
-.IP "\fBwVal\fP: 0-65535 (Hex 0x0-0xFFFF, Octal 0-0177777)" 0
-A 16-bit word value.
-
-.br
-
-.br
-.SH pigpiod_if2 Error Codes
-
-.EX
-
-.br
-typedef enum
-.br
-{
-.br
- pigif_bad_send = -2000,
-.br
- pigif_bad_recv = -2001,
-.br
- pigif_bad_getaddrinfo = -2002,
-.br
- pigif_bad_connect = -2003,
-.br
- pigif_bad_socket = -2004,
-.br
- pigif_bad_noib = -2005,
-.br
- pigif_duplicate_callback = -2006,
-.br
- pigif_bad_malloc = -2007,
-.br
- pigif_bad_callback = -2008,
-.br
- pigif_notify_failed = -2009,
-.br
- pigif_callback_not_found = -2010,
-.br
- pigif_unconnected_pi = -2011,
-.br
- pigif_too_many_pis = -2012,
-.br
-} pigifError_t;
-.br
-
-.br
-
-.EE
-
-.SH SEE ALSO
-
-pigpiod(1), pig2vcd(1), pigs(1), pigpio(3), pigpiod_if(3)
-.SH AUTHOR
-
-joan@abyz.co.uk
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.c b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.c
deleted file mode 100644
index 842fb4be2..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.c
+++ /dev/null
@@ -1,1877 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-/* PIGPIOD_IF2_VERSION 8 */
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-
-#include "pigpio.h"
-#include "command.h"
-
-#include "pigpiod_if2.h"
-
-#define PI_MAX_REPORTS_PER_READ 4096
-
-#define STACK_SIZE (256*1024)
-
-#define MAX_PI 32
-
-typedef void (*CBF_t) ();
-
-struct callback_s
-{
-
- int id;
- int pi;
- int gpio;
- int edge;
- CBF_t f;
- void * user;
- int ex;
- callback_t *prev;
- callback_t *next;
-};
-
-/* GLOBALS ---------------------------------------------------------------- */
-
-static int gPiInUse [MAX_PI];
-
-static int gPigCommand [MAX_PI];
-static int gPigHandle [MAX_PI];
-static int gPigNotify [MAX_PI];
-
-static uint32_t gNotifyBits [MAX_PI];
-static uint32_t gLastLevel [MAX_PI];
-
-static pthread_t *gPthNotify [MAX_PI];
-
-static pthread_mutex_t gCmdMutex [MAX_PI];
-static int gCancelState [MAX_PI];
-
-static callback_t *gCallBackFirst = 0;
-static callback_t *gCallBackLast = 0;
-
-/* PRIVATE ---------------------------------------------------------------- */
-
-static void _pml(int pi)
-{
- int cancelState;
-
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancelState);
- pthread_mutex_lock(&gCmdMutex[pi]);
- gCancelState[pi] = cancelState;
-}
-
-static void _pmu(int pi)
-{
- int cancelState;
-
- cancelState = gCancelState[pi];
- pthread_mutex_unlock(&gCmdMutex[pi]);
- pthread_setcancelstate(cancelState, NULL);
-}
-
-static int pigpio_command(int pi, int command, int p1, int p2, int rl)
-{
- cmdCmd_t cmd;
-
- if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi])
- return pigif_unconnected_pi;
-
- cmd.cmd = command;
- cmd.p1 = p1;
- cmd.p2 = p2;
- cmd.res = 0;
-
- _pml(pi);
-
- if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd))
- {
- _pmu(pi);
- return pigif_bad_send;
- }
-
- if (recv(gPigCommand[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd))
- {
- _pmu(pi);
- return pigif_bad_recv;
- }
-
- if (rl) _pmu(pi);
-
- return cmd.res;
-}
-
-static int pigpio_notify(int pi)
-{
- cmdCmd_t cmd;
-
- if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi])
- return pigif_unconnected_pi;
-
- cmd.cmd = PI_CMD_NOIB;
- cmd.p1 = 0;
- cmd.p2 = 0;
- cmd.res = 0;
-
- _pml(pi);
-
- if (send(gPigNotify[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd))
- {
- _pmu(pi);
- return pigif_bad_send;
- }
-
- if (recv(gPigNotify[pi], &cmd, sizeof(cmd), MSG_WAITALL) != sizeof(cmd))
- {
- _pmu(pi);
- return pigif_bad_recv;
- }
-
- _pmu(pi);
-
- return cmd.res;
-}
-
-static int pigpio_command_ext
- (int pi, int command, int p1, int p2, int p3,
- int extents, gpioExtent_t *ext, int rl)
-{
- int i;
- cmdCmd_t cmd;
-
- if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi])
- return pigif_unconnected_pi;
-
- cmd.cmd = command;
- cmd.p1 = p1;
- cmd.p2 = p2;
- cmd.p3 = p3;
-
- _pml(pi);
-
- if (send(gPigCommand[pi], &cmd, sizeof(cmd), 0) != sizeof(cmd))
- {
- _pmu(pi);
- return pigif_bad_send;
- }
-
- for (i=0; iai_next)
- {
- sock = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
-
- if (sock == -1) continue;
-
- /* Disable the Nagle algorithm. */
- opt = 1;
- setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char*)&opt, sizeof(int));
-
- if (connect(sock, rp->ai_addr, rp->ai_addrlen) != -1) break;
- }
-
- freeaddrinfo(res);
-
- if (rp == NULL) return pigif_bad_connect;
-
- return sock;
-}
-
-static void dispatch_notification(int pi, gpioReport_t *r)
-{
- callback_t *p;
- uint32_t changed;
- int l, g;
-
-/*
- printf("s=%4x f=%4x t=%10u l=%8x\n",
- r->seqno, r->flags, r->tick, r->level);
-*/
-
- if (r->flags == 0)
- {
- changed = (r->level ^ gLastLevel[pi]) & gNotifyBits[pi];
-
- gLastLevel[pi] = r->level;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (((p->pi) == pi) && (changed & (1<<(p->gpio))))
- {
- if ((r->level) & (1<<(p->gpio))) l = 1; else l = 0;
- if ((p->edge) ^ l)
- {
- if (p->ex) (p->f)(pi, p->gpio, l, r->tick, p->user);
- else (p->f)(pi, p->gpio, l, r->tick);
- }
- }
- p = p->next;
- }
- }
- else
- {
- g = (r->flags) & 31;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (((p->pi) == pi) && ((p->gpio) == g))
- {
- if (p->ex) (p->f)(pi, g, PI_TIMEOUT, r->tick, p->user);
- else (p->f)(pi, g, PI_TIMEOUT, r->tick);
- }
- p = p->next;
- }
- }
-}
-
-static void *pthNotifyThread(void *x)
-{
- static int got = 0;
- int pi;
- int bytes, r;
- gpioReport_t report[PI_MAX_REPORTS_PER_READ];
-
- pi = *((int*)x);
- free(x); /* memory allocated in pigpio_start */
-
- while (1)
- {
- bytes = read(gPigNotify[pi], (char*)&report+got, sizeof(report)-got);
-
- if (bytes > 0) got += bytes;
- else break;
-
- r = 0;
-
- while (got >= sizeof(gpioReport_t))
- {
- dispatch_notification(pi, &report[r]);
-
- r++;
-
- got -= sizeof(gpioReport_t);
- }
-
- /* copy any partial report to start of array */
-
- if (got && r) report[0] = report[r];
- }
-
- fprintf(stderr, "notify thread for pi %d broke with read error %d\n",
- pi, bytes);
-
- while (1) sleep(1);
-
- return NULL;
-}
-
-static void findNotifyBits(int pi)
-{
- callback_t *p;
- uint32_t bits = 0;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (p->pi == pi) bits |= (1<<(p->gpio));
- p = p->next;
- }
-
- if (bits != gNotifyBits[pi])
- {
- gNotifyBits[pi] = bits;
- pigpio_command(pi, PI_CMD_NB, gPigHandle[pi], gNotifyBits[pi], 1);
- }
-}
-
-static void _wfe(
- int pi, unsigned user_gpio, unsigned level, uint32_t tick, void *user)
-{
- *(int *)user = 1;
-}
-
-static int intCallback(
- int pi, unsigned user_gpio, unsigned edge, void *f, void *user, int ex)
-{
- static int id = 0;
- callback_t *p;
-
- if ((user_gpio >=0) && (user_gpio < 32) && (edge >=0) && (edge <= 2) && f)
- {
- /* prevent duplicates */
-
- p = gCallBackFirst;
-
- while (p)
- {
- if ((p->pi == pi) &&
- (p->gpio == user_gpio) &&
- (p->edge == edge) &&
- (p->f == f))
- {
- return pigif_duplicate_callback;
- }
- p = p->next;
- }
-
- p = malloc(sizeof(callback_t));
-
- if (p)
- {
- if (!gCallBackFirst) gCallBackFirst = p;
-
- p->id = id++;
- p->pi = pi;
- p->gpio = user_gpio;
- p->edge = edge;
- p->f = f;
- p->user = user;
- p->ex = ex;
- p->next = 0;
- p->prev = gCallBackLast;
-
- if (p->prev) (p->prev)->next = p;
- gCallBackLast = p;
-
- findNotifyBits(pi);
-
- return p->id;
- }
-
- return pigif_bad_malloc;
- }
-
- return pigif_bad_callback;
-}
-
-static int recvMax(int pi, void *buf, int bufsize, int sent)
-{
- uint8_t scratch[4096];
- int remaining, fetch, count;
-
- if (sent < bufsize) count = sent; else count = bufsize;
-
- if (count) recv(gPigCommand[pi], buf, count, MSG_WAITALL);
-
- remaining = sent - count;
-
- while (remaining)
- {
- fetch = remaining;
- if (fetch > sizeof(scratch)) fetch = sizeof(scratch);
- recv(gPigCommand[pi], scratch, fetch, MSG_WAITALL);
- remaining -= fetch;
- }
-
- return count;
-}
-
-/* PUBLIC ----------------------------------------------------------------- */
-
-double time_time(void)
-{
- struct timeval tv;
- double t;
-
- gettimeofday(&tv, 0);
-
- t = (double)tv.tv_sec + ((double)tv.tv_usec / 1E6);
-
- return t;
-}
-
-void time_sleep(double seconds)
-{
- struct timespec ts, rem;
-
- if (seconds > 0.0)
- {
- ts.tv_sec = seconds;
- ts.tv_nsec = (seconds-(double)ts.tv_sec) * 1E9;
-
- while (clock_nanosleep(CLOCK_REALTIME, 0, &ts, &rem))
- {
- /* copy remaining time to ts */
- ts.tv_sec = rem.tv_sec;
- ts.tv_nsec = rem.tv_nsec;
- }
- }
-}
-
-char *pigpio_error(int errnum)
-{
- if (errnum > -1000) return cmdErrStr(errnum);
- else
- {
- switch(errnum)
- {
- case pigif_bad_send:
- return "failed to send to pigpiod";
- case pigif_bad_recv:
- return "failed to receive from pigpiod";
- case pigif_bad_getaddrinfo:
- return "failed to find address of pigpiod";
- case pigif_bad_connect:
- return "failed to connect to pigpiod";
- case pigif_bad_socket:
- return "failed to create socket";
- case pigif_bad_noib:
- return "failed to open notification in band";
- case pigif_duplicate_callback:
- return "identical callback exists";
- case pigif_bad_malloc:
- return "failed to malloc";
- case pigif_bad_callback:
- return "bad callback parameter";
- case pigif_notify_failed:
- return "failed to create notification thread";
- case pigif_callback_not_found:
- return "callback not found";
- case pigif_unconnected_pi:
- return "not connected to Pi";
- case pigif_too_many_pis:
- return "too many connected Pis";
-
- default:
- return "unknown error";
- }
- }
-}
-
-unsigned pigpiod_if_version(void)
-{
- return PIGPIOD_IF2_VERSION;
-}
-
-pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata)
-{
- pthread_t *pth;
- pthread_attr_t pthAttr;
-
- pth = malloc(sizeof(pthread_t));
-
- if (pth)
- {
- if (pthread_attr_init(&pthAttr))
- {
- perror("pthread_attr_init failed");
- free(pth);
- return NULL;
- }
-
- if (pthread_attr_setstacksize(&pthAttr, STACK_SIZE))
- {
- perror("pthread_attr_setstacksize failed");
- free(pth);
- return NULL;
- }
-
- if (pthread_create(pth, &pthAttr, thread_func, userdata))
- {
- perror("pthread_create socket failed");
- free(pth);
- return NULL;
- }
- }
- return pth;
-}
-
-void stop_thread(pthread_t *pth)
-{
- if (pth)
- {
- pthread_cancel(*pth);
- pthread_join(*pth, NULL);
- free(pth);
- }
-}
-
-int pigpio_start(char *addrStr, char *portStr)
-{
- int pi;
- int *userdata;
-
- for (pi=0; pi= MAX_PI) return pigif_too_many_pis;
-
- gPiInUse[pi] = 1;
-
- pthread_mutex_init(&gCmdMutex[pi], NULL);
-
- gPigCommand[pi] = pigpioOpenSocket(addrStr, portStr);
-
- if (gPigCommand[pi] >= 0)
- {
- gPigNotify[pi] = pigpioOpenSocket(addrStr, portStr);
-
- if (gPigNotify[pi] >= 0)
- {
- gPigHandle[pi] = pigpio_notify(pi);
-
- if (gPigHandle[pi] < 0) return pigif_bad_noib;
- else
- {
- gLastLevel[pi] = read_bank_1(pi);
-
- /* must be freed by pthNotifyThread */
- userdata = malloc(sizeof(*userdata));
- *userdata = pi;
-
- gPthNotify[pi] = start_thread(pthNotifyThread, userdata);
-
- if (gPthNotify[pi]) return pi;
- else return pigif_notify_failed;
-
- }
- }
- else return gPigNotify[pi];
- }
- else return gPigCommand[pi];
-}
-
-void pigpio_stop(int pi)
-{
- if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi]) return;
-
- if (gPthNotify[pi])
- {
- stop_thread(gPthNotify[pi]);
- gPthNotify[pi] = 0;
- }
-
- if (gPigCommand[pi] >= 0)
- {
- if (gPigHandle[pi] >= 0)
- {
- pigpio_command(pi, PI_CMD_NC, gPigHandle[pi], 0, 1);
- gPigHandle[pi] = -1;
- }
-
- close(gPigCommand[pi]);
- gPigCommand[pi] = -1;
- }
-
- if (gPigNotify[pi] >= 0)
- {
- close(gPigNotify[pi]);
- gPigNotify[pi] = -1;
- }
-
- gPiInUse[pi] = 0;
-}
-
-int set_mode(int pi, unsigned gpio, unsigned mode)
- {return pigpio_command(pi, PI_CMD_MODES, gpio, mode, 1);}
-
-int get_mode(int pi, unsigned gpio)
- {return pigpio_command(pi, PI_CMD_MODEG, gpio, 0, 1);}
-
-int set_pull_up_down(int pi, unsigned gpio, unsigned pud)
- {return pigpio_command(pi, PI_CMD_PUD, gpio, pud, 1);}
-
-int gpio_read(int pi, unsigned gpio)
- {return pigpio_command(pi, PI_CMD_READ, gpio, 0, 1);}
-
-int gpio_write(int pi, unsigned gpio, unsigned level)
- {return pigpio_command(pi, PI_CMD_WRITE, gpio, level, 1);}
-
-int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle)
- {return pigpio_command(pi, PI_CMD_PWM, user_gpio, dutycycle, 1);}
-
-int get_PWM_dutycycle(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_GDC, user_gpio, 0, 1);}
-
-int set_PWM_range(int pi, unsigned user_gpio, unsigned range)
- {return pigpio_command(pi, PI_CMD_PRS, user_gpio, range, 1);}
-
-int get_PWM_range(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_PRG, user_gpio, 0, 1);}
-
-int get_PWM_real_range(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_PRRG, user_gpio, 0, 1);}
-
-int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency)
- {return pigpio_command(pi, PI_CMD_PFS, user_gpio, frequency, 1);}
-
-int get_PWM_frequency(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_PFG, user_gpio, 0, 1);}
-
-int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth)
- {return pigpio_command(pi, PI_CMD_SERVO, user_gpio, pulsewidth, 1);}
-
-int get_servo_pulsewidth(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_GPW, user_gpio, 0, 1);}
-
-int notify_open(int pi)
- {return pigpio_command(pi, PI_CMD_NO, 0, 0, 1);}
-
-int notify_begin(int pi, unsigned handle, uint32_t bits)
- {return pigpio_command(pi, PI_CMD_NB, handle, bits, 1);}
-
-int notify_pause(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_NB, handle, 0, 1);}
-
-int notify_close(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_NC, handle, 0, 1);}
-
-int set_watchdog(int pi, unsigned user_gpio, unsigned timeout)
- {return pigpio_command(pi, PI_CMD_WDOG, user_gpio, timeout, 1);}
-
-uint32_t read_bank_1(int pi)
- {return pigpio_command(pi, PI_CMD_BR1, 0, 0, 1);}
-
-uint32_t read_bank_2(int pi)
- {return pigpio_command(pi, PI_CMD_BR2, 0, 0, 1);}
-
-int clear_bank_1(int pi, uint32_t levels)
- {return pigpio_command(pi, PI_CMD_BC1, levels, 0, 1);}
-
-int clear_bank_2(int pi, uint32_t levels)
- {return pigpio_command(pi, PI_CMD_BC2, levels, 0, 1);}
-
-int set_bank_1(int pi, uint32_t levels)
- {return pigpio_command(pi, PI_CMD_BS1, levels, 0, 1);}
-
-int set_bank_2(int pi, uint32_t levels)
- {return pigpio_command(pi, PI_CMD_BS2, levels, 0, 1);}
-
-int hardware_clock(int pi, unsigned gpio, unsigned frequency)
- {return pigpio_command(pi, PI_CMD_HC, gpio, frequency, 1);}
-
-int hardware_PWM(int pi, unsigned gpio, unsigned frequency, uint32_t dutycycle)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=gpio
- p2=frequency
- p3=4
- ## extension ##
- uint32_t dutycycle
- */
-
- ext[0].size = sizeof(dutycycle);
- ext[0].ptr = &dutycycle;
-
- return pigpio_command_ext(
- pi, PI_CMD_HP, gpio, frequency, sizeof(dutycycle), 1, ext, 1);
-}
-
-uint32_t get_current_tick(int pi)
- {return pigpio_command(pi, PI_CMD_TICK, 0, 0, 1);}
-
-uint32_t get_hardware_revision(int pi)
- {return pigpio_command(pi, PI_CMD_HWVER, 0, 0, 1);}
-
-uint32_t get_pigpio_version(int pi)
- {return pigpio_command(pi, PI_CMD_PIGPV, 0, 0, 1);}
-
-int wave_clear(int pi)
- {return pigpio_command(pi, PI_CMD_WVCLR, 0, 0, 1);}
-
-int wave_add_new(int pi)
- {return pigpio_command(pi, PI_CMD_WVNEW, 0, 0, 1);}
-
-int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=pulses*sizeof(gpioPulse_t)
- ## extension ##
- gpioPulse_t[] pulses
- */
-
- if (!numPulses) return 0;
-
- ext[0].size = numPulses * sizeof(gpioPulse_t);
- ext[0].ptr = pulses;
-
- return pigpio_command_ext(
- pi, PI_CMD_WVAG, 0, 0, ext[0].size, 1, ext, 1);
-}
-
-int wave_add_serial(
- int pi, unsigned user_gpio, unsigned baud, uint32_t databits,
- uint32_t stophalfbits, uint32_t offset, unsigned numChar, char *str)
-{
- uint8_t buf[12];
- gpioExtent_t ext[2];
-
- /*
- p1=user_gpio
- p2=baud
- p3=len+12
- ## extension ##
- uint32_t databits
- uint32_t stophalfbits
- uint32_t offset
- char[len] str
- */
-
- if (!numChar) return 0;
-
- memcpy(buf, &databits, 4);
- memcpy(buf+4, &stophalfbits, 4);
- memcpy(buf+8, &offset, 4);
-
- ext[0].size = sizeof(buf);
- ext[0].ptr = buf;
-
- ext[1].size = numChar;
- ext[1].ptr = str;
-
- return pigpio_command_ext(pi, PI_CMD_WVAS,
- user_gpio, baud, numChar+sizeof(buf), 2, ext, 1);
-}
-
-int wave_create(int pi)
- {return pigpio_command(pi, PI_CMD_WVCRE, 0, 0, 1);}
-
-int wave_delete(int pi, unsigned wave_id)
- {return pigpio_command(pi, PI_CMD_WVDEL, wave_id, 0, 1);}
-
-int wave_tx_start(int pi) /* DEPRECATED */
- {return pigpio_command(pi, PI_CMD_WVGO, 0, 0, 1);}
-
-int wave_tx_repeat(int pi) /* DEPRECATED */
- {return pigpio_command(pi, PI_CMD_WVGOR, 0, 0, 1);}
-
-int wave_send_once(int pi, unsigned wave_id)
- {return pigpio_command(pi, PI_CMD_WVTX, wave_id, 0, 1);}
-
-int wave_send_repeat(int pi, unsigned wave_id)
- {return pigpio_command(pi, PI_CMD_WVTXR, wave_id, 0, 1);}
-
-int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode)
- {return pigpio_command(pi, PI_CMD_WVTXM, wave_id, mode, 1);}
-
-int wave_chain(int pi, char *buf, unsigned bufSize)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=bufSize
- ## extension ##
- char buf[bufSize]
- */
-
- ext[0].size = bufSize;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_WVCHA, 0, 0, bufSize, 1, ext, 1);
-}
-
-int wave_tx_at(int pi)
- {return pigpio_command(pi, PI_CMD_WVTAT, 0, 0, 1);}
-
-int wave_tx_busy(int pi)
- {return pigpio_command(pi, PI_CMD_WVBSY, 0, 0, 1);}
-
-int wave_tx_stop(int pi)
- {return pigpio_command(pi, PI_CMD_WVHLT, 0, 0, 1);}
-
-int wave_get_micros(int pi)
- {return pigpio_command(pi, PI_CMD_WVSM, 0, 0, 1);}
-
-int wave_get_high_micros(int pi)
- {return pigpio_command(pi, PI_CMD_WVSM, 1, 0, 1);}
-
-int wave_get_max_micros(int pi)
- {return pigpio_command(pi, PI_CMD_WVSM, 2, 0, 1);}
-
-int wave_get_pulses(int pi)
- {return pigpio_command(pi, PI_CMD_WVSP, 0, 0, 1);}
-
-int wave_get_high_pulses(int pi)
- {return pigpio_command(pi, PI_CMD_WVSP, 1, 0, 1);}
-
-int wave_get_max_pulses(int pi)
- {return pigpio_command(pi, PI_CMD_WVSP, 2, 0, 1);}
-
-int wave_get_cbs(int pi)
- {return pigpio_command(pi, PI_CMD_WVSC, 0, 0, 1);}
-
-int wave_get_high_cbs(int pi)
- {return pigpio_command(pi, PI_CMD_WVSC, 1, 0, 1);}
-
-int wave_get_max_cbs(int pi)
- {return pigpio_command(pi, PI_CMD_WVSC, 2, 0, 1);}
-
-int gpio_trigger(int pi, unsigned user_gpio, unsigned pulseLen, uint32_t level)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=pulseLen
- p3=4
- ## extension ##
- unsigned level
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &level;
-
- return pigpio_command_ext(
- pi, PI_CMD_TRIG, user_gpio, pulseLen, 4, 1, ext, 1);
-}
-
-int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady)
- {return pigpio_command(pi, PI_CMD_FG, user_gpio, steady, 1);}
-
-int set_noise_filter(int pi, unsigned user_gpio, unsigned steady, unsigned active)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=steady
- p3=4
- ## extension ##
- unsigned active
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &active;
-
- return pigpio_command_ext(
- pi, PI_CMD_FN, user_gpio, steady, 4, 1, ext, 1);
-}
-
-int store_script(int pi, char *script)
-{
- unsigned len;
- gpioExtent_t ext[1];
-
- /*
- p1=0
- p2=0
- p3=len
- ## extension ##
- char[len] script
- */
-
- len = strlen(script);
-
- if (!len) return 0;
-
- ext[0].size = len;
- ext[0].ptr = script;
-
- return pigpio_command_ext(pi, PI_CMD_PROC, 0, 0, len, 1, ext, 1);
-}
-
-int run_script(int pi, unsigned script_id, unsigned numPar, uint32_t *param)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=script id
- p2=0
- p3=numPar * 4
- ## extension ##
- uint32_t[numPar] pars
- */
-
- ext[0].size = 4 * numPar;
- ext[0].ptr = param;
-
- return pigpio_command_ext
- (pi, PI_CMD_PROCR, script_id, 0, numPar*4, 1, ext, 1);
-}
-
-int script_status(int pi, unsigned script_id, uint32_t *param)
-{
- int status;
- uint32_t p[PI_MAX_SCRIPT_PARAMS+1]; /* space for script status */
-
- status = pigpio_command(pi, PI_CMD_PROCP, script_id, 0, 0);
-
- if (status > 0)
- {
- recvMax(pi, p, sizeof(p), status);
- status = p[0];
- if (param) memcpy(param, p+1, sizeof(p)-4);
- }
-
- _pmu(pi);
-
- return status;
-}
-
-int stop_script(int pi, unsigned script_id)
- {return pigpio_command(pi, PI_CMD_PROCS, script_id, 0, 1);}
-
-int delete_script(int pi, unsigned script_id)
- {return pigpio_command(pi, PI_CMD_PROCD, script_id, 0, 1);}
-
-int bb_serial_read_open(int pi, unsigned user_gpio, unsigned baud, uint32_t bbBits)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=user_gpio
- p2=baud
- p3=4
- ## extension ##
- unsigned bbBits
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &bbBits;
-
- return pigpio_command_ext(
- pi, PI_CMD_SLRO, user_gpio, baud, 4, 1, ext, 1);
-}
-
-int bb_serial_read(int pi, unsigned user_gpio, void *buf, size_t bufSize)
-{
- int bytes;
-
- bytes = pigpio_command(pi, PI_CMD_SLR, user_gpio, bufSize, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, bufSize, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int bb_serial_read_close(int pi, unsigned user_gpio)
- {return pigpio_command(pi, PI_CMD_SLRC, user_gpio, 0, 1);}
-
-int bb_serial_invert(int pi, unsigned user_gpio, unsigned invert)
- {return pigpio_command(pi, PI_CMD_SLRI, user_gpio, invert, 1);}
-
-int i2c_open(int pi, unsigned i2c_bus, unsigned i2c_addr, uint32_t i2c_flags)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=i2c_bus
- p2=i2c_addr
- p3=4
- ## extension ##
- uint32_t i2c_flags
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &i2c_flags;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CO, i2c_bus, i2c_addr, 4, 1, ext, 1);
-}
-
-int i2c_close(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_I2CC, handle, 0, 1);}
-
-int i2c_write_quick(int pi, unsigned handle, unsigned bit)
- {return pigpio_command(pi, PI_CMD_I2CWQ, handle, bit, 1);}
-
-int i2c_write_byte(int pi, unsigned handle, unsigned val)
- {return pigpio_command(pi, PI_CMD_I2CWS, handle, val, 1);}
-
-int i2c_read_byte(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_I2CRS, handle, 0, 1);}
-
-int i2c_write_byte_data(int pi, unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CWB, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_write_word_data(int pi, unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CWW, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_read_byte_data(int pi, unsigned handle, unsigned reg)
- {return pigpio_command(pi, PI_CMD_I2CRB, handle, reg, 1);}
-
-int i2c_read_word_data(int pi, unsigned handle, unsigned reg)
- {return pigpio_command(pi, PI_CMD_I2CRW, handle, reg, 1);}
-
-int i2c_process_call(int pi, unsigned handle, unsigned reg, uint32_t val)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t val
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &val;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CPK, handle, reg, 4, 1, ext, 1);
-}
-
-int i2c_write_block_data(
- int pi, unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CWK, handle, reg, count, 1, ext, 1);
-}
-
-int i2c_read_block_data(int pi, unsigned handle, unsigned reg, char *buf)
-{
- int bytes;
-
- bytes = pigpio_command(pi, PI_CMD_I2CRK, handle, reg, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, 32, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int i2c_block_process_call(
- int pi, unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_I2CPK, handle, reg, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, 32, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int i2c_read_i2c_block_data(
- int pi, unsigned handle, unsigned reg, char *buf, uint32_t count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=4
- ## extension ##
- uint32_t count
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &count;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_I2CRI, handle, reg, 4, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-
-int i2c_write_i2c_block_data(
- int pi, unsigned handle, unsigned reg, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=reg
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CWI, handle, reg, count, 1, ext, 1);
-}
-
-int i2c_read_device(int pi, unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command(pi, PI_CMD_I2CRD, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int i2c_write_device(int pi, unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_I2CWD, handle, 0, count, 1, ext, 1);
-}
-
-int i2c_zip(
- int pi,
- unsigned handle,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=inLen
- ## extension ##
- char inBuf[inLen]
- */
-
- ext[0].size = inLen;
- ext[0].ptr = inBuf;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_I2CZ, handle, 0, inLen, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, outBuf, outLen, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int bb_i2c_open(int pi, unsigned SDA, unsigned SCL, unsigned baud)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=SDA
- p2=SCL
- p3=4
- ## extension ##
- uint32_t baud
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &baud;
-
- return pigpio_command_ext
- (pi, PI_CMD_BI2CO, SDA, SCL, 4, 1, ext, 1);
-}
-
-int bb_i2c_close(int pi, unsigned SDA)
- {return pigpio_command(pi, PI_CMD_BI2CC, SDA, 0, 1);}
-
-int bb_i2c_zip(
- int pi,
- unsigned SDA,
- char *inBuf,
- unsigned inLen,
- char *outBuf,
- unsigned outLen)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=SDA
- p2=0
- p3=inLen
- ## extension ##
- char inBuf[inLen]
- */
-
- ext[0].size = inLen;
- ext[0].ptr = inBuf;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_BI2CZ, SDA, 0, inLen, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, outBuf, outLen, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int bb_spi_open(
- int pi,
- unsigned CS, unsigned MISO, unsigned MOSI, unsigned SCLK,
- unsigned baud, unsigned spiFlags)
-{
- uint8_t buf[20];
- gpioExtent_t ext[1];
-
- /*
- p1=CS
- p2=0
- p3=20
- ## extension ##
- uint32_t MISO
- uint32_t MOSI
- uint32_t SCLK
- uint32_t baud
- uint32_t spiFlags
- */
-
- ext[0].size = 20;
- ext[0].ptr = &buf;
-
- memcpy(buf + 0, &MISO, 4);
- memcpy(buf + 4, &MOSI, 4);
- memcpy(buf + 8, &SCLK, 4);
- memcpy(buf + 12, &baud, 4);
- memcpy(buf + 16, &spiFlags, 4);
-
- return pigpio_command_ext
- (pi, PI_CMD_BSPIO, CS, 0, 20, 1, ext, 1);
-}
-
-int bb_spi_close(int pi, unsigned CS)
- {return pigpio_command(pi, PI_CMD_BSPIC, CS, 0, 1);}
-
-int bb_spi_xfer(
- int pi,
- unsigned CS,
- char *txBuf,
- char *rxBuf,
- unsigned count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=CS
- p2=0
- p3=count
- ## extension ##
- char txBuf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = txBuf;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_BSPIX, CS, 0, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, rxBuf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int spi_open(int pi, unsigned channel, unsigned speed, uint32_t flags)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=channel
- p2=speed
- p3=4
- ## extension ##
- uint32_t flags
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &flags;
-
- return pigpio_command_ext
- (pi, PI_CMD_SPIO, channel, speed, 4, 1, ext, 1);
-}
-
-int spi_close(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_SPIC, handle, 0, 1);}
-
-int spi_read(int pi, unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command
- (pi, PI_CMD_SPIR, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int spi_write(int pi, unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_SPIW, handle, 0, count, 1, ext, 1);
-}
-
-int spi_xfer(int pi, unsigned handle, char *txBuf, char *rxBuf, unsigned count)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = txBuf;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_SPIX, handle, 0, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, rxBuf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int serial_open(int pi, char *dev, unsigned baud, unsigned flags)
-{
- int len;
- gpioExtent_t ext[1];
-
- len = strlen(dev);
-
- /*
- p1=baud
- p2=flags
- p3=len
- ## extension ##
- char dev[len]
- */
-
- ext[0].size = len;
- ext[0].ptr = dev;
-
- return pigpio_command_ext
- (pi, PI_CMD_SERO, baud, flags, len, 1, ext, 1);
-}
-
-int serial_close(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_SERC, handle, 0, 1);}
-
-int serial_write_byte(int pi, unsigned handle, unsigned val)
- {return pigpio_command(pi, PI_CMD_SERWB, handle, val, 1);}
-
-int serial_read_byte(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_SERRB, handle, 0, 1);}
-
-int serial_write(int pi, unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_SERW, handle, 0, count, 1, ext, 1);
-}
-
-int serial_read(int pi, unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command
- (pi, PI_CMD_SERR, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int serial_data_available(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_SERDA, handle, 0, 1);}
-
-int custom_1(int pi, unsigned arg1, unsigned arg2, char *argx, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=arg1
- p2=arg2
- p3=count
- ## extension ##
- char argx[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = argx;
-
- return pigpio_command_ext(
- pi, PI_CMD_CF1, arg1, arg2, count, 1, ext, 1);
-}
-
-
-int custom_2(int pi, unsigned arg1, char *argx, unsigned count,
- char *retBuf, uint32_t retMax)
-{
- int bytes;
- gpioExtent_t ext[1];
-
- /*
- p1=arg1
- p2=retMax
- p3=count
- ## extension ##
- char argx[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = argx;
-
- bytes = pigpio_command_ext
- (pi, PI_CMD_CF2, arg1, retMax, count, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, retBuf, retMax, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int get_pad_strength(int pi, unsigned pad)
- {return pigpio_command(pi, PI_CMD_PADG, pad, 0, 1);}
-
-int set_pad_strength(int pi, unsigned pad, unsigned padStrength)
- {return pigpio_command(pi, PI_CMD_PADS, pad, padStrength, 1);}
-
-int shell_(int pi, char *scriptName, char *scriptString)
-{
- int ln, ls;
- gpioExtent_t ext[2];
-
- ln = strlen(scriptName);
- ls = strlen(scriptString);
- /*
- p1=len(scriptName)
- p2=0
- p3=len(scriptName) + len(scriptString) + 1
- ## extension ##
- char[]
- */
-
- ext[0].size = ln + 1; /* include null byte */
- ext[0].ptr = scriptName;
-
- ext[1].size = ls;
- ext[1].ptr = scriptString;
-
- return pigpio_command_ext
- (pi, PI_CMD_SHELL, ln, 0, ln+ls+1, 2, ext, 1);
-}
-
-int file_open(int pi, char *file, unsigned mode)
-{
- int len;
- gpioExtent_t ext[1];
-
- len = strlen(file);
-
- /*
- p1=mode
- p2=0
- p3=len
- ## extension ##
- char file[len]
- */
-
- ext[0].size = len;
- ext[0].ptr = file;
-
- return pigpio_command_ext
- (pi, PI_CMD_FO, mode, 0, len, 1, ext, 1);
-}
-
-int file_close(int pi, unsigned handle)
- {return pigpio_command(pi, PI_CMD_FC, handle, 0, 1);}
-
-int file_write(int pi, unsigned handle, char *buf, unsigned count)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=0
- p3=count
- ## extension ##
- char buf[count]
- */
-
- ext[0].size = count;
- ext[0].ptr = buf;
-
- return pigpio_command_ext
- (pi, PI_CMD_FW, handle, 0, count, 1, ext, 1);
-}
-
-int file_read(int pi, unsigned handle, char *buf, unsigned count)
-{
- int bytes;
-
- bytes = pigpio_command
- (pi, PI_CMD_FR, handle, count, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int file_seek(int pi, unsigned handle, int32_t seekOffset, int seekFrom)
-{
- gpioExtent_t ext[1];
-
- /*
- p1=handle
- p2=seekOffset
- p3=4
- ## extension ##
- uint32_t seekFrom
- */
-
- ext[0].size = sizeof(uint32_t);
- ext[0].ptr = &seekFrom;
-
- return pigpio_command_ext
- (pi, PI_CMD_FS, handle, seekOffset, 4, 1, ext, 1);
-}
-
-int file_list(int pi, char *fpat, char *buf, unsigned count)
-{
- int len;
- int bytes;
- gpioExtent_t ext[1];
-
- len = strlen(fpat);
-
- /*
- p1=60000
- p2=0
- p3=len
- ## extension ##
- char fpat[len]
- */
-
- ext[0].size = len;
- ext[0].ptr = fpat;
-
- bytes = pigpio_command_ext(pi, PI_CMD_FL, 60000, 0, len, 1, ext, 0);
-
- if (bytes > 0)
- {
- bytes = recvMax(pi, buf, count, bytes);
- }
-
- _pmu(pi);
-
- return bytes;
-}
-
-int callback(int pi, unsigned user_gpio, unsigned edge, CBFunc_t f)
- {return intCallback(pi, user_gpio, edge, f, 0, 0);}
-
-int callback_ex(
- int pi, unsigned user_gpio, unsigned edge, CBFuncEx_t f, void *user)
- {return intCallback(pi, user_gpio, edge, f, user, 1);}
-
-int callback_cancel(unsigned id)
-{
- callback_t *p;
- int pi;
-
- p = gCallBackFirst;
-
- while (p)
- {
- if (p->id == id)
- {
- pi = p->pi;
-
- if (p->prev) {p->prev->next = p->next;}
- else {gCallBackFirst = p->next;}
-
- if (p->next) {p->next->prev = p->prev;}
- else {gCallBackLast = p->prev;}
-
- free(p);
-
- findNotifyBits(pi);
-
- return 0;
- }
- p = p->next;
- }
- return pigif_callback_not_found;
-}
-
-int wait_for_edge(int pi, unsigned user_gpio, unsigned edge, double timeout)
-{
- int triggered = 0;
- int id;
- double due;
-
- if ((pi < 0) || (pi >= MAX_PI) || !gPiInUse[pi])
- return pigif_unconnected_pi;
-
- if (timeout <= 0.0) return 0;
-
- due = time_time() + timeout;
-
- id = callback_ex(pi, user_gpio, edge, _wfe, &triggered);
-
- while (!triggered && (time_time() < due)) time_sleep(0.05);
-
- callback_cancel(id);
-
- return triggered;
-}
-
diff --git a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.h b/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.h
deleted file mode 100644
index ced2c9add..000000000
--- a/shredder/asterix-pp/asterix-hmi/drivers/Raspberry/PIGPIO/pigpiod_if2.h
+++ /dev/null
@@ -1,3819 +0,0 @@
-/*
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
-*/
-
-#ifndef PIGPIOD_IF2_H
-#define PIGPIOD_IF2_H
-
-#include "pigpio.h"
-
-#define PIGPIOD_IF2_VERSION 9
-
-/*TEXT
-
-pigpiod_if2 is a C library for the Raspberry which allows control
-of the GPIO via the socket interface to the pigpio daemon.
-
-*Features*
-
-o hardware timed PWM on any of GPIO 0-31
-
-o hardware timed servo pulses on any of GPIO 0-31
-
-o callbacks when any of GPIO 0-31 change state
-
-o callbacks at timed intervals
-
-o reading/writing all of the GPIO in a bank as one operation
-
-o individually setting GPIO modes, reading and writing
-
-o notifications when any of GPIO 0-31 change state
-
-o the construction of output waveforms with microsecond timing
-
-o rudimentary permission control over GPIO
-
-o a simple interface to start and stop new threads
-
-o I2C, SPI, and serial link wrappers
-
-o creating and running scripts on the pigpio daemon
-
-*GPIO*
-
-ALL GPIO are identified by their Broadcom number.
-
-*Notes*
-
-The PWM and servo pulses are timed using the DMA and PWM/PCM peripherals.
-
-*Usage*
-
-Include in your source files.
-
-Assuming your source is in prog.c use the following command to build
-
-. .
-gcc -Wall -pthread -o prog prog.c -lpigpiod_if2 -lrt
-. .
-
-to run make sure the pigpio daemon is running
-
-. .
-sudo pigpiod
-
- ./prog # sudo is not required to run programs linked to pigpiod_if2
-. .
-
-For examples see x_pigpiod_if2.c within the pigpio archive file.
-
-*Notes*
-
-All the functions which return an int return < 0 on error
-
-TEXT*/
-
-/*OVERVIEW
-
-ESSENTIAL
-
-pigpio_start Connects to a pigpio daemon
-pigpio_stop Disconnects from a pigpio daemon
-
-BEGINNER
-
-set_mode Set a GPIO mode
-get_mode Get a GPIO mode
-
-set_pull_up_down Set/clear GPIO pull up/down resistor
-
-gpio_read Read a GPIO
-gpio_write Write a GPIO
-
-set_PWM_dutycycle Start/stop PWM pulses on a GPIO
-get_PWM_dutycycle Get the PWM dutycycle in use on a GPIO
-
-set_servo_pulsewidth Start/stop servo pulses on a GPIO
-get_servo_pulsewidth Get the servo pulsewidth in use on a GPIO
-
-callback Create GPIO level change callback
-callback_ex Create GPIO level change callback
-callback_cancel Cancel a callback
-wait_for_edge Wait for GPIO level change
-
-INTERMEDIATE
-
-gpio_trigger Send a trigger pulse to a GPIO.
-
-set_watchdog Set a watchdog on a GPIO.
-
-set_PWM_range Configure PWM range for a GPIO
-get_PWM_range Get configured PWM range for a GPIO
-
-set_PWM_frequency Configure PWM frequency for a GPIO
-get_PWM_frequency Get configured PWM frequency for a GPIO
-
-read_bank_1 Read all GPIO in bank 1
-read_bank_2 Read all GPIO in bank 2
-
-clear_bank_1 Clear selected GPIO in bank 1
-clear_bank_2 Clear selected GPIO in bank 2
-
-set_bank_1 Set selected GPIO in bank 1
-set_bank_2 Set selected GPIO in bank 2
-
-start_thread Start a new thread
-stop_thread Stop a previously started thread
-
-ADVANCED
-
-get_PWM_real_range Get underlying PWM range for a GPIO
-
-notify_open Request a notification handle
-notify_begin Start notifications for selected GPIO
-notify_pause Pause notifications
-notify_close Close a notification
-
-bb_serial_read_open Opens a GPIO for bit bang serial reads
-bb_serial_read Reads bit bang serial data from a GPIO
-bb_serial_read_close Closes a GPIO for bit bang serial reads
-bb_serial_invert Invert serial logic (1 invert, 0 normal)
-
-hardware_clock Start hardware clock on supported GPIO
-hardware_PWM Start hardware PWM on supported GPIO
-
-set_glitch_filter Set a glitch filter on a GPIO
-set_noise_filter Set a noise filter on a GPIO
-
-get_pad_strength Gets a pads drive strength
-set_pad_strength Sets a pads drive strength
-
-shell_ Executes a shell command
-
-SCRIPTS
-
-store_script Store a script
-run_script Run a stored script
-script_status Get script status and parameters
-stop_script Stop a running script
-delete_script Delete a stored script
-
-WAVES
-
-wave_clear Deletes all waveforms
-
-wave_add_new Starts a new waveform
-wave_add_generic Adds a series of pulses to the waveform
-wave_add_serial Adds serial data to the waveform
-
-wave_create Creates a waveform from added data
-wave_delete Deletes one or more waveforms
-
-wave_send_once Transmits a waveform once
-wave_send_repeat Transmits a waveform repeatedly
-wave_send_using_mode Transmits a waveform in the chosen mode
-
-wave_chain Transmits a chain of waveforms
-
-wave_tx_at Returns the current transmitting waveform
-wave_tx_busy Checks to see if the waveform has ended
-wave_tx_stop Aborts the current waveform
-
-wave_get_micros Length in microseconds of the current waveform
-wave_get_high_micros Length of longest waveform so far
-wave_get_max_micros Absolute maximum allowed micros
-
-wave_get_pulses Length in pulses of the current waveform
-wave_get_high_pulses Length of longest waveform so far
-wave_get_max_pulses Absolute maximum allowed pulses
-
-wave_get_cbs Length in cbs of the current waveform
-wave_get_high_cbs Length of longest waveform so far
-wave_get_max_cbs Absolute maximum allowed cbs
-
-I2C
-
-i2c_open Opens an I2C device
-i2c_close Closes an I2C device
-
-i2c_write_quick smbus write quick
-i2c_write_byte smbus write byte
-i2c_read_byte smbus read byte
-i2c_write_byte_data smbus write byte data
-i2c_write_word_data smbus write word data
-i2c_read_byte_data smbus read byte data
-i2c_read_word_data smbus read word data
-i2c_process_call smbus process call
-i2c_write_block_data smbus write block data
-i2c_read_block_data smbus read block data
-i2c_block_process_call smbus block process call
-
-i2c_write_i2c_block_data smbus write I2C block data
-i2c_read_i2c_block_data smbus read I2C block data
-
-i2c_read_device Reads the raw I2C device
-i2c_write_device Writes the raw I2C device
-
-i2c_zip Performs multiple I2C transactions
-
-bb_i2c_open Opens GPIO for bit banging I2C
-bb_i2c_close Closes GPIO for bit banging I2C
-bb_i2c_zip Performs multiple bit banged I2C transactions
-
-SPI
-
-spi_open Opens a SPI device
-spi_close Closes a SPI device
-
-spi_read Reads bytes from a SPI device
-spi_write Writes bytes to a SPI device
-spi_xfer Transfers bytes with a SPI device
-
-bb_spi_open Opens GPIO for bit banging SPI
-bb_spi_close Closes GPIO for bit banging SPI
-bb_spi_xfer Transfers bytes with bit banging SPI
-
-SERIAL
-
-serial_open Opens a serial device
-serial_close Closes a serial device
-
-serial_write_byte Writes a byte to a serial device
-serial_read_byte Reads a byte from a serial device
-serial_write Writes bytes to a serial device
-serial_read Reads bytes from a serial device
-
-serial_data_available Returns number of bytes ready to be read
-
-FILES
-
-file_open Opens a file
-file_close Closes a file
-file_read Reads bytes from a file
-file_write Writes bytes to a file
-file_seek Seeks to a position within a file
-file_list List files which match a pattern
-
-CUSTOM
-
-custom_1 User custom function 1
-custom_2 User custom function 2
-
-UTILITIES
-
-get_current_tick Get current tick (microseconds)
-
-get_hardware_revision Get hardware revision
-get_pigpio_version Get the pigpio version
-pigpiod_if_version Get the pigpiod_if2 version
-
-pigpio_error Get a text description of an error code.
-
-time_sleep Sleeps for a float number of seconds
-time_time Float number of seconds since the epoch
-
-OVERVIEW*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*CBFunc_t)
- (int pi, unsigned user_gpio, unsigned level, uint32_t tick);
-
-typedef void (*CBFuncEx_t)
- (int pi, unsigned user_gpio, unsigned level, uint32_t tick, void * user);
-
-typedef struct callback_s callback_t;
-
-/*F*/
-double time_time(void);
-/*D
-Return the current time in seconds since the Epoch.
-D*/
-
-/*F*/
-void time_sleep(double seconds);
-/*D
-Delay execution for a given number of seconds.
-
-. .
-seconds: the number of seconds to delay.
-. .
-D*/
-
-/*F*/
-char *pigpio_error(int errnum);
-/*D
-Return a text description for an error code.
-
-. .
-errnum: the error code.
-. .
-D*/
-
-/*F*/
-unsigned pigpiod_if_version(void);
-/*D
-Return the pigpiod_if2 version.
-D*/
-
-/*F*/
-pthread_t *start_thread(gpioThreadFunc_t thread_func, void *userdata);
-/*D
-Starts a new thread of execution with thread_func as the main routine.
-
-. .
-thread_func: the main function for the new thread.
- userdata: a pointer to an arbitrary argument.
-. .
-
-Returns a pointer to pthread_t if OK, otherwise NULL.
-
-The function is passed the single argument userdata.
-
-The thread can be cancelled by passing the pointer to pthread_t to
-[*stop_thread*].
-D*/
-
-/*F*/
-void stop_thread(pthread_t *pth);
-/*D
-Cancels the thread pointed at by pth.
-
-. .
-pth: the thread to be stopped.
-. .
-
-No value is returned.
-
-The thread to be stopped should have been started with [*start_thread*].
-D*/
-
-/*F*/
-int pigpio_start(char *addrStr, char *portStr);
-/*D
-Connect to the pigpio daemon. Reserving command and
-notification streams.
-
-. .
-addrStr: specifies the host or IP address of the Pi running the
- pigpio daemon. It may be NULL in which case localhost
- is used unless overridden by the PIGPIO_ADDR environment
- variable.
-
-portStr: specifies the port address used by the Pi running the
- pigpio daemon. It may be NULL in which case "8888"
- is used unless overridden by the PIGPIO_PORT environment
- variable.
-. .
-
-Returns an integer value greater than or equal to zero if OK.
-
-This value is passed to the GPIO routines to specify the Pi
-to be operated on.
-D*/
-
-/*F*/
-void pigpio_stop(int pi);
-/*D
-Terminates the connection to a pigpio daemon and releases
-resources used by the library.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-D*/
-
-/*F*/
-int set_mode(int pi, unsigned gpio, unsigned mode);
-/*D
-Set the GPIO mode.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-gpio: 0-53.
-mode: PI_INPUT, PI_OUTPUT, PI_ALT0, PI_ALT1,
- PI_ALT2, PI_ALT3, PI_ALT4, PI_ALT5.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_MODE,
-or PI_NOT_PERMITTED.
-D*/
-
-/*F*/
-int get_mode(int pi, unsigned gpio);
-/*D
-Get the GPIO mode.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-gpio: 0-53.
-. .
-
-Returns the GPIO mode if OK, otherwise PI_BAD_GPIO.
-D*/
-
-/*F*/
-int set_pull_up_down(int pi, unsigned gpio, unsigned pud);
-/*D
-Set or clear the GPIO pull-up/down resistor.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-gpio: 0-53.
- pud: PI_PUD_UP, PI_PUD_DOWN, PI_PUD_OFF.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_PUD,
-or PI_NOT_PERMITTED.
-D*/
-
-/*F*/
-int gpio_read(int pi, unsigned gpio);
-/*D
-Read the GPIO level.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-gpio:0-53.
-. .
-
-Returns the GPIO level if OK, otherwise PI_BAD_GPIO.
-D*/
-
-/*F*/
-int gpio_write(int pi, unsigned gpio, unsigned level);
-/*D
-Write the GPIO level.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
- gpio: 0-53.
-level: 0, 1.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_GPIO, PI_BAD_LEVEL,
-or PI_NOT_PERMITTED.
-
-Notes
-
-If PWM or servo pulses are active on the GPIO they are switched off.
-D*/
-
-/*F*/
-int set_PWM_dutycycle(int pi, unsigned user_gpio, unsigned dutycycle);
-/*D
-Start (non-zero dutycycle) or stop (0) PWM pulses on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-dutycycle: 0-range (range defaults to 255).
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYCYCLE,
-or PI_NOT_PERMITTED.
-Notes
-
-The [*set_PWM_range*] function may be used to change the
-default range of 255.
-D*/
-
-/*F*/
-int get_PWM_dutycycle(int pi, unsigned user_gpio);
-/*D
-Return the PWM dutycycle in use on a GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_PWM_GPIO.
-
-For normal PWM the dutycycle will be out of the defined range
-for the GPIO (see [*get_PWM_range*]).
-
-If a hardware clock is active on the GPIO the reported dutycycle
-will be 500000 (500k) out of 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported dutycycle
-will be out of a 1000000 (1M).
-D*/
-
-/*F*/
-int set_PWM_range(int pi, unsigned user_gpio, unsigned range);
-/*D
-Set the range of PWM values to be used on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
- range: 25-40000.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_DUTYRANGE,
-or PI_NOT_PERMITTED.
-
-Notes
-
-If PWM is currently active on the GPIO its dutycycle will be
-scaled to reflect the new range.
-
-The real range, the number of steps between fully off and fully on
-for each of the 18 available GPIO frequencies is
-
-. .
- 25(#1), 50(#2), 100(#3), 125(#4), 200(#5), 250(#6),
- 400(#7), 500(#8), 625(#9), 800(#10), 1000(#11), 1250(#12),
-2000(#13), 2500(#14), 4000(#15), 5000(#16), 10000(#17), 20000(#18)
-. .
-
-The real value set by set_PWM_range is (dutycycle * real range) / range.
-D*/
-
-/*F*/
-int get_PWM_range(int pi, unsigned user_gpio);
-/*D
-Get the range of PWM values being used on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-. .
-
-Returns the dutycycle range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-If a hardware clock or hardware PWM is active on the GPIO the
-reported range will be 1000000 (1M).
-D*/
-
-/*F*/
-int get_PWM_real_range(int pi, unsigned user_gpio);
-/*D
-Get the real underlying range of PWM values being used on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-. .
-
-Returns the real range used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-
-If a hardware clock is active on the GPIO the reported
-real range will be 1000000 (1M).
-
-If hardware PWM is active on the GPIO the reported real range
-will be approximately 250M divided by the set PWM frequency.
-
-D*/
-
-/*F*/
-int set_PWM_frequency(int pi, unsigned user_gpio, unsigned frequency);
-/*D
-Set the frequency (in Hz) of the PWM to be used on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-frequency: >=0 (Hz).
-. .
-
-Returns the numerically closest frequency if OK, otherwise
-PI_BAD_USER_GPIO or PI_NOT_PERMITTED.
-
-If PWM is currently active on the GPIO it will be switched
-off and then back on at the new frequency.
-
-Each GPIO can be independently set to one of 18 different
-PWM frequencies.
-
-The selectable frequencies depend upon the sample rate which
-may be 1, 2, 4, 5, 8, or 10 microseconds (default 5). The
-sample rate is set when the pigpio daemon is started.
-
-The frequencies for each sample rate are:
-
-. .
- Hertz
-
- 1: 40000 20000 10000 8000 5000 4000 2500 2000 1600
- 1250 1000 800 500 400 250 200 100 50
-
- 2: 20000 10000 5000 4000 2500 2000 1250 1000 800
- 625 500 400 250 200 125 100 50 25
-
- 4: 10000 5000 2500 2000 1250 1000 625 500 400
- 313 250 200 125 100 63 50 25 13
-sample
- rate
- (us) 5: 8000 4000 2000 1600 1000 800 500 400 320
- 250 200 160 100 80 50 40 20 10
-
- 8: 5000 2500 1250 1000 625 500 313 250 200
- 156 125 100 63 50 31 25 13 6
-
- 10: 4000 2000 1000 800 500 400 250 200 160
- 125 100 80 50 40 25 20 10 5
-. .
-D*/
-
-/*F*/
-int get_PWM_frequency(int pi, unsigned user_gpio);
-/*D
-Get the frequency of PWM being used on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-. .
-
-For normal PWM the frequency will be that defined for the GPIO by
-[*set_PWM_frequency*].
-
-If a hardware clock is active on the GPIO the reported frequency
-will be that set by [*hardware_clock*].
-
-If hardware PWM is active on the GPIO the reported frequency
-will be that set by [*hardware_PWM*].
-
-Returns the frequency (in hertz) used for the GPIO if OK,
-otherwise PI_BAD_USER_GPIO.
-D*/
-
-/*F*/
-int set_servo_pulsewidth(int pi, unsigned user_gpio, unsigned pulsewidth);
-/*D
-Start (500-2500) or stop (0) servo pulses on the GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
- user_gpio: 0-31.
-pulsewidth: 0 (off), 500 (anti-clockwise) - 2500 (clockwise).
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, PI_BAD_PULSEWIDTH or
-PI_NOT_PERMITTED.
-
-The selected pulsewidth will continue to be transmitted until
-changed by a subsequent call to set_servo_pulsewidth.
-
-The pulsewidths supported by servos varies and should probably be
-determined by experiment. A value of 1500 should always be safe and
-represents the mid-point of rotation.
-
-You can DAMAGE a servo if you command it to move beyond its limits.
-
-OTHER UPDATE RATES:
-
-This function updates servos at 50Hz. If you wish to use a different
-update frequency you will have to use the PWM functions.
-
-. .
-Update Rate (Hz) 50 100 200 400 500
-1E6/Hz 20000 10000 5000 2500 2000
-. .
-
-Firstly set the desired PWM frequency using [*set_PWM_frequency*].
-
-Then set the PWM range using [*set_PWM_range*] to 1E6/Hz.
-Doing this allows you to use units of microseconds when setting
-the servo pulsewidth.
-
-E.g. If you want to update a servo connected to GPIO 25 at 400Hz
-
-. .
-set_PWM_frequency(25, 400);
-set_PWM_range(25, 2500);
-. .
-
-Thereafter use the [*set_PWM_dutycycle*] function to move the servo,
-e.g. set_PWM_dutycycle(25, 1500) will set a 1500 us pulse.
-D*/
-
-/*F*/
-int get_servo_pulsewidth(int pi, unsigned user_gpio);
-/*D
-Return the servo pulsewidth in use on a GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO or PI_NOT_SERVO_GPIO.
-D*/
-
-/*F*/
-int notify_open(int pi);
-/*D
-Get a free notification handle.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-Returns a handle greater than or equal to zero if OK,
-otherwise PI_NO_HANDLE.
-
-A notification is a method for being notified of GPIO state
-changes via a pipe.
-
-Pipes are only accessible from the local machine so this function
-serves no purpose if you are using the library from a remote machine.
-The in-built (socket) notifications provided by [*callback*]
-should be used instead.
-
-Notifications for handle x will be available at the pipe
-named /dev/pigpiox (where x is the handle number).
-E.g. if the function returns 15 then the notifications must be
-read from /dev/pigpio15.
-D*/
-
-/*F*/
-int notify_begin(int pi, unsigned handle, uint32_t bits);
-/*D
-Start notifications on a previously opened handle.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-handle: 0-31 (as returned by [*notify_open*])
- bits: a mask indicating the GPIO to be notified.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-The notification sends state changes for each GPIO whose
-corresponding bit in bits is set.
-
-Each notification occupies 12 bytes in the fifo as follows:
-
-. .
-typedef struct
-{
- uint16_t seqno;
- uint16_t flags;
- uint32_t tick;
- uint32_t level;
-} gpioReport_t;
-. .
-
-seqno: starts at 0 each time the handle is opened and then increments
-by one for each report.
-
-flags: two flags are defined, PI_NTFY_FLAGS_WDOG and PI_NTFY_FLAGS_ALIVE.
-
-PI_NTFY_FLAGS_WDOG, if bit 5 is set then bits 0-4 of the flags
-indicate a GPIO which has had a watchdog timeout.
-
-PI_NTFY_FLAGS_ALIVE, if bit 6 is set this indicates a keep alive
-signal on the pipe/socket and is sent once a minute in the absence
-of other notification activity.
-
-tick: the number of microseconds since system boot. It wraps around
-after 1h12m.
-
-level: indicates the level of each GPIO. If bit 1<=0 (as returned by [*pigpio_start*]).
-handle: 0-31 (as returned by [*notify_open*])
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-
-Notifications for the handle are suspended until
-[*notify_begin*] is called again.
-D*/
-
-/*F*/
-int notify_close(int pi, unsigned handle);
-/*D
-Stop notifications on a previously opened handle and
-release the handle for reuse.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-handle: 0-31 (as returned by [*notify_open*])
-. .
-
-Returns 0 if OK, otherwise PI_BAD_HANDLE.
-D*/
-
-/*F*/
-int set_watchdog(int pi, unsigned user_gpio, unsigned timeout);
-/*D
-Sets a watchdog for a GPIO.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
- timeout: 0-60000.
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO
-or PI_BAD_WDOG_TIMEOUT.
-
-The watchdog is nominally in milliseconds.
-
-Only one watchdog may be registered per GPIO.
-
-The watchdog may be cancelled by setting timeout to 0.
-
-If no level change has been detected for the GPIO for timeout
-milliseconds any notification for the GPIO has a report written
-to the fifo with the flags set to indicate a watchdog timeout.
-
-The [*callback*] and [*callback_ex*] functions interpret the flags
-and will call registered callbacks for the GPIO with level TIMEOUT.
-D*/
-
-/*F*/
-int set_glitch_filter(int pi, unsigned user_gpio, unsigned steady);
-/*D
-Sets a glitch filter on a GPIO.
-
-Level changes on the GPIO are not reported unless the level
-has been stable for at least [*steady*] microseconds. The
-level is then reported. Level changes of less than
-[*steady*] microseconds are ignored.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31
- steady: 0-300000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-Note, each (stable) edge will be timestamped [*steady*] microseconds
-after it was first detected.
-D*/
-
-/*F*/
-int set_noise_filter(
- int pi, unsigned user_gpio, unsigned steady, unsigned active);
-/*D
-Sets a noise filter on a GPIO.
-
-Level changes on the GPIO are ignored until a level which has
-been stable for [*steady*] microseconds is detected. Level changes
-on the GPIO are then reported for [*active*] microseconds after
-which the process repeats.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31
- steady: 0-300000
- active: 0-1000000
-. .
-
-Returns 0 if OK, otherwise PI_BAD_USER_GPIO, or PI_BAD_FILTER.
-
-Note, level changes before and after the active period may
-be reported. Your software must be designed to cope with
-such reports.
-D*/
-
-/*F*/
-uint32_t read_bank_1(int pi);
-/*D
-Read the levels of the bank 1 GPIO (GPIO 0-31).
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-The returned 32 bit integer has a bit set if the corresponding
-GPIO is logic 1. GPIO n has bit value (1<=0 (as returned by [*pigpio_start*]).
-. .
-
-The returned 32 bit integer has a bit set if the corresponding
-GPIO is logic 1. GPIO n has bit value (1<<(n-32)).
-D*/
-
-/*F*/
-int clear_bank_1(int pi, uint32_t bits);
-/*D
-Clears GPIO 0-31 if the corresponding bit in bits is set.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding GPIO is
- to be cleared.
-. .
-
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-D*/
-
-/*F*/
-int clear_bank_2(int pi, uint32_t bits);
-/*D
-Clears GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding GPIO is
- to be cleared.
-. .
-
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-D*/
-
-/*F*/
-int set_bank_1(int pi, uint32_t bits);
-/*D
-Sets GPIO 0-31 if the corresponding bit in bits is set.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding GPIO is
- to be set.
-. .
-
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-D*/
-
-/*F*/
-int set_bank_2(int pi, uint32_t bits);
-/*D
-Sets GPIO 32-53 if the corresponding bit (0-21) in bits is set.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-bits: a bit mask with 1 set if the corresponding GPIO is
- to be set.
-. .
-
-Returns 0 if OK, otherwise PI_SOME_PERMITTED.
-
-A status of PI_SOME_PERMITTED indicates that the user is not
-allowed to write to one or more of the GPIO.
-D*/
-
-
-/*F*/
-int hardware_clock(int pi, unsigned gpio, unsigned clkfreq);
-/*D
-Starts a hardware clock on a GPIO at the specified frequency.
-Frequencies above 30MHz are unlikely to work.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
- gpio: see description
-frequency: 0 (off) or 4689-250000000 (250M)
-. .
-
-Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
-PI_NOT_HCLK_GPIO, PI_BAD_HCLK_FREQ,or PI_BAD_HCLK_PASS.
-
-The same clock is available on multiple GPIO. The latest
-frequency setting will be used by all GPIO which share a clock.
-
-The GPIO must be one of the following.
-
-. .
-4 clock 0 All models
-5 clock 1 All models but A and B (reserved for system use)
-6 clock 2 All models but A and B
-20 clock 0 All models but A and B
-21 clock 1 All models but A and Rev.2 B (reserved for system use)
-
-32 clock 0 Compute module only
-34 clock 0 Compute module only
-42 clock 1 Compute module only (reserved for system use)
-43 clock 2 Compute module only
-44 clock 1 Compute module only (reserved for system use)
-. .
-
-Access to clock 1 is protected by a password as its use will likely
-crash the Pi. The password is given by or'ing 0x5A000000 with the
-GPIO number.
-D*/
-
-
-/*F*/
-int hardware_PWM(int pi, unsigned gpio, unsigned PWMfreq, uint32_t PWMduty);
-/*D
-Starts hardware PWM on a GPIO at the specified frequency and dutycycle.
-Frequencies above 30MHz are unlikely to work.
-
-NOTE: Any waveform started by [*wave_send_**] or [*wave_chain*]
-will be cancelled.
-
-This function is only valid if the pigpio main clock is PCM. The
-main clock defaults to PCM but may be overridden when the pigpio
-daemon is started (option -t).
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
- gpio: see descripton
-PWMfreq: 0 (off) or 1-125000000 (125M)
-PWMduty: 0 (off) to 1000000 (1M)(fully on)
-. .
-
-Returns 0 if OK, otherwise PI_NOT_PERMITTED, PI_BAD_GPIO,
-PI_NOT_HPWM_GPIO, PI_BAD_HPWM_DUTY, PI_BAD_HPWM_FREQ,
-or PI_HPWM_ILLEGAL.
-
-The same PWM channel is available on multiple GPIO. The latest
-frequency and dutycycle setting will be used by all GPIO which
-share a PWM channel.
-
-The GPIO must be one of the following.
-
-. .
-12 PWM channel 0 All models but A and B
-13 PWM channel 1 All models but A and B
-18 PWM channel 0 All models
-19 PWM channel 1 All models but A and B
-
-40 PWM channel 0 Compute module only
-41 PWM channel 1 Compute module only
-45 PWM channel 1 Compute module only
-52 PWM channel 0 Compute module only
-53 PWM channel 1 Compute module only
-. .
-
-The actual number of steps beween off and fully on is the
-integral part of 250 million divided by PWMfreq.
-
-The actual frequency set is 250 million / steps.
-
-There will only be a million steps for a PWMfreq of 250.
-Lower frequencies will have more steps and higher
-frequencies will have fewer steps. PWMduty is
-automatically scaled to take this into account.
-D*/
-
-
-/*F*/
-uint32_t get_current_tick(int pi);
-/*D
-Gets the current system tick.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-Tick is the number of microseconds since system boot.
-
-As tick is an unsigned 32 bit quantity it wraps around after
-2**32 microseconds, which is approximately 1 hour 12 minutes.
-
-D*/
-
-/*F*/
-uint32_t get_hardware_revision(int pi);
-/*D
-Get the Pi's hardware revision number.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-The hardware revision is the last few characters on the Revision line
-of /proc/cpuinfo.
-
-If the hardware revision can not be found or is not a valid
-hexadecimal number the function returns 0.
-
-The revision number can be used to determine the assignment of GPIO
-to pins (see [*gpio*]).
-
-There are at least three types of board.
-
-Type 1 boards have hardware revision numbers of 2 and 3.
-
-Type 2 boards have hardware revision numbers of 4, 5, 6, and 15.
-
-Type 3 boards have hardware revision numbers of 16 or greater.
-D*/
-
-/*F*/
-uint32_t get_pigpio_version(int pi);
-/*D
-Returns the pigpio version.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-D*/
-
-
-/*F*/
-int wave_clear(int pi);
-/*D
-This function clears all waveforms and any data added by calls to the
-[*wave_add_**] functions.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-Returns 0 if OK.
-D*/
-
-/*F*/
-int wave_add_new(int pi);
-/*D
-This function starts a new empty waveform. You wouldn't normally need
-to call this function as it is automatically called after a waveform is
-created with the [*wave_create*] function.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-Returns 0 if OK.
-D*/
-
-/*F*/
-int wave_add_generic(int pi, unsigned numPulses, gpioPulse_t *pulses);
-/*D
-This function adds a number of pulses to the current waveform.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-numPulses: the number of pulses.
- pulses: an array of pulses.
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_TOO_MANY_PULSES.
-
-The pulses are interleaved in time order within the existing waveform
-(if any).
-
-Merging allows the waveform to be built in parts, that is the settings
-for GPIO#1 can be added, and then GPIO#2 etc.
-
-If the added waveform is intended to start after or within the existing
-waveform then the first pulse should consist solely of a delay.
-D*/
-
-/*F*/
-int wave_add_serial
- (int pi, unsigned user_gpio, unsigned baud, unsigned data_bits,
- unsigned stop_bits, unsigned offset, unsigned numBytes, char *str);
-/*D
-This function adds a waveform representing serial data to the
-existing waveform (if any). The serial data starts offset
-microseconds from the start of the waveform.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-user_gpio: 0-31.
- baud: 50-1000000
-data_bits: number of data bits (1-32)
-stop_bits: number of stop half bits (2-8)
- offset: >=0
- numBytes: >=1
- str: an array of chars.
-. .
-
-Returns the new total number of pulses in the current waveform if OK,
-otherwise PI_BAD_USER_GPIO, PI_BAD_WAVE_BAUD, PI_BAD_DATABITS,
-PI_BAD_STOP_BITS, PI_TOO_MANY_CHARS, PI_BAD_SER_OFFSET,
-or PI_TOO_MANY_PULSES.
-
-NOTES:
-
-The serial data is formatted as one start bit, [*data_bits*] data bits,
-and [*stop_bits*]/2 stop bits.
-
-It is legal to add serial data streams with different baud rates to
-the same waveform.
-
-[*numBytes*] is the number of bytes of data in str.
-
-The bytes required for each character depend upon [*data_bits*].
-
-For [*data_bits*] 1-8 there will be one byte per character.
-For [*data_bits*] 9-16 there will be two bytes per character.
-For [*data_bits*] 17-32 there will be four bytes per character.
-D*/
-
-/*F*/
-int wave_create(int pi);
-/*D
-This function creates a waveform from the data provided by the prior
-calls to the [*wave_add_**] functions. Upon success a wave id
-greater than or equal to 0 is returned, otherwise PI_EMPTY_WAVEFORM,
-PI_TOO_MANY_CBS, PI_TOO_MANY_OOL, or PI_NO_WAVEFORM_ID.
-
-. .
-pi: >=0 (as returned by [*pigpio_start*]).
-. .
-
-The data provided by the [*wave_add_**] functions is consumed by this
-function.
-
-As many waveforms may be created as there is space available. The
-wave id is passed to [*wave_send_**] to specify the waveform to transmit.
-
-Normal usage would be
-
-Step 1. [*wave_clear*] to clear all waveforms and added data.
-
-Step 2. [*wave_add_**] calls to supply the waveform data.
-
-Step 3. [*wave_create*] to create the waveform and get a unique id
-
-Repeat steps 2 and 3 as needed.
-
-Step 4. [*wave_send_**] with the id of the waveform to transmit.
-
-A waveform comprises one or more pulses. Each pulse consists of a
-[*gpioPulse_t*] structure.
-
-. .
-typedef struct
-{
- uint32_t gpioOn;
- uint32_t gpioOff;
- uint32_t usDelay;
-} gpioPulse_t;
-. .
-
-The fields specify
-
-1) the GPIO to be switched on at the start of the pulse.
-2) the GPIO to be switched off at the start of the pulse.
-3) the delay in microseconds before the next pulse.
-
-Any or all the fields can be zero. It doesn't make any sense to
-set all the fields to zero (the pulse will be ignored).
-
-When a waveform is started each pulse is executed in order with the
-specified delay between the pulse and the next.
-
-Returns the new waveform id if OK, otherwise PI_EMPTY_WAVEFORM,
-PI_NO_WAVEFORM_ID, PI_TOO_MANY_CBS, or PI_TOO_MANY_OOL.
-D*/
-
-
-/*F*/
-int wave_delete(int pi, unsigned wave_id);
-/*D
-This function deletes the waveform with id wave_id.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Wave ids are allocated in order, 0, 1, 2, etc.
-
-Returns 0 if OK, otherwise PI_BAD_WAVE_ID.
-D*/
-
-
-/*F*/
-int wave_send_once(int pi, unsigned wave_id);
-/*D
-This function transmits the waveform with id wave_id. The waveform
-is sent once.
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-
-/*F*/
-int wave_send_repeat(int pi, unsigned wave_id);
-/*D
-This function transmits the waveform with id wave_id. The waveform
-cycles until cancelled (either by the sending of a new waveform or
-by [*wave_tx_stop*]).
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-wave_id: >=0, as returned by [*wave_create*].
-. .
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-
-/*F*/
-int wave_send_using_mode(int pi, unsigned wave_id, unsigned mode);
-/*D
-Transmits the waveform with id wave_id using mode mode.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
-wave_id: >=0, as returned by [*wave_create*].
- mode: PI_WAVE_MODE_ONE_SHOT, PI_WAVE_MODE_REPEAT,
- PI_WAVE_MODE_ONE_SHOT_SYNC, or PI_WAVE_MODE_REPEAT_SYNC.
-. .
-
-PI_WAVE_MODE_ONE_SHOT: same as [*wave_send_once*].
-
-PI_WAVE_MODE_REPEAT same as [*wave_send_repeat*].
-
-PI_WAVE_MODE_ONE_SHOT_SYNC same as [*wave_send_once*] but tries
-to sync with the previous waveform.
-
-PI_WAVE_MODE_REPEAT_SYNC same as [*wave_send_repeat*] but tries
-to sync with the previous waveform.
-
-WARNING: bad things may happen if you delete the previous
-waveform before it has been synced to the new waveform.
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-Returns the number of DMA control blocks in the waveform if OK,
-otherwise PI_BAD_WAVE_ID, or PI_BAD_WAVE_MODE.
-D*/
-
-/*F*/
-int wave_chain(int pi, char *buf, unsigned bufSize);
-/*D
-This function transmits a chain of waveforms.
-
-NOTE: Any hardware PWM started by [*hardware_PWM*] will be cancelled.
-
-The waves to be transmitted are specified by the contents of buf
-which contains an ordered list of [*wave_id*]s and optional command
-codes and related data.
-
-. .
- pi: >=0 (as returned by [*pigpio_start*]).
- buf: pointer to the wave_ids and optional command codes
-bufSize: the number of bytes in buf
-. .
-
-Returns 0 if OK, otherwise PI_CHAIN_NESTING, PI_CHAIN_LOOP_CNT, PI_BAD_CHAIN_LOOP, PI_BAD_CHAIN_CMD, PI_CHAIN_COUNTER,
-PI_BAD_CHAIN_DELAY, PI_CHAIN_TOO_BIG, or PI_BAD_WAVE_ID.
-
-Each wave is transmitted in the order specified. A wave may
-occur multiple times per chain.
-
-A blocks of waves may be transmitted multiple times by using
-the loop commands. The block is bracketed by loop start and
-end commands. Loops may be nested.
-
-Delays between waves may be added with the delay command.
-
-The following command codes are supported:
-
-Name @ Cmd & Data @ Meaning
-Loop Start @ 255 0 @ Identify start of a wave block
-Loop Repeat @ 255 1 x y @ loop x + y*256 times
-Delay @ 255 2 x y @ delay x + y*256 microseconds
-Loop Forever @ 255 3 @ loop forever
-
-If present Loop Forever must be the last entry in the chain.
-
-The code is currently dimensioned to support a chain with roughly
-600 entries and 20 loop counters.
-
-...
-#include