sensor_angle: No need to send messages when stopping queries

Simplify the mcu code as any messages are ignored by the host anyway.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2023-12-17 11:35:40 -05:00
parent 95e1a290f1
commit dc6182f3b3
2 changed files with 4 additions and 10 deletions

View File

@ -437,7 +437,7 @@ class Angle:
self.oid = oid = mcu.create_oid() self.oid = oid = mcu.create_oid()
self.sensor_helper = sensor_class(config, self.spi, oid) self.sensor_helper = sensor_class(config, self.spi, oid)
# Setup mcu sensor_spi_angle bulk query code # Setup mcu sensor_spi_angle bulk query code
self.query_spi_angle_cmd = self.query_spi_angle_end_cmd = None self.query_spi_angle_cmd = None
mcu.add_config_cmd( mcu.add_config_cmd(
"config_spi_angle oid=%d spi_oid=%d spi_angle_type=%s" "config_spi_angle oid=%d spi_oid=%d spi_angle_type=%s"
% (oid, self.spi.get_oid(), sensor_type)) % (oid, self.spi.get_oid(), sensor_type))
@ -462,9 +462,6 @@ class Angle:
self.query_spi_angle_cmd = self.mcu.lookup_command( self.query_spi_angle_cmd = self.mcu.lookup_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c", "query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
cq=cmdqueue) cq=cmdqueue)
self.query_spi_angle_end_cmd = self.mcu.lookup_query_command(
"query_spi_angle oid=%c clock=%u rest_ticks=%u time_shift=%c",
"spi_angle_end oid=%c sequence=%hu", oid=self.oid, cq=cmdqueue)
def get_status(self, eventtime=None): def get_status(self, eventtime=None):
return {'temperature': self.sensor_helper.last_temperature} return {'temperature': self.sensor_helper.last_temperature}
def add_client(self, client_cb): def add_client(self, client_cb):
@ -543,7 +540,7 @@ class Angle:
self.time_shift], reqclock=reqclock) self.time_shift], reqclock=reqclock)
def _finish_measurements(self): def _finish_measurements(self):
# Halt bulk reading # Halt bulk reading
params = self.query_spi_angle_end_cmd.send([self.oid, 0, 0, 0]) self.query_spi_angle_cmd.send_wait_ack([self.oid, 0, 0, 0])
self.bulk_queue.clear_samples() self.bulk_queue.clear_samples()
self.sensor_helper.last_temperature = None self.sensor_helper.last_temperature = None
logging.info("Stopped angle '%s' measurements", self.name) logging.info("Stopped angle '%s' measurements", self.name)

View File

@ -230,13 +230,10 @@ command_query_spi_angle(uint32_t *args)
sched_del_timer(&sa->timer); sched_del_timer(&sa->timer);
sa->flags = 0; sa->flags = 0;
if (!args[2]) { if (!args[2])
// End measurements // End measurements
if (sa->data_count)
angle_report(sa, oid);
sendf("spi_angle_end oid=%c sequence=%hu", oid, sa->sequence);
return; return;
}
// Start new measurements query // Start new measurements query
sa->timer.waketime = args[1]; sa->timer.waketime = args[1];
sa->rest_ticks = args[2]; sa->rest_ticks = args[2];