01-15-2023, 04:31 AM
How to inject gps speed into guages
First thing to do is install gpsd clients
Install [b]gpsd_py3 [/b]
Install minicom
use minicom to set up your gps (sim7600) and set to read nema once every 1sec
exit minicom
point gpsd at your gps dev
Exit nano ^X , Y to save
sudo reboot
Check to make sure gpsd is working correctly
in terminal enter
If you have a 2d/3d fix gps is working and gpsd is set up (make sure antena has clear view of sky)
Clone OPA api repository
Open api folder and create odbinjectmph.py copy and save code below
Cd into OAP api folder in terminal and run
Open OAP and check your guages and you should have a working speedometer.
I am no programer and this took quite a bit or work and learning for me to accomplish. im sure there are things i could have done better. feel free to use/change things you think i could have done better or fit your needs better. USE AT YOUR OWN RISK
First thing to do is install gpsd clients
sudo apt install -y gpsd gpsd-clients
Install [b]gpsd_py3 [/b]
pip3 install gpsd-py3
Install minicom
sudo apt install minicom
use minicom to set up your gps (sim7600) and set to read nema once every 1sec
AT+CGPS=1,1
AT+CGPSAUTO=1
at+cgpsinfofg =1,31
exit minicom
point gpsd at your gps dev
sudo nano /etc/default/gpsd
# Default settings for the gpsd init script and the hotplug wrapper.
# Start the gpsd daemon automatically at boot time
START_DAEMON="true"
# Use USB hotplugging to add new USB devices automatically to the daemon
USBAUTO="true"
# Devices gpsd should collect to at boot time.
# They need to be read/writeable, either by user gpsd or the group dialout.
DEVICES= "/dev/ttyUSB*/ttyAMA*" <----- Change to your gps device!!!!!!!!!!!!
# Other options you want to pass to gpsd
GPSD_OPTIONS=""
_______________________________________________________________________________
Exit nano ^X , Y to save
sudo reboot
Check to make sure gpsd is working correctly
in terminal enter
cpgs
If you have a 2d/3d fix gps is working and gpsd is set up (make sure antena has clear view of sky)
Clone OPA api repository
https://github.com/bluewave-studio/openauto-pro-api.git
Open api folder and create odbinjectmph.py copy and save code below
#!/usr/bin/python3
#
#
#
import threading
import time
import gpsd
import Api_pb2 as oap_api
from Client import Client, ClientEventHandler
injecting_active = True
# Connect to the gpsd daemon
gpsd.connect()
def inject_obd_gauge_formula_value(client):
global mph
obd_inject_gauge_formula_value = oap_api.ObdInjectGaugeFormulaValue()
packet = (gpsd.get_current())
while injecting_active:
packet = (gpsd.get_current())
mph = int(packet.hspeed)
obd_inject_gauge_formula_value.formula = 'getPidValue(5)'
obd_inject_gauge_formula_value.value = mph
client.send(oap_api.MESSAGE_OBD_INJECT_GAUGE_FORMULA_VALUE, 0,
obd_inject_gauge_formula_value.SerializeToString())
time.sleep(1)
class EventHandler(ClientEventHandler):
def on_hello_response(self, client, message):
print(
"received hello response, result: {}, oap version: {}.{}, api version: {}.{}"
.format(message.result, message.oap_version.major,
message.oap_version.minor, message.api_version.major,
message.api_version.minor))
threading.Thread(target=inject_obd_gauge_formula_value,
args=(client,)).start()
def main():
client = Client("obd inject example")
event_handler = EventHandler()
client.set_event_handler(event_handler)
client.connect('127.0.0.1', 44405)
active = True
while active:
try:
active = client.wait_for_message()
except KeyboardInterrupt:
break
global injecting_active
injecting_active = False
client.disconnect()
if __name__ == "__main__":
main()
Cd into OAP api folder in terminal and run
python3 obdinjectmph.py
Open OAP and check your guages and you should have a working speedometer.
I am no programer and this took quite a bit or work and learning for me to accomplish. im sure there are things i could have done better. feel free to use/change things you think i could have done better or fit your needs better. USE AT YOUR OWN RISK