Skip to content
Snippets Groups Projects
Commit 2c5977f3 authored by Dónal Murray's avatar Dónal Murray
Browse files

Merge branch 'master' of https://github.com/hev-sw/hev-sw

parents 8edb09d1 31784b6e
Branches
No related merge requests found
......@@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = uno
default_envs = yun
[env]
lib_deps =
......
......@@ -6,11 +6,11 @@
int ventilation_mode = HEV_MODE_PS;
const uint16_t report_freq = 1 ; // in Hz
const uint16_t report_freq = 5 ; // in Hz
const uint16_t update_freq = 100 ; // in Hz
uint16_t report_cnt = 0;
float working_pressure = 1; //?
float inspiratory_minute_volume = 6000; // ml/min
float respiratory_rate = 15; // 10-40 +-1 ;aka breaths_per_min
......@@ -92,6 +92,7 @@ void setup()
pinMode(pin_buzzer, OUTPUT);
pinMode(pin_button_0, INPUT);
while (!Serial) ;
comms.beginSerial();
}
......@@ -113,8 +114,8 @@ void loop()
data.readback_valve_inhale = vinhale;
data.readback_valve_exhale = vexhale;
data.readback_valve_purge = vpurge;
data.pressure_o2_supply = freeMemory() & 0xFFFF;
data.pressure_o2_regulated = freeMemory() >> 16;
// data.pressure_o2_supply = freeMemory() & 0xFFFF;
// data.pressure_o2_regulated = freeMemory() >> 16;
// TODO ; add to dataFormat
// data.readback_valve_atmosphere = vpurge;
......@@ -131,6 +132,7 @@ void loop()
// per cycle sender
comms.sender();
// per cycle receiver
comms.receiver();
uint8_t cmdCode = 0;
......@@ -139,7 +141,6 @@ void loop()
cmdCode = (plReceive.getCmd()->cmdCode);
plReceive.setType(payloadType::payloadUnset);
}
}
switch(cmdCode){
......
......@@ -27,8 +27,8 @@ void FSM_assignment( ) {
{
case BS_IDLE:
if (running == true) {
// FSM_time = millis();
next_state = BS_BUFF_PREFILL;
FSM_time = millis();
// Serial.println("Exit IDLE") ;
} else {
next_state = BS_IDLE;
......@@ -100,7 +100,7 @@ void FSM_breath_cycle()
case BS_IDLE:
if (running == true) {
FSM_time = millis();
// FSM_time = millis();
} else {
timeout = 1000;
}
......@@ -177,4 +177,9 @@ void do_start()
void do_stop()
{
running = false;
}
bool get_running()
{
return running;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ void FSM_assignment();
void FSM_breath_cycle();
void do_start();
void do_stop();
bool get_running();
// states
enum BS_STATES : byte
......
......@@ -132,7 +132,7 @@ void commsControl::receiver() {
lastTransIndex_ = 0;
}
}
}
}
}
bool commsControl::writePayload(payload &pl) {
......@@ -246,7 +246,7 @@ void commsControl::sendPacket(commsFormat *packet) {
if (encoder(packet->getData(), packet->getSize()) ) {
if (Serial.availableForWrite() >= commsSendSize_) {
Serial.write(commsSend_, commsSendSize_);
}
}
}
}
......
......@@ -100,7 +100,8 @@ void loop() {
// per cycle sender
comms_.sender();
// per cycle receiver
comms_.receiver();
int x1, x2, x3 = 0;
comms_.receiver(x1,x2,x3);
if (comms_.readPayload(plReceive_)) {
......
......@@ -15,7 +15,7 @@ from collections import deque
import binascii
import logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
# communication class that governs talking between devices
......
......@@ -17,6 +17,8 @@ class Dependant(object):
def update_llipacket(self, payload):
logging.info(f"payload received: {payload}")
#logging.info(f"payload received: {payload._fsm_state}")
#logging.info(f"payload received: {payload._readback_valve_o2_in} {payload._readback_valve_inhale} {payload._readback_valve_exhale} {payload._readback_valve_purge} {payload._fsm_state}")
self._llipacket = payload.getDict() # returns a dict
# pop from queue - protects against Dependant going down and not receiving packets
self._lli.pop_payloadrecv()
......@@ -28,12 +30,14 @@ stop = 0x2
# initialise as start command, automatically executes toByteArray()
cmd = commandFormat(cmdCode=start)
time.sleep(4)
comms.writePayload(cmd)
#comms.sender()
print('sent cmd start')
while True:
time.sleep(30)
time.sleep(20)
cmd.cmdCode = stop # automatically executes toByteArray()
comms.writePayload(cmd)
#comms.registerData(stop)
print('sent cmd stop')
pass
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment