Import
This commit is contained in:
parent
c6c37db892
commit
b7ec484e6f
1
GPIO/ClientDoor.json
Normal file
1
GPIO/ClientDoor.json
Normal file
|
@ -0,0 +1 @@
|
|||
{"servers": {"name": "MQTT local","host": "tcp://192.168.0.89:1883","user": "beetai","pass": "Admin@123"},"clients": {"name": "Door 1","topic": "device/gpio/1","active": 1}}
|
323
GPIO/GPIO.go
Normal file
323
GPIO/GPIO.go
Normal file
|
@ -0,0 +1,323 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"beetai/file"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/stianeikeland/go-rpio"
|
||||
)
|
||||
|
||||
// var last_msg_time = time.Now().UnixNano() / 1000000
|
||||
|
||||
var Debug int = 1
|
||||
|
||||
//***********************************************//
|
||||
|
||||
const time_hold = 3 // Set time giu khoa cua
|
||||
|
||||
//***********************************************//
|
||||
|
||||
var AUTO_SERVER int = 1
|
||||
|
||||
//var path_log = "/home/pi/GPIO/log"
|
||||
var Path_config = "/home/pi/GPIO/ClientDoor.json"
|
||||
|
||||
var mqtt_cms_bi mqtt.Client
|
||||
|
||||
var CMS_HOST_BI = ""
|
||||
|
||||
var CMS_ACCESS_TOKEN_BI = ""
|
||||
var CMS_PASS_BI = ""
|
||||
|
||||
var CMS_TOPIC_IN = ""
|
||||
var CMS_TOPIC_OUT = ""
|
||||
|
||||
// const CMS_HOST_BI = "tcp://broker.beetai.com:21883"
|
||||
|
||||
// const CMS_ACCESS_TOKEN_BI = "beeetai"
|
||||
// const CMS_PASS_BI = "5ige8TdfTEHoTgJz"
|
||||
|
||||
// var CMS_TOPIC_IN = "gpio/devices/in/+"
|
||||
// var CMS_TOPIC_OUT = "gpio/devices/out/1"
|
||||
|
||||
// var CMS_TOPIC_IN = "gpio/devices/ademax/in/+"
|
||||
// var CMS_TOPIC_OUT = "gpio/devices/ademax/out/1"
|
||||
|
||||
// var CMS_TOPIC_IN = "gpio/devices/beetin/in/+"
|
||||
// var CMS_TOPIC_OUT = "gpio/devices/beetin/out/+"
|
||||
var time_now int = 0
|
||||
var Name string = ""
|
||||
var door_state bool
|
||||
var (
|
||||
// Use mcu pin 10, corresponds to physical pin 19 on the pi
|
||||
relay = rpio.Pin(6) // 6- raspberry pi 1 / 9 - raspberry 3B+
|
||||
)
|
||||
|
||||
// {
|
||||
// "server": [
|
||||
// {
|
||||
// "name":"MQTT local",
|
||||
// "host":"tcp://localhost:1883",
|
||||
// "user":"beetai",
|
||||
// "pass":"Admin@123"
|
||||
// }
|
||||
// ],
|
||||
// "client": [
|
||||
// {
|
||||
// "name": "Door 1",
|
||||
// "topic": "device/gpio/1",
|
||||
// "active": 1
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
var door Door
|
||||
|
||||
type Door struct {
|
||||
Servers Server `json:"servers"`
|
||||
Clients Client `json:"clients"`
|
||||
}
|
||||
|
||||
type Server struct {
|
||||
Name string `json:"name"`
|
||||
Host string `json:"host"`
|
||||
User string `json:"user"`
|
||||
Pass string `json:"pass"`
|
||||
}
|
||||
type Client struct {
|
||||
Name string `json:"name"`
|
||||
Topic string `json:"topic"`
|
||||
Active int `json:"active"`
|
||||
}
|
||||
|
||||
var state_read_ecf = false
|
||||
|
||||
func LoadConfig(path string) {
|
||||
//fmt.Println("---------------------------------- Function Load Config 123 ---------------------------")
|
||||
fmt.Println(path)
|
||||
payload := file.ReadFile(path)
|
||||
fmt.Println(payload)
|
||||
// err := json.Unmarshal([]byte(payload), &door)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// fmt.Println(door)
|
||||
fmt.Println("----------------------------------------")
|
||||
jsonFile, err := os.Open(path)
|
||||
// if we os.Open returns an error then handle it
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(jsonFile)
|
||||
fmt.Println("Successfully Opened engine.json")
|
||||
fmt.Println("\n")
|
||||
defer jsonFile.Close()
|
||||
byteValue, _ := ioutil.ReadAll(jsonFile)
|
||||
json.Unmarshal(byteValue, &door)
|
||||
|
||||
// // Convert Struct to Json
|
||||
// e, err := json.Marshal(door)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
// //file.Println(string(e))
|
||||
// err = ioutil.WriteFile(path, []byte(string(e)), 0)
|
||||
// if err != nil {
|
||||
// fmt.Println(err)
|
||||
// }
|
||||
//fmt.Printf("Door: \n", door)
|
||||
state_read_ecf = true
|
||||
// if Debug == 2 {
|
||||
// file.Println(file.ReadFile(Path_engine_config))
|
||||
// }
|
||||
}
|
||||
func main() {
|
||||
// Bat debug
|
||||
//mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime)
|
||||
time.Sleep(7 * time.Second)
|
||||
if state_read_ecf == false {
|
||||
LoadConfig(Path_config)
|
||||
fmt.Println("Read config done")
|
||||
|
||||
//fmt.Println(door.Servers)
|
||||
//fmt.Println(door.Clients)
|
||||
CMS_HOST_BI = door.Servers.Host
|
||||
CMS_ACCESS_TOKEN_BI = door.Servers.User
|
||||
CMS_PASS_BI = door.Servers.Pass
|
||||
CMS_TOPIC_IN = door.Clients.Topic
|
||||
fmt.Println(door)
|
||||
|
||||
}
|
||||
fmt.Println(door)
|
||||
mqtt_begin()
|
||||
//SetConnectionLostHandler(connLostHandler)
|
||||
mqtt_cms_bi.Subscribe(CMS_TOPIC_IN, 0, mqtt_messageHandler)
|
||||
|
||||
// Open and map memory to access gpio, check for errors
|
||||
if err := rpio.Open(); err != nil {
|
||||
if Debug == 1 {
|
||||
fmt.Println(err)
|
||||
}
|
||||
fmt.Println(err)
|
||||
//os.Exit(1)
|
||||
}
|
||||
defer rpio.Close()
|
||||
// Set pin to output mode
|
||||
relay.Output()
|
||||
relay.PullUp()
|
||||
// Toggle pin 20 times
|
||||
//go Check_door()
|
||||
for {
|
||||
Check_door()
|
||||
}
|
||||
}
|
||||
func connLostHandler(c mqtt.Client, err error) {
|
||||
fmt.Printf("Connection lost, reason: %v\n", err)
|
||||
mqtt_begin()
|
||||
}
|
||||
func Check_door() {
|
||||
if door_state == true {
|
||||
time.Sleep(time.Second * time_hold)
|
||||
relay.Low()
|
||||
if Debug == 1 {
|
||||
fmt.Println("Close Door")
|
||||
fmt.Println("--------------------------------")
|
||||
}
|
||||
|
||||
door_state = false
|
||||
}
|
||||
}
|
||||
func mqtt_begin() {
|
||||
fmt.Println(CMS_HOST_BI)
|
||||
fmt.Println(CMS_ACCESS_TOKEN_BI)
|
||||
fmt.Println(CMS_PASS_BI)
|
||||
opts_cms_bi := mqtt.NewClientOptions()
|
||||
opts_cms_bi.AddBroker(CMS_HOST_BI)
|
||||
opts_cms_bi.SetUsername(CMS_ACCESS_TOKEN_BI)
|
||||
opts_cms_bi.SetPassword(CMS_PASS_BI)
|
||||
opts_cms_bi.SetCleanSession(true)
|
||||
mqtt_cms_bi = mqtt.NewClient(opts_cms_bi)
|
||||
opts_cms_bi.SetConnectionLostHandler(MQTTLostConnectHandler)
|
||||
opts_cms_bi.SetOnConnectHandler(MQTTOnConnectHandler)
|
||||
|
||||
var reconect = false
|
||||
for reconect == false {
|
||||
if token_1 := mqtt_cms_bi.Connect(); token_1.Wait() && token_1.Error() == nil {
|
||||
//file.Write_log("MQTT CMS Beetsoft Connected\n", path_log)
|
||||
if Debug == 1 {
|
||||
fmt.Printf("MQTT CMS Beetsoft Connected\n")
|
||||
}
|
||||
reconect = true
|
||||
} else {
|
||||
//file.Write_log("MQTT CMS Beetsoft cant not Connected\n", path_log)
|
||||
if Debug == 1 {
|
||||
fmt.Printf("MQTT CMS Beetsoft cant not Connected\n")
|
||||
fmt.Printf("Loi CMS Beetsoft : %v \n", token_1.Error())
|
||||
fmt.Printf("-------------------\n")
|
||||
}
|
||||
reconect = false
|
||||
}
|
||||
}
|
||||
|
||||
opts_cms_bi.OnConnect = func(c mqtt.Client) {
|
||||
fmt.Printf("Client connected, subscribing to: " + CMS_TOPIC_IN)
|
||||
c.Subscribe(CMS_TOPIC_IN, 0, mqtt_messageHandler)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func MQTTLostConnectHandler(c mqtt.Client, err error) {
|
||||
// file.Write_log("MQTT CMS Beetsoft Lost Connect\n", box.Path_log_luncher)
|
||||
fmt.Println("MQTT CMS Beetsoft Lost Connect\n")
|
||||
fmt.Println(err)
|
||||
}
|
||||
func MQTTOnConnectHandler(client mqtt.Client) {
|
||||
// file.Write_log("Reconnect: MQTT_OnConnectHandler\n", box.Path_log_luncher)
|
||||
fmt.Println("Reconnect: MQTT_OnConnectHandler\n")
|
||||
mqtt_cms_bi.Unsubscribe(CMS_TOPIC_IN)
|
||||
time.Sleep(10)
|
||||
mqtt_cms_bi.Subscribe(CMS_TOPIC_IN, 0, mqtt_messageHandler)
|
||||
fmt.Println("Recall function Subscribe MQTT\n")
|
||||
// file.Write_log("Recall function Subscribe MQTT\n", box.Path_log_luncher)
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
var k int
|
||||
|
||||
// mqtt callback server beetswoft
|
||||
func mqtt_messageHandler(mqtt_bi mqtt.Client, message mqtt.Message) {
|
||||
|
||||
if Debug == 1 {
|
||||
fmt.Printf("TOPIC: %s\n", message.Topic())
|
||||
fmt.Printf("MSG:\n %s\n", message.Payload())
|
||||
}
|
||||
//file.Write_log(string(message.Topic()), path_log)
|
||||
//file.Write_log(string(message.Payload()), path_log)
|
||||
dec := json.NewDecoder(bytes.NewReader(message.Payload()))
|
||||
var list map[string]interface{}
|
||||
if err := dec.Decode(&list); err != nil {
|
||||
fmt.Printf("Error:%v\n", err)
|
||||
//return
|
||||
}
|
||||
fmt.Println(list)
|
||||
//************************************************//
|
||||
if Debug == 1 {
|
||||
fmt.Println(k)
|
||||
}
|
||||
|
||||
if list["method"] == "gpio" {
|
||||
topic := CMS_TOPIC_OUT
|
||||
if Debug == 1 {
|
||||
fmt.Println(topic)
|
||||
}
|
||||
if list["params"] == "1" {
|
||||
if door_state == true {
|
||||
|
||||
} else {
|
||||
relay.High()
|
||||
Name = (list["name"]).(string)
|
||||
fmt.Println("Xin Chao Mung " + Name)
|
||||
}
|
||||
|
||||
//msg := `{"method":"gpio","params":"1"}`
|
||||
//CmsResponse(mqtt_bi, topic, msg)
|
||||
if Debug == 1 {
|
||||
fmt.Println("Open Door")
|
||||
fmt.Println("--------------------------------")
|
||||
}
|
||||
|
||||
door_state = true
|
||||
|
||||
} else if list["params"] == "0" {
|
||||
//relay.Low()
|
||||
//msg := `{"method":"gpio","params":"0"}`
|
||||
//CmsResponse(mqtt_bi, topic, msg)
|
||||
relay.Low()
|
||||
if Debug == 1 {
|
||||
fmt.Println("Close Door")
|
||||
fmt.Println("--------------------------------")
|
||||
}
|
||||
|
||||
door_state = false
|
||||
}
|
||||
|
||||
//fmt.Print("Set gpio done\n")
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
func CmsResponse(c mqtt.Client, topic string, msg string) {
|
||||
c.Publish(topic, 0, false, msg)
|
||||
if Debug == 1 {
|
||||
fmt.Println("Publish message done")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//{"method":"gpio","params": "0"}
|
||||
//{"method":"gpio","params": "1"}
|
BIN
GPIO/Tool_debug_fast/GPIO
Normal file
BIN
GPIO/Tool_debug_fast/GPIO
Normal file
Binary file not shown.
211
GPIO/Tool_debug_fast/pub/pub.go
Normal file
211
GPIO/Tool_debug_fast/pub/pub.go
Normal file
|
@ -0,0 +1,211 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
)
|
||||
|
||||
var time_hold int
|
||||
var mqtt_cms_bi mqtt.Client
|
||||
|
||||
const CMS_HOST_BI string = "tcp://broker.beetai.com:21883"
|
||||
|
||||
const CMS_ACCESS_TOKEN_BI string = "beeetai"
|
||||
const CMS_PASS_BI = "5ige8TdfTEHoTgJz"
|
||||
|
||||
var id_box string = ""
|
||||
var CMS_TOPIC_IN_1 string = "gpio/devices/in/+"
|
||||
|
||||
// var CMS_TOPIC_IN string = "gpio/devices/in/1"
|
||||
// var CMS_TOPIC_OUT string = "gpio/devices/out/1"
|
||||
|
||||
var CMS_TOPIC_IN string = "gpio/devices/ademax/in/+"
|
||||
var CMS_TOPIC_OUT string = "gpio/devices/ademax/out/+"
|
||||
|
||||
// var CMS_TOPIC_IN_1 string = "v1/devices/7/telemetry/+"
|
||||
|
||||
//var CMS_TOPIC_OUT string = "gpio/devices/ademax/out/+"
|
||||
|
||||
var count int = 0
|
||||
var params string = ""
|
||||
var method string = ""
|
||||
var mode int = 0
|
||||
|
||||
//var ty bool = false
|
||||
|
||||
// {"method" : "ssh","params":"1"} {"method" : "cmd","params":"reboot"} {"method" : "cmd","params":"nano /root/monitor/engine/face_recognition/data/Config.txt"}
|
||||
// {"method" : "ssh","params":"0"} {"method" : "cmd","params":"htop"}
|
||||
// {"method" : "gpio","params":"1","name":"HIEUPV"}
|
||||
//============================> Main <==========================
|
||||
|
||||
func main() {
|
||||
|
||||
fmt.Printf("ID BOX : ")
|
||||
i := bufio.NewReader(os.Stdin)
|
||||
id, err := i.ReadString('\n')
|
||||
|
||||
if err == io.EOF {
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
||||
id = strings.Replace(id, "\n", "", -1)
|
||||
id_box = id
|
||||
|
||||
// var CMS_TOPIC_IN string = "gpio/devices/in/1"
|
||||
// var CMS_TOPIC_OUT string = "gpio/devices/out/1"
|
||||
var CMS_TOPIC_IN string = "gpio/devices/ademax/in/1"
|
||||
var CMS_TOPIC_OUT string = "gpio/devices/ademax/out/+"
|
||||
|
||||
fmt.Println("ID_BOX: " + id_box)
|
||||
fmt.Println("TOPIC IN :" + CMS_TOPIC_IN)
|
||||
fmt.Println("TOPIC OUT :" + CMS_TOPIC_OUT)
|
||||
fmt.Println("*************************************")
|
||||
mqtt_begin()
|
||||
mqtt_cms_bi.Subscribe(CMS_TOPIC_IN_1, 0, mqtt_messageHandler)
|
||||
fmt.Printf("MQTT host: %v\n", CMS_HOST_BI)
|
||||
fmt.Printf("Topic: %v\n", CMS_TOPIC_OUT)
|
||||
fmt.Println("Please sellect mode.\n*Mode 1: Tranfer Full Message.\n*Mode 2: Tranfer Message Type (params,value)")
|
||||
|
||||
m := bufio.NewReader(os.Stdin)
|
||||
md, err := m.ReadString('\n')
|
||||
|
||||
if err == io.EOF {
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
||||
md = strings.Replace(md, "\n", "", -1)
|
||||
mode, _ = strconv.Atoi(md)
|
||||
fmt.Printf("Mode:%v\n", mode)
|
||||
fmt.Println("----------> START <----------")
|
||||
if mode == 1 {
|
||||
for {
|
||||
Mode_1()
|
||||
}
|
||||
|
||||
} else if mode == 2 {
|
||||
for {
|
||||
Mode_2()
|
||||
}
|
||||
|
||||
}
|
||||
fmt.Println("End game")
|
||||
// for {
|
||||
// if mode == 1 {
|
||||
// Mode_1()
|
||||
// } else if mode == 2 {
|
||||
// Mode_2()
|
||||
// }
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
func Mode_1() {
|
||||
fmt.Print("Message:")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
msg, err := reader.ReadString('\n')
|
||||
|
||||
if err == io.EOF {
|
||||
os.Exit(0)
|
||||
}
|
||||
msg = strings.Replace(msg, "\n", "", -1)
|
||||
msg = strings.Replace(msg, "\n", "", -1)
|
||||
count++
|
||||
//CmsResponse(mqtt_cms_bi, CMS_TOPIC_OUT+strconv.Itoa(count), p)
|
||||
//CmsResponse_1(mqtt_cms_bi, CMS_TOPIC_IN+strconv.Itoa(count), msg)
|
||||
CmsResponse_1(mqtt_cms_bi, CMS_TOPIC_IN, msg)
|
||||
fmt.Println("Publish message Mode 1 ok")
|
||||
}
|
||||
func Mode_2() {
|
||||
fmt.Print("Method:")
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
p, err := reader.ReadString('\n')
|
||||
|
||||
if err == io.EOF {
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
||||
method = strings.Replace(p, "\n", "", -1)
|
||||
fmt.Print("Params:")
|
||||
|
||||
reader1 := bufio.NewReader(os.Stdin)
|
||||
v, err := reader1.ReadString('\n')
|
||||
|
||||
if err == io.EOF {
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
}
|
||||
params = strings.Replace(v, "\n", "", -1)
|
||||
count++
|
||||
//CmsResponse(mqtt_cms_bi, CMS_TOPIC_OUT+strconv.Itoa(count), p)
|
||||
CmsResponse_2(mqtt_cms_bi, CMS_TOPIC_IN, method, params)
|
||||
}
|
||||
|
||||
//=================> END MAIN <====================
|
||||
//***********************************************//
|
||||
//------------------ Function ---------------------
|
||||
|
||||
func mqtt_begin() {
|
||||
|
||||
opts_cms_bi := mqtt.NewClientOptions()
|
||||
opts_cms_bi.AddBroker(CMS_HOST_BI)
|
||||
opts_cms_bi.SetUsername(CMS_ACCESS_TOKEN_BI)
|
||||
opts_cms_bi.SetPassword("CMS_PASS_BI")
|
||||
opts_cms_bi.SetCleanSession(true)
|
||||
|
||||
mqtt_cms_bi = mqtt.NewClient(opts_cms_bi)
|
||||
if token_1 := mqtt_cms_bi.Connect(); token_1.Wait() && token_1.Error() == nil {
|
||||
fmt.Printf("MQTT CMS Beetsoft Connected\n")
|
||||
//file.Write_log("MQTT CMS BeetsoftConnected\n", path_log_luncher)
|
||||
} else {
|
||||
fmt.Printf("MQTT CMS Beetsoft cant not Connected\n")
|
||||
//file.Write_log("MQTT CMS Beetsoft cant not Connected\n", path_log_luncher)
|
||||
fmt.Printf("Loi CMS Beetsoft : %v \n", token_1.Error())
|
||||
fmt.Printf("-------------------\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
func CmsResponse_2(c mqtt.Client, topic string, method string, params string) {
|
||||
//var msg = `{"` + params + `":` + value + `}`
|
||||
var msg = `{"method":"` + method + `","params": "` + params + `"}`
|
||||
fmt.Printf("Message:%v", msg)
|
||||
c.Publish(topic, 0, false, msg)
|
||||
fmt.Println("\nPublic Message Done")
|
||||
fmt.Println("*****************************")
|
||||
}
|
||||
func CmsResponse_1(c mqtt.Client, topic string, msg string) {
|
||||
fmt.Printf("Message:%v", msg)
|
||||
c.Publish(topic, 0, false, msg)
|
||||
fmt.Println("\nPublic Message Done")
|
||||
fmt.Println("*****************************")
|
||||
}
|
||||
func mqtt_messageHandler(mqtt_bi mqtt.Client, message mqtt.Message) {
|
||||
fmt.Printf("TOPIC: %s\n", message.Topic())
|
||||
fmt.Printf("MSG:\n %s\n", message.Payload())
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(message.Payload()))
|
||||
var list map[string]interface{}
|
||||
if err := dec.Decode(&list); err != nil {
|
||||
println(err)
|
||||
//return
|
||||
}
|
||||
//fmt.Print("\n")
|
||||
if mode == 1 {
|
||||
Mode_1()
|
||||
} else if mode == 2 {
|
||||
Mode_2()
|
||||
}
|
||||
}
|
5
GPIO/build_pi.bat
Normal file
5
GPIO/build_pi.bat
Normal file
|
@ -0,0 +1,5 @@
|
|||
set GOOS=linux
|
||||
set GOARCH=arm
|
||||
set GOARM=5
|
||||
go build
|
||||
pause
|
21
GPIO/install_service.txt
Normal file
21
GPIO/install_service.txt
Normal file
|
@ -0,0 +1,21 @@
|
|||
cd /lib/systemd/system/
|
||||
sudo nano GPIO.service
|
||||
|
||||
[Unit]
|
||||
Description=MQTT GPIO
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/env /home/pi/GPIO/GPIO
|
||||
Restart=on-abort
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
sudo chmod 644 /lib/systemd/system/GPIO.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable GPIO.service
|
||||
sudo systemctl start GPIO.service
|
||||
|
8
GPIO/run_gpio.sh
Normal file
8
GPIO/run_gpio.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#! /bin/bash
|
||||
cd /home/pi/GPIO
|
||||
screen -dm -S GPIO ./GPIO >> log_1.txt
|
||||
t=$(date)
|
||||
echo "Time: $t" >> /home/pi/GPIO/autostart.txt
|
||||
echo "Run GPIO" >> /home/pi/GPIO/autostart.txt
|
||||
exit 0
|
||||
|
Loading…
Reference in New Issue
Block a user