Compare commits
9 Commits
b6c91e4ac4
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d564b2670 | |||
| 5a67e90143 | |||
| 224fae39f7 | |||
| 45459ee231 | |||
| 978dd0dc5d | |||
| 1f96e10f76 | |||
| c5782018b8 | |||
| 67874de37a | |||
| 582925b8a1 |
18
.vscode/c_cpp_properties.json
vendored
Normal file
18
.vscode/c_cpp_properties.json
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "linux-gcc-x64",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**"
|
||||||
|
],
|
||||||
|
"compilerPath": "/usr/bin/gcc",
|
||||||
|
"cStandard": "${default}",
|
||||||
|
"cppStandard": "${default}",
|
||||||
|
"intelliSenseMode": "linux-gcc-x64",
|
||||||
|
"compilerArgs": [
|
||||||
|
""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
24
.vscode/launch.json
vendored
Normal file
24
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "C/C++ Runner: Debug Session",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": false,
|
||||||
|
"externalConsole": false,
|
||||||
|
"cwd": "/hdd/GiTea-REPO/MD1200/PC_CONTROL_CODE/CPP/noInflux",
|
||||||
|
"program": "/hdd/GiTea-REPO/MD1200/PC_CONTROL_CODE/CPP/noInflux/build/Debug/outDebug",
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
59
.vscode/settings.json
vendored
Normal file
59
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp_Runner.cCompilerPath": "gcc",
|
||||||
|
"C_Cpp_Runner.cppCompilerPath": "g++",
|
||||||
|
"C_Cpp_Runner.debuggerPath": "gdb",
|
||||||
|
"C_Cpp_Runner.cStandard": "",
|
||||||
|
"C_Cpp_Runner.cppStandard": "",
|
||||||
|
"C_Cpp_Runner.msvcBatchPath": "",
|
||||||
|
"C_Cpp_Runner.useMsvc": false,
|
||||||
|
"C_Cpp_Runner.warnings": [
|
||||||
|
"-Wall",
|
||||||
|
"-Wextra",
|
||||||
|
"-Wpedantic",
|
||||||
|
"-Wshadow",
|
||||||
|
"-Wformat=2",
|
||||||
|
"-Wcast-align",
|
||||||
|
"-Wconversion",
|
||||||
|
"-Wsign-conversion",
|
||||||
|
"-Wnull-dereference"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.msvcWarnings": [
|
||||||
|
"/W4",
|
||||||
|
"/permissive-",
|
||||||
|
"/w14242",
|
||||||
|
"/w14287",
|
||||||
|
"/w14296",
|
||||||
|
"/w14311",
|
||||||
|
"/w14826",
|
||||||
|
"/w44062",
|
||||||
|
"/w44242",
|
||||||
|
"/w14905",
|
||||||
|
"/w14906",
|
||||||
|
"/w14263",
|
||||||
|
"/w44265",
|
||||||
|
"/w14928"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.enableWarnings": true,
|
||||||
|
"C_Cpp_Runner.warningsAsError": false,
|
||||||
|
"C_Cpp_Runner.compilerArgs": [],
|
||||||
|
"C_Cpp_Runner.linkerArgs": [],
|
||||||
|
"C_Cpp_Runner.includePaths": [],
|
||||||
|
"C_Cpp_Runner.includeSearch": [
|
||||||
|
"*",
|
||||||
|
"**/*"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.excludeSearch": [
|
||||||
|
"**/build",
|
||||||
|
"**/build/**",
|
||||||
|
"**/.*",
|
||||||
|
"**/.*/**",
|
||||||
|
"**/.vscode",
|
||||||
|
"**/.vscode/**"
|
||||||
|
],
|
||||||
|
"C_Cpp_Runner.useAddressSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useUndefinedSanitizer": false,
|
||||||
|
"C_Cpp_Runner.useLeakSanitizer": false,
|
||||||
|
"C_Cpp_Runner.showCompilationTime": false,
|
||||||
|
"C_Cpp_Runner.useLinkTimeOptimization": false,
|
||||||
|
"C_Cpp_Runner.msvcSecureNoWarnings": false
|
||||||
|
}
|
||||||
BIN
58FO8iY.jpg
Normal file
BIN
58FO8iY.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
1
PC_CONTROL_CODE/.gitignore
vendored
1
PC_CONTROL_CODE/.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
testing
|
testing
|
||||||
|
cpp
|
||||||
BIN
PC_CONTROL_CODE/docker/.Dockerfile.kate-swp
Normal file
BIN
PC_CONTROL_CODE/docker/.Dockerfile.kate-swp
Normal file
Binary file not shown.
1
PC_CONTROL_CODE/docker/.gitignore
vendored
Normal file
1
PC_CONTROL_CODE/docker/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.mypy_cache
|
||||||
@@ -1,29 +1,30 @@
|
|||||||
import serial, time, os
|
import serial, time, os
|
||||||
|
from typing import Final
|
||||||
|
|
||||||
# setting consts that can be customized
|
# setting consts that can be customized
|
||||||
|
|
||||||
# baud rate. Prob not needed as 38400 is standard
|
# baud rate. Prob not needed as 38400 is standard
|
||||||
MD1200BAUD = int(os.getenv("MD1200BAUD", 38400))
|
MD1200BAUD: Final[int] = int(os.getenv("MD1200BAUD", 38400))
|
||||||
# used if you want to run it on multiple JBODs
|
# used if you want to run it on multiple JBODs
|
||||||
SERIALADAPTER = os.getenv("SERIALADAPTER", "/dev/ttyUSB0")
|
SERIALADAPTER: Final[str] = os.getenv("SERIALADAPTER", "/dev/ttyUSB0")
|
||||||
# Factor that defines how aggressive the temperature curve is
|
# Factor that defines how aggressive the temperature curve is
|
||||||
TEMP_FACTOR = int(os.getenv("TEMP_FACTOR", 16))
|
TEMP_FACTOR: Final[int] = int(os.getenv("TEMP_FACTOR", 16))
|
||||||
# time between sending command to get temp and storing it. It's there to allow JBOD to answer
|
# time between sending command to get temp and storing it. It's there to allow JBOD to answer
|
||||||
EPPYSLEEPY = float(os.getenv("EPPYSLEEPY", 1))
|
EPPYSLEEPY: Final[float] = float(os.getenv("EPPYSLEEPY", 1))
|
||||||
|
|
||||||
LOW_FAN_TRSHD = int(os.getenv("LOW_FAN_TRSHD", 21))
|
LOW_FAN_TRSHD: Final[int] = int(os.getenv("LOW_FAN_TRSHD", 21))
|
||||||
HIGH_FAN_TRSHD = int(os.getenv("HIGH_FAN_TRSHD", 40))
|
HIGH_FAN_TRSHD: Final[int] = int(os.getenv("HIGH_FAN_TRSHD", 40))
|
||||||
|
|
||||||
GETTMPCMND = os.getenv("GETTMPCMND", "_temp_rd")
|
GETTMPCMND: Final[str] = os.getenv("GETTMPCMND", "_temp_rd")
|
||||||
SETFANCMND = os.getenv("SETFANCMND", "set_speed")
|
SETFANCMND: Final[str] = os.getenv("SETFANCMND", "set_speed")
|
||||||
|
|
||||||
DEFOUTPRCNTG = int(os.getenv("DEFOUTPRCNTG", 24))
|
DEFOUTPRCNTG: Final[int] = int(os.getenv("DEFOUTPRCNTG", 24))
|
||||||
|
|
||||||
MDSERIALTIMEOUT = float(os.getenv("MDSERIALTIMEOUT", 1))
|
MDSERIALTIMEOUT: Final[float] = float(os.getenv("MDSERIALTIMEOUT", 1))
|
||||||
|
|
||||||
TEMPREADINTERVAL = int(os.getenv("TEMPREADINTERVAL", 15))
|
TEMPREADINTERVAL: Final[int] = int(os.getenv("TEMPREADINTERVAL", 15))
|
||||||
|
|
||||||
GETTEMPTIMESLEEP = int(os.getenv("GETTEMPTIMESLEEP", 1))
|
GETTEMPTIMESLEEP: Final[int] = int(os.getenv("GETTEMPTIMESLEEP", 1))
|
||||||
|
|
||||||
# init
|
# init
|
||||||
MDserial = serial.Serial(
|
MDserial = serial.Serial(
|
||||||
@@ -38,7 +39,7 @@ lastTempReading = time.time()
|
|||||||
MDtempDict = {}
|
MDtempDict = {}
|
||||||
|
|
||||||
|
|
||||||
def getTemp():
|
def getTemp() -> dict:
|
||||||
|
|
||||||
MDserial.write(f"{GETTMPCMND}\n\r".encode())
|
MDserial.write(f"{GETTMPCMND}\n\r".encode())
|
||||||
time.sleep(GETTEMPTIMESLEEP)
|
time.sleep(GETTEMPTIMESLEEP)
|
||||||
@@ -94,9 +95,11 @@ def getTemp():
|
|||||||
continue
|
continue
|
||||||
# continue
|
# continue
|
||||||
return MDict
|
return MDict
|
||||||
|
else:
|
||||||
|
return {"error": "unidentified"}
|
||||||
|
|
||||||
|
|
||||||
def setSpeed(inSpeeDict: dict):
|
def setSpeed(inSpeeDict: dict) -> int:
|
||||||
|
|
||||||
bpavrg = 0
|
bpavrg = 0
|
||||||
# default
|
# default
|
||||||
@@ -108,18 +111,20 @@ def setSpeed(inSpeeDict: dict):
|
|||||||
outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
|
outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
|
||||||
# os.system(f"echo setting {outfanprcntg}%")
|
# os.system(f"echo setting {outfanprcntg}%")
|
||||||
|
|
||||||
|
return outfanprcntg
|
||||||
|
|
||||||
# Set fan speed
|
# Set fan speed
|
||||||
if outfanprcntg >= 20:
|
if outfanprcntg >= 20:
|
||||||
MDserial.write((f"{SETFANCMND} {str(outfanprcntg)} \n\r").encode())
|
MDserial.write((f"{SETFANCMND} {str(outfanprcntg)} \n\r").encode())
|
||||||
print(f"setting {outfanprcntg}%", flush=True)
|
print(f"setting {outfanprcntg}%", flush=True)
|
||||||
return 0
|
return outfanprcntg
|
||||||
else:
|
else:
|
||||||
# Set default value
|
# Set default value
|
||||||
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
||||||
return 1
|
return DEFOUTPRCNTG
|
||||||
|
|
||||||
# If something goes super wrong
|
# If something goes super wrong
|
||||||
return -1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
1
PC_CONTROL_CODE/dockerInflux/.gitignore
vendored
Normal file
1
PC_CONTROL_CODE/dockerInflux/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.mypy_cache
|
||||||
@@ -3,16 +3,8 @@
|
|||||||
services:
|
services:
|
||||||
mdfanchanger:
|
mdfanchanger:
|
||||||
container_name: MD_Fan_Changer
|
container_name: MD_Fan_Changer
|
||||||
image: yuruc3/md1200_fan_controll:v1.2.1
|
image: yuruc3/md1200_fan_controll:v2-flux
|
||||||
environment:
|
env_file: md1200.env
|
||||||
# - MD1200BAUD=
|
|
||||||
- SERIALADAPTER=/dev/ttyUSB0
|
|
||||||
- TEMP_FACTOR=17
|
|
||||||
- EPPYSLEEPY=0.5
|
|
||||||
- MDSERIALTIMEOUT=0.5
|
|
||||||
# - LOW_FAN_TRSHD=
|
|
||||||
# - HIGH_FAN_TRSHD=
|
|
||||||
env_file: "md1200.env"
|
|
||||||
devices:
|
devices:
|
||||||
- /dev/ttyUSB0:/dev/ttyUSB0
|
- /dev/ttyUSB0:/dev/ttyUSB0
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
@@ -3,17 +3,18 @@ from influxdb_client import InfluxDBClient, Point, WritePrecision
|
|||||||
from influxdb_client.client.write_api import SYNCHRONOUS, ASYNCHRONOUS, WriteOptions
|
from influxdb_client.client.write_api import SYNCHRONOUS, ASYNCHRONOUS, WriteOptions
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
from typing import Final
|
||||||
|
|
||||||
|
|
||||||
# INFLUXDB config
|
# INFLUXDB config
|
||||||
# token = "apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A=="
|
# token = "apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A=="
|
||||||
token = os.getenv("INFLUX_TOKEN")
|
INFLUXTOKEN: Final[str] = os.getenv("INFLUX_TOKEN")
|
||||||
# bucket = "JBOD"
|
# bucket = "JBOD"
|
||||||
bucket = os.getenv("INFLUX_BUCKET")
|
# INFLUXBUCKET: Final[str] = os.getenv("INFLUX_BUCKET")
|
||||||
# org = "staging"
|
# org = "staging"
|
||||||
org = os.getenv("INFLUX_ORG")
|
INFLUXORG: Final[str] = os.getenv("INFLUX_ORG")
|
||||||
# url = "http://localhost:8086"
|
# url = "http://localhost:8086"
|
||||||
url = os.getenv("INFLUX_URL")
|
INFLUXURL: Final[str] = os.getenv("INFLUX_URL")
|
||||||
# measurement = "MD1200"
|
# measurement = "MD1200"
|
||||||
measurement = os.getenv("INFLUX_MEASUREMENT")
|
measurement = os.getenv("INFLUX_MEASUREMENT")
|
||||||
# MACHINE_TAG = "CHONGUS1200"
|
# MACHINE_TAG = "CHONGUS1200"
|
||||||
@@ -24,7 +25,7 @@ LOCATION = os.getenv("INFLUX_LOCATION")
|
|||||||
INFLUX_SEPARATE_POINTS = int(os.getenv("INFLUX_SEPARATE_POINTS"))
|
INFLUX_SEPARATE_POINTS = int(os.getenv("INFLUX_SEPARATE_POINTS"))
|
||||||
|
|
||||||
# Initialize InfluxDB client and influxdb API
|
# Initialize InfluxDB client and influxdb API
|
||||||
inflxdb_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
|
inflxdb_client = influxdb_client.InfluxDBClient(url=INFLUXURL, token=INFLUXTOKEN, org=INFLUXORG)
|
||||||
#write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS)
|
#write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS)
|
||||||
write_api = inflxdb_client.write_api(write_options=WriteOptions(batch_size=500, flush_interval=1000))
|
write_api = inflxdb_client.write_api(write_options=WriteOptions(batch_size=500, flush_interval=1000))
|
||||||
|
|
||||||
|
|||||||
@@ -2,45 +2,57 @@ import time, os, influxdb_client, serial, threading
|
|||||||
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
||||||
from influxdb_client.client.write_api import SYNCHRONOUS, ASYNCHRONOUS, WriteOptions
|
from influxdb_client.client.write_api import SYNCHRONOUS, ASYNCHRONOUS, WriteOptions
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
from typing import Final
|
||||||
|
|
||||||
# setting consts that can be customized
|
# setting consts that can be customized
|
||||||
|
|
||||||
# baud rate. Prob not needed as 38400 is standard
|
# baud rate. Prob not needed as 38400 is standard
|
||||||
MD1200BAUD = int(os.getenv("MD1200BAUD", 38400))
|
MD1200BAUD: Final[int] = int(os.getenv("MD1200BAUD", "38400"))
|
||||||
# used if you want to run it on multiple JBODs
|
# used if you want to run it on multiple JBODs
|
||||||
SERIALADAPTER = os.getenv("SERIALADAPTER", "/dev/ttyUSB0")
|
SERIALADAPTER: Final[str] = os.getenv("SERIALADAPTER", "/dev/ttyUSB0")
|
||||||
# Factor that defines how aggressive the temperature curve is
|
# Factor that defines how aggressive the temperature curve is
|
||||||
TEMP_FACTOR = int(os.getenv("TEMP_FACTOR", 16))
|
TEMP_FACTOR: Final[float] = float(os.getenv("TEMP_FACTOR", "19"))
|
||||||
# time between sending command to get temp and storing it. It's there to allow JBOD to answer
|
# time between sending command to get temp and storing it. It's there to allow JBOD to answer
|
||||||
EPPYSLEEPY = float(os.getenv("EPPYSLEEPY", 1))
|
EPPYSLEEPY: Final[float] = float(os.getenv("EPPYSLEEPY", "1"))
|
||||||
|
|
||||||
LOW_FAN_TRSHD = int(os.getenv("LOW_FAN_TRSHD", 21))
|
LOW_FAN_TRSHD: Final[float] = float(os.getenv("LOW_FAN_TRSHD", "21"))
|
||||||
HIGH_FAN_TRSHD = int(os.getenv("HIGH_FAN_TRSHD", 40))
|
HIGH_FAN_TRSHD: Final[float] = float(os.getenv("HIGH_FAN_TRSHD", "40"))
|
||||||
|
|
||||||
GETTMPCMND = os.getenv("GETTMPCMND", "_temp_rd")
|
GETTMPCMND: Final[str] = os.getenv("GETTMPCMND", "_temp_rd")
|
||||||
SETFANCMND = os.getenv("SETFANCMND", "set_speed")
|
SETFANCMND: Final[str] = os.getenv("SETFANCMND", "set_speed")
|
||||||
|
|
||||||
DEFOUTPRCNTG = int(os.getenv("DEFOUTPRCNTG", 24))
|
DEFOUTPRCNTG: Final[float] = float(os.getenv("DEFOUTPRCNTG", "24"))
|
||||||
|
|
||||||
MDSERIALTIMEOUT = float(os.getenv("MDSERIALTIMEOUT", 1))
|
MDSERIALTIMEOUT: Final[float] = float(os.getenv("MDSERIALTIMEOUT", "1"))
|
||||||
|
|
||||||
TEMPREADINTERVAL = float(os.getenv("TEMPREADINTERVAL", 15))
|
TEMPREADINTERVAL: Final[float] = float(os.getenv("TEMPREADINTERVAL", "15"))
|
||||||
|
|
||||||
|
# If True or yes then we good
|
||||||
|
TEMPSETING = os.getenv("TEMPSETING", "1").strip().lower() in ("1", "true", "yes", "on")
|
||||||
|
|
||||||
|
PROCESSTEMPWAITTIME: Final[float] = float(os.getenv("PROCESSTEMPWAITTIME", "0.75"))
|
||||||
|
|
||||||
|
BACKOFFTIME: Final[float] = float(os.getenv("BACKOFFTIME", "5"))
|
||||||
|
|
||||||
|
INFLUX_MAX_RETRIES: Final[int] = int(os.getenv("INFLUX_MAX_RETRIES", "3"))
|
||||||
|
|
||||||
# INFLUXDB config
|
# INFLUXDB config
|
||||||
|
# should Influx be used?
|
||||||
|
USEINFLUX: Final[bool] = os.getenv("USEINFLUX", "True").strip().lower() in ("1", "true", "yes", "on")
|
||||||
# token = "apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A=="
|
# token = "apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A=="
|
||||||
token = os.getenv("INFLUX_TOKEN")
|
INFLUXTOKEN: Final[str] = str(os.getenv("INFLUX_TOKEN", "0"))
|
||||||
# bucket = "JBOD"
|
# bucket = "JBOD"
|
||||||
bucket = os.getenv("INFLUX_BUCKET")
|
INFLUXBUCKET: Final[str] = str(os.getenv("INFLUX_BUCKET", "0"))
|
||||||
# org = "staging"
|
# org = "staging"
|
||||||
org = os.getenv("INFLUX_ORG")
|
INFLUXORG: Final[str] = str(os.getenv("INFLUX_ORG", "0"))
|
||||||
# url = "http://localhost:8086"
|
# url = "http://localhost:8086"
|
||||||
url = os.getenv("INFLUX_URL")
|
INFLUXURL: Final[str] = str(os.getenv("INFLUX_URL", "0"))
|
||||||
# measurement = "MD1200"
|
# measurement = "MD1200"
|
||||||
measurement = os.getenv("INFLUX_MEASUREMENT")
|
INFLUXMEASUREMENT: Final[str] = str(os.getenv("INFLUX_MEASUREMENT", "0"))
|
||||||
# MACHINE_TAG = "CHONGUS1200"
|
# MACHINE_TAG = "CHONGUS1200"
|
||||||
MACHINE_TAG = os.getenv("INFLUX_MACHINE_TAG")
|
MACHINE_TAG: Final[str] = str(os.getenv("INFLUX_MACHINE_TAG", "0"))
|
||||||
# LOCATION = "HQ"
|
# LOCATION = "HQ"
|
||||||
LOCATION = os.getenv("INFLUX_LOCATION")
|
LOCATION: Final[str] = str(os.getenv("INFLUX_LOCATION", "0"))
|
||||||
# INFLX_SEPARATE_POINTS = 0.1
|
# INFLX_SEPARATE_POINTS = 0.1
|
||||||
# INFLUX_SEPARATE_POINTS = float(os.getenv("INFLUX_SEPARATE_POINTS"), 0.1)
|
# INFLUX_SEPARATE_POINTS = float(os.getenv("INFLUX_SEPARATE_POINTS"), 0.1)
|
||||||
|
|
||||||
@@ -53,26 +65,47 @@ MDserial = serial.Serial(
|
|||||||
bytesize=serial.EIGHTBITS,\
|
bytesize=serial.EIGHTBITS,\
|
||||||
timeout=MDSERIALTIMEOUT)
|
timeout=MDSERIALTIMEOUT)
|
||||||
|
|
||||||
lastTempReading = time.time()
|
# lastTempReading: float = time.time()
|
||||||
MDtempDict = {}
|
setSpeedrcode = 21
|
||||||
MDict = {}
|
MDtempDict: dict = {}
|
||||||
fluxSending = False
|
MDict: dict = {}
|
||||||
currentTime = 0
|
currentSerialUsage = threading.Lock()
|
||||||
lastTempReading = 0
|
fluxSending: bool = False
|
||||||
|
currentTime: float = 0
|
||||||
|
lastTempReading: float = 0
|
||||||
# Initialize InfluxDB client and influxdb API
|
# Initialize InfluxDB client and influxdb API
|
||||||
# ---------------------UNCOMMENT-----------------------
|
# ---------------------UNCOMMENT-----------------------
|
||||||
# inflxdb_client = influxdb_client.InfluxDBClient(url=url, token=token, org=org)
|
if USEINFLUX:
|
||||||
# write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS)
|
inflxdb_client = influxdb_client.InfluxDBClient(url=INFLUXURL, token=INFLUXTOKEN, org=INFLUXORG)
|
||||||
|
write_api = inflxdb_client.write_api(write_options=SYNCHRONOUS)
|
||||||
|
inflxdb_LeData: list = []
|
||||||
# ---------------------UNCOMMENT-----------------------
|
# ---------------------UNCOMMENT-----------------------
|
||||||
|
|
||||||
|
|
||||||
def getTemp():
|
# Just a helper function for process_temps to avoid db errors on flapping network
|
||||||
|
def process_temps_dbsend(inpdatatosend) -> bool:
|
||||||
|
if not USEINFLUX:
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
write_api.write(bucket=INFLUXBUCKET, org=INFLUXORG, record=inpdatatosend)
|
||||||
|
return True
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Influx write error {e}", flush=True)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def getTemp() -> dict:
|
||||||
global MDict, fluxSending
|
global MDict, fluxSending
|
||||||
|
|
||||||
|
|
||||||
|
with currentSerialUsage:
|
||||||
MDserial.write(f"{GETTMPCMND}\n\r".encode())
|
MDserial.write(f"{GETTMPCMND}\n\r".encode())
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
MDreturning = MDserial.read_until(" >").decode()
|
MDreturning = MDserial.read_until(" >").decode()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# MDict = {}
|
# MDict = {}
|
||||||
|
|
||||||
# Sanitise output
|
# Sanitise output
|
||||||
@@ -129,9 +162,11 @@ def getTemp():
|
|||||||
fluxSending = True
|
fluxSending = True
|
||||||
|
|
||||||
return MDict
|
return MDict
|
||||||
|
else:
|
||||||
|
return {"error": "unidentified"}
|
||||||
|
|
||||||
|
|
||||||
def setSpeed(inSpeeDict: dict):
|
def setSpeed(inSpeeDict: dict) -> int:
|
||||||
|
|
||||||
bpavrg = 0
|
bpavrg = 0
|
||||||
# default
|
# default
|
||||||
@@ -140,21 +175,27 @@ def setSpeed(inSpeeDict: dict):
|
|||||||
# get backplanbe average
|
# get backplanbe average
|
||||||
if "bp1" in inSpeeDict and "bp2" in inSpeeDict:
|
if "bp1" in inSpeeDict and "bp2" in inSpeeDict:
|
||||||
bpavrg = (inSpeeDict["bp1"] + inSpeeDict["bp2"]) /2
|
bpavrg = (inSpeeDict["bp1"] + inSpeeDict["bp2"]) /2
|
||||||
|
#outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
|
||||||
outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
|
outfanprcntg = int((bpavrg / (HIGH_FAN_TRSHD - LOW_FAN_TRSHD)) * TEMP_FACTOR)
|
||||||
# os.system(f"echo setting {outfanprcntg}%")
|
# os.system(f"echo setting {outfanprcntg}%")
|
||||||
|
|
||||||
|
with currentSerialUsage:
|
||||||
|
|
||||||
# Set fan speed
|
# Set fan speed
|
||||||
if outfanprcntg >= 20:
|
if outfanprcntg >= 20:
|
||||||
MDserial.write((f"{SETFANCMND} {str(outfanprcntg)} \n\r").encode())
|
MDserial.write((f"{SETFANCMND} {str(outfanprcntg)} \n\r").encode())
|
||||||
print(f"setting {outfanprcntg}%", flush=True)
|
print(f"setting {outfanprcntg}%", flush=True)
|
||||||
return 0
|
|
||||||
|
return outfanprcntg
|
||||||
else:
|
else:
|
||||||
# Set default value
|
# Set default value
|
||||||
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
||||||
return 1
|
|
||||||
|
return outfanprcntg
|
||||||
|
|
||||||
|
|
||||||
# If something goes super wrong
|
# If something goes super wrong
|
||||||
return -1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -169,50 +210,65 @@ def setSpeed(inSpeeDict: dict):
|
|||||||
# print("Port allready opened.\nTry closing it first")
|
# print("Port allready opened.\nTry closing it first")
|
||||||
|
|
||||||
# Threaded flow processor
|
# Threaded flow processor
|
||||||
def process_temps():
|
def process_temps() -> None:
|
||||||
global MDict, fluxSending
|
global MDict, fluxSending, setSpeedrcode
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# ---LeData---
|
# ---LeData---
|
||||||
# {'bp1': 35, 'bp2': 29, 'sim0': 35, 'sim1': 34, 'exp0': 56, 'exp1': 54}
|
# {'bp1': 35, 'bp2': 29, 'sim0': 35, 'sim1': 34, 'exp0': 56, 'exp1': 54}
|
||||||
# ---LeData---
|
# ---LeData---
|
||||||
|
|
||||||
if fluxSending:
|
if fluxSending:
|
||||||
# Prep InfluxDB data
|
# Prep InfluxDB data
|
||||||
# ---------------------UNCOMMENT-----------------------
|
|
||||||
# inflxdb_Data_To_Send = (
|
|
||||||
# influxdb_client.Point(f"{measurement}-script")
|
|
||||||
# .tag("MACHINE", MACHINE_TAG)
|
|
||||||
# .tag("LOCATION", LOCATION)
|
|
||||||
# .field("Backplane1", MDict["bp1"])
|
|
||||||
# .field("Backplane2", MDict["bp2"])
|
|
||||||
# .field("SASIntModule0", MDict["sim0"])
|
|
||||||
# .field("SASIntModule1", MDict["sim1"])
|
|
||||||
# .field("Expander0", MDict["exp0"])
|
|
||||||
# .field("Expander1", MDict["exp1"])
|
|
||||||
# .field("Average", MDict["avg"])
|
|
||||||
# )
|
|
||||||
|
|
||||||
# inflxdb_Datazz_To_Send.append(inflxdb_Data_To_Send)
|
# build local copy in case MDict changes while executing
|
||||||
# # Send data to InfluxDB
|
MDictLocalCopy = MDict.copy()
|
||||||
# write_api.write(bucket=bucket, org=org, record=inflxdb_Data_To_Send)
|
try:
|
||||||
# # time.sleep(INFLX_SEPARATE_POINTS) # separate points
|
inflxdb_Data_To_Send = (
|
||||||
|
influxdb_client.Point(f"{INFLUXMEASUREMENT}-script")
|
||||||
|
.tag("MACHINE", MACHINE_TAG)
|
||||||
|
.tag("LOCATION", LOCATION)
|
||||||
|
.field("Backplane1", MDictLocalCopy["bp1"])
|
||||||
|
.field("Backplane2", MDictLocalCopy["bp2"])
|
||||||
|
.field("SASIntModule0", MDictLocalCopy["sim0"])
|
||||||
|
.field("SASIntModule1", MDictLocalCopy["sim1"])
|
||||||
|
.field("Expander0", MDictLocalCopy["exp0"])
|
||||||
|
.field("Expander1", MDictLocalCopy["exp1"])
|
||||||
|
.field("Average", MDictLocalCopy["avg"])
|
||||||
|
.field("FanSpeed", setSpeedrcode)
|
||||||
|
)
|
||||||
|
except KeyError:
|
||||||
|
time.sleep(BACKOFFTIME)
|
||||||
|
continue
|
||||||
|
|
||||||
# # print(f"{len(bigDict)} <--- This many entrys")
|
# Prep/append data
|
||||||
|
inflxdb_LeData.append(inflxdb_Data_To_Send)
|
||||||
|
|
||||||
|
# Issue YuruC3/MD1200#7 fix
|
||||||
|
if not process_temps_dbsend(inflxdb_Data_To_Send):
|
||||||
|
i = 0
|
||||||
|
while i < INFLUX_MAX_RETRIES:
|
||||||
|
if process_temps_dbsend(inflxdb_Data_To_Send):
|
||||||
|
print("Sending data to InfluxDB", flush=True)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
time.sleep(1)
|
||||||
|
i += 1
|
||||||
|
else:
|
||||||
|
print(f"Failed to send data to InfluxDB after {INFLUX_MAX_RETRIES} retires", flush=True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Sending data to InfluxDB", flush=True)
|
||||||
|
|
||||||
|
|
||||||
# # Clean up before another loop
|
|
||||||
# bigDict.clear()
|
# Clean up before another lo#op, 0.75
|
||||||
# inflxdb_Datazz_To_Send.clear()
|
inflxdb_LeData.clear()
|
||||||
# ---------------------UNCOMMENT-----------------------
|
|
||||||
print("I'm sending stuff to InfluxDB")
|
|
||||||
|
|
||||||
fluxSending = False
|
fluxSending = False
|
||||||
|
|
||||||
|
|
||||||
# print("----------------")
|
|
||||||
# return ()
|
|
||||||
else:
|
else:
|
||||||
continue
|
time.sleep(PROCESSTEMPWAITTIME)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -221,7 +277,8 @@ def process_temps():
|
|||||||
MDict = getTemp()
|
MDict = getTemp()
|
||||||
lastTempReading = time.time()
|
lastTempReading = time.time()
|
||||||
|
|
||||||
def mainCodeHere():
|
def mainCodeHere() -> None:
|
||||||
|
global setSpeedrcode
|
||||||
while True:
|
while True:
|
||||||
global MDict, fluxSending, currentTime, lastTempReading
|
global MDict, fluxSending, currentTime, lastTempReading
|
||||||
# https://stackoverflow.com/questions/52578122/not-able-to-send-the-enter-command-on-pyserial
|
# https://stackoverflow.com/questions/52578122/not-able-to-send-the-enter-command-on-pyserial
|
||||||
@@ -231,10 +288,11 @@ def mainCodeHere():
|
|||||||
currentTime = time.time()
|
currentTime = time.time()
|
||||||
|
|
||||||
if currentTime - lastTempReading >= TEMPREADINTERVAL:
|
if currentTime - lastTempReading >= TEMPREADINTERVAL:
|
||||||
|
|
||||||
getTemp()
|
getTemp()
|
||||||
lastTempReading = currentTime
|
lastTempReading = currentTime
|
||||||
|
|
||||||
if MDict:
|
if MDict and TEMPSETING:
|
||||||
setSpeedrcode = setSpeed(MDict)
|
setSpeedrcode = setSpeed(MDict)
|
||||||
|
|
||||||
# good
|
# good
|
||||||
@@ -254,20 +312,39 @@ def mainCodeHere():
|
|||||||
else:
|
else:
|
||||||
print("idk", flush=True)
|
print("idk", flush=True)
|
||||||
exit()
|
exit()
|
||||||
|
elif TEMPSETING == False:
|
||||||
|
print(f"Waiting to get temp", flush=True)
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
print(f"temperature not yet pulled.\nFalling back do default fan speed", flush=True)
|
print(f"temperature not yet pulled.\nFalling back do default fan speed", flush=True)
|
||||||
# os.system(f"echo temperature not yet pulled.\nFalling back do default fan speed")
|
# os.system(f"echo temperature not yet pulled.\nFalling back do default fan speed")
|
||||||
|
|
||||||
|
with currentSerialUsage:
|
||||||
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
MDserial.write((f"{SETFANCMND} {str(DEFOUTPRCNTG)} \n\r").encode())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
time.sleep(EPPYSLEEPY)
|
time.sleep(EPPYSLEEPY)
|
||||||
|
|
||||||
|
|
||||||
# Prepare threads and launch them
|
# Prepare threads and launch them
|
||||||
thread_main = threading.Thread(target=mainCodeHere)
|
|
||||||
thread_flux = threading.Thread(target=process_temps)
|
|
||||||
|
|
||||||
thread_main.start()
|
|
||||||
thread_flux.start()
|
|
||||||
|
|
||||||
thread_main.join()
|
# daemon to make docker exit smoother
|
||||||
thread_flux.join()
|
thread_main = threading.Thread(target=mainCodeHere, daemon=True)
|
||||||
|
threads = [thread_main]
|
||||||
|
|
||||||
|
if USEINFLUX:
|
||||||
|
thread_flux = threading.Thread(target=process_temps, daemon=True)
|
||||||
|
threads.append(thread_flux)
|
||||||
|
|
||||||
|
for thr in threads:
|
||||||
|
thr.start()
|
||||||
|
|
||||||
|
# Join both (this will block forever, which is fine for a daemon)
|
||||||
|
for thr in threads:
|
||||||
|
thr.join()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
# baud_rate=
|
# MD1200BAUD=
|
||||||
# serial_adapter=
|
SERIALADAPTER=/dev/ttyUSB0
|
||||||
# wait_time=
|
|
||||||
# temp_factor=
|
# These are (for me) working values
|
||||||
# lower_treshold=
|
EPPYSLEEPY=1.5
|
||||||
# upper_treshold=
|
MDSERIALTIMEOUT=2
|
||||||
INFLUX_TOKEN=apg1gysUeCcxdcRTMmosJTenbEppmUNi9rXlANDB2oNadBdWAu2GVTDc_q_dyo0iyYsckKaOvPRm6ba2NK0y_A==
|
TEMPREADINTERVAL=30
|
||||||
|
|
||||||
|
|
||||||
|
TEMP_FACTOR=16
|
||||||
|
# LOW_FAN_TRSHD=21
|
||||||
|
# HIGH_FAN_TRSHD=40
|
||||||
|
|
||||||
|
# Influxdb config
|
||||||
|
INFLUX_TOKEN=-3rZgq6EprG9i-gKqBDSFCC3hTS3U49fxGkg==
|
||||||
INFLUX_BUCKET=JBOD
|
INFLUX_BUCKET=JBOD
|
||||||
INFLUX_ORG=staging
|
INFLUX_ORG=FUBUKUS
|
||||||
INFLUX_URL=http://localhost:8086
|
INFLUX_URL=http://192.168.1.101:8086
|
||||||
INFLUX_MEASUREMENT=MD1200
|
INFLUX_MEASUREMENT=MD1200
|
||||||
INFLUX_MACHINE_TAG=CHONGUS1200
|
INFLUX_MACHINE_TAG=CHONGUS1200
|
||||||
INFLUX_LOCATION=HQ
|
INFLUX_LOCATION=HQ
|
||||||
INFLX_SEPARATE_POINTS=0.1
|
|
||||||
19
PC_CONTROL_CODE/dockerInflux/md1200.env.defaults
Normal file
19
PC_CONTROL_CODE/dockerInflux/md1200.env.defaults
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
MD1200BAUD=38400
|
||||||
|
SERIALADAPTER=/dev/ttyUSB0
|
||||||
|
|
||||||
|
EPPYSLEEPY=1
|
||||||
|
MDSERIALTIMEOUT=1
|
||||||
|
TEMPREADINTERVAL=15
|
||||||
|
|
||||||
|
TEMP_FACTOR=19
|
||||||
|
LOW_FAN_TRSHD=21
|
||||||
|
HIGH_FAN_TRSHD=40
|
||||||
|
|
||||||
|
# Influxdb config
|
||||||
|
INFLUX_TOKEN===
|
||||||
|
INFLUX_BUCKET=JBOD
|
||||||
|
INFLUX_ORG=staging
|
||||||
|
INFLUX_URL=http://localhost:8086
|
||||||
|
INFLUX_MEASUREMENT=MD1200
|
||||||
|
INFLUX_MACHINE_TAG=CHONGUS1200
|
||||||
|
INFLUX_LOCATION=HQ
|
||||||
@@ -8,10 +8,10 @@
|
|||||||
; Please visit documentation for the other options and examples
|
; Please visit documentation for the other options and examples
|
||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[env:genericSTM32F103C6]
|
[env:bluepill_f103c6]
|
||||||
platform = ststm32
|
platform = ststm32
|
||||||
board = genericSTM32F103C6
|
board = bluepill_f103c6
|
||||||
framework = arduino
|
framework = stm32cube
|
||||||
lib_deps = adafruit/DHT sensor library@^1.4.6
|
lib_deps = adafruit/DHT sensor library@^1.4.6
|
||||||
debug_tool = stlink
|
debug_tool = stlink
|
||||||
upload_protocol = stlink
|
upload_protocol = stlink
|
||||||
|
|||||||
130
STM32_CONTROL/src/main.cpp
Normal file
130
STM32_CONTROL/src/main.cpp
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
|
||||||
|
#include <stm32f1xx_hal.h>
|
||||||
|
|
||||||
|
UART_HandleTypeDef huart1;
|
||||||
|
|
||||||
|
// --- Function prototypes ---
|
||||||
|
void SystemClock_Config(void);
|
||||||
|
static void MX_GPIO_Init(void);
|
||||||
|
static void MX_USART1_UART_Init(void);
|
||||||
|
|
||||||
|
// --- Optional RX buffer for interrupt ---
|
||||||
|
uint8_t rx_byte;
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
HAL_Init();
|
||||||
|
SystemClock_Config();
|
||||||
|
MX_GPIO_Init();
|
||||||
|
MX_USART1_UART_Init();
|
||||||
|
|
||||||
|
char msg[] = "UART started at 38400 baud\r\n";
|
||||||
|
|
||||||
|
// Send a startup message
|
||||||
|
HAL_UART_Transmit(&huart1, (uint8_t*)msg, sizeof(msg)-1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
|
// Start interrupt-based receive of one byte
|
||||||
|
HAL_UART_Receive_IT(&huart1, &rx_byte, 1);
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
// Send a heartbeat message every second
|
||||||
|
char heartbeat[] = "Ping\r\n";
|
||||||
|
HAL_UART_Transmit(&huart1, (uint8_t*)heartbeat, sizeof(heartbeat)-1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
|
HAL_Delay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Error handler
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
|
while (1) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// UART1 initialization (38400 baud)
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
static void MX_USART1_UART_Init(void)
|
||||||
|
{
|
||||||
|
huart1.Instance = USART1;
|
||||||
|
huart1.Init.BaudRate = 38400;
|
||||||
|
huart1.Init.WordLength = UART_WORDLENGTH_8B;
|
||||||
|
huart1.Init.StopBits = UART_STOPBITS_1;
|
||||||
|
huart1.Init.Parity = UART_PARITY_NONE;
|
||||||
|
huart1.Init.Mode = UART_MODE_TX_RX;
|
||||||
|
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
|
||||||
|
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
|
||||||
|
|
||||||
|
if (HAL_UART_Init(&huart1) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// GPIO for UART1 pins (PA9 TX, PA10 RX)
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
static void MX_GPIO_Init(void)
|
||||||
|
{
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
|
|
||||||
|
GPIO_InitTypeDef GPIO_InitStruct = {0};
|
||||||
|
|
||||||
|
// PA9 -> USART1_TX (Alternate Function Push-Pull)
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_9;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
// PA10 -> USART1_RX (Input)
|
||||||
|
GPIO_InitStruct.Pin = GPIO_PIN_10;
|
||||||
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Interrupt callback for UART receive
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||||
|
{
|
||||||
|
if (huart->Instance == USART1) {
|
||||||
|
|
||||||
|
// Echo received byte back
|
||||||
|
HAL_UART_Transmit(&huart1, &rx_byte, 1, HAL_MAX_DELAY);
|
||||||
|
|
||||||
|
// Re-enable reception of next byte
|
||||||
|
HAL_UART_Receive_IT(&huart1, &rx_byte, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
// Basic system clock (HSE not required for 38400 UART)
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
|
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
|
||||||
|
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
|
||||||
|
|
||||||
|
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
|
||||||
|
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||||
|
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
|
||||||
|
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
|
||||||
|
HAL_RCC_OscConfig(&RCC_OscInitStruct);
|
||||||
|
|
||||||
|
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK |
|
||||||
|
RCC_CLOCKTYPE_SYSCLK |
|
||||||
|
RCC_CLOCKTYPE_PCLK1 |
|
||||||
|
RCC_CLOCKTYPE_PCLK2;
|
||||||
|
|
||||||
|
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
|
||||||
|
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
|
||||||
|
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||||
|
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
|
|
||||||
// UART2 (PA3 = RX, PA2 = TX)
|
|
||||||
HardwareSerial mdSerial(PA10, PA9);
|
|
||||||
// HardwareSerial sigma(PA9, )
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
|
|
||||||
mdSerial.begin(38400);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
mdSerial.write("skibidi");
|
|
||||||
|
|
||||||
delay(5000); // wait before next loop
|
|
||||||
}
|
|
||||||
24
STM32_CONTROL/tmp/test.cpp
Normal file
24
STM32_CONTROL/tmp/test.cpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
// #include <Arduino.h>
|
||||||
|
#include <stm32f1xx_hal.h>
|
||||||
|
#define PIN_SERIAL3_RX PB11
|
||||||
|
#define PIN_SERIAL3_TX PB10
|
||||||
|
|
||||||
|
// UART2 (PA3 = RX, PA2 = TX)
|
||||||
|
HardwareSerial Serial1(PA10, PA9);
|
||||||
|
// HardwareSerial sigma(PA9, )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
|
||||||
|
Serial1.begin(38400);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
Serial1.write("skibidi");
|
||||||
|
|
||||||
|
delay(5000); // wait before next loop
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
232
dashboard.json
Normal file
232
dashboard.json
Normal file
@@ -0,0 +1,232 @@
|
|||||||
|
{
|
||||||
|
"annotations": {
|
||||||
|
"list": [
|
||||||
|
{
|
||||||
|
"builtIn": 1,
|
||||||
|
"datasource": {
|
||||||
|
"type": "grafana",
|
||||||
|
"uid": "-- Grafana --"
|
||||||
|
},
|
||||||
|
"enable": true,
|
||||||
|
"hide": true,
|
||||||
|
"iconColor": "rgba(0, 211, 255, 1)",
|
||||||
|
"name": "Annotations & Alerts",
|
||||||
|
"type": "dashboard"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 0,
|
||||||
|
"id": 38,
|
||||||
|
"links": [],
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"collapsed": false,
|
||||||
|
"gridPos": {
|
||||||
|
"h": 1,
|
||||||
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 0
|
||||||
|
},
|
||||||
|
"id": 2,
|
||||||
|
"panels": [],
|
||||||
|
"title": "MD1200-1",
|
||||||
|
"type": "row"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "bdp80jf4cy328f"
|
||||||
|
},
|
||||||
|
"fieldConfig": {
|
||||||
|
"defaults": {
|
||||||
|
"color": {
|
||||||
|
"mode": "palette-classic"
|
||||||
|
},
|
||||||
|
"custom": {
|
||||||
|
"axisBorderShow": false,
|
||||||
|
"axisCenteredZero": false,
|
||||||
|
"axisColorMode": "text",
|
||||||
|
"axisLabel": "",
|
||||||
|
"axisPlacement": "auto",
|
||||||
|
"barAlignment": 0,
|
||||||
|
"barWidthFactor": 0.6,
|
||||||
|
"drawStyle": "line",
|
||||||
|
"fillOpacity": 0,
|
||||||
|
"gradientMode": "none",
|
||||||
|
"hideFrom": {
|
||||||
|
"legend": false,
|
||||||
|
"tooltip": false,
|
||||||
|
"viz": false
|
||||||
|
},
|
||||||
|
"insertNulls": false,
|
||||||
|
"lineInterpolation": "linear",
|
||||||
|
"lineWidth": 1,
|
||||||
|
"pointSize": 5,
|
||||||
|
"scaleDistribution": {
|
||||||
|
"type": "linear"
|
||||||
|
},
|
||||||
|
"showPoints": "auto",
|
||||||
|
"spanNulls": false,
|
||||||
|
"stacking": {
|
||||||
|
"group": "A",
|
||||||
|
"mode": "none"
|
||||||
|
},
|
||||||
|
"thresholdsStyle": {
|
||||||
|
"mode": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"mappings": [],
|
||||||
|
"thresholds": {
|
||||||
|
"mode": "absolute",
|
||||||
|
"steps": [
|
||||||
|
{
|
||||||
|
"color": "green"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": 80
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"unit": "celsius"
|
||||||
|
},
|
||||||
|
"overrides": [
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "Average {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "Average"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "Backplane1 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "Backplane 1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "Backplane2 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "Backplane 2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "Expander0 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "Expander 0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "Expander1 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "Expander 1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "SASIntModule0 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "SAS interface module 0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"matcher": {
|
||||||
|
"id": "byName",
|
||||||
|
"options": "SASIntModule1 {LOCATION=\"HQ\", MACHINE=\"CHONGUS1200\"}"
|
||||||
|
},
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"id": "displayName",
|
||||||
|
"value": "SAS interface module 1"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gridPos": {
|
||||||
|
"h": 10,
|
||||||
|
"w": 24,
|
||||||
|
"x": 0,
|
||||||
|
"y": 1
|
||||||
|
},
|
||||||
|
"id": 1,
|
||||||
|
"options": {
|
||||||
|
"legend": {
|
||||||
|
"calcs": [],
|
||||||
|
"displayMode": "list",
|
||||||
|
"placement": "bottom",
|
||||||
|
"showLegend": true
|
||||||
|
},
|
||||||
|
"tooltip": {
|
||||||
|
"hideZeros": false,
|
||||||
|
"mode": "single",
|
||||||
|
"sort": "none"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"pluginVersion": "12.0.2",
|
||||||
|
"targets": [
|
||||||
|
{
|
||||||
|
"datasource": {
|
||||||
|
"type": "influxdb",
|
||||||
|
"uid": "bdp80jf4cy328f"
|
||||||
|
},
|
||||||
|
"query": "from(bucket: \"JBOD\")\n |> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n |> filter(fn: (r) => r[\"_measurement\"] == \"MD1200-script\")\n |> filter(fn: (r) => r[\"LOCATION\"] == \"HQ\")\n |> filter(fn: (r) => r[\"MACHINE\"] == \"CHONGUS1200\")\n |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)\n |> yield(name: \"mean\")",
|
||||||
|
"refId": "A"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "Temperatures",
|
||||||
|
"type": "timeseries"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preload": false,
|
||||||
|
"schemaVersion": 41,
|
||||||
|
"tags": [],
|
||||||
|
"templating": {
|
||||||
|
"list": []
|
||||||
|
},
|
||||||
|
"time": {
|
||||||
|
"from": "now-3h",
|
||||||
|
"to": "now"
|
||||||
|
},
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "JBODs",
|
||||||
|
"uid": "1ee6cf76-943c-45e0-8d6f-c92db9691459",
|
||||||
|
"version": 3
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user