• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pybricks / pybricks-micropython / 19016791193

02 Nov 2025 06:40PM UTC coverage: 57.167% (-2.6%) from 59.744%
19016791193

Pull #406

github

laurensvalk
bricks/virtualhub: Replace with embedded simulation.

Instead of using the newly introduced simhub alongside the virtualhub, we'll just replace the old one entirely now that it has reached feature parity. We can keep calling it the virtualhub.
Pull Request #406: New virtual hub for more effective debugging

41 of 48 new or added lines in 7 files covered. (85.42%)

414 existing lines in 53 files now uncovered.

4479 of 7835 relevant lines covered (57.17%)

17178392.75 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/lib/pbio/src/motor_process.c
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2018-2025 The Pybricks Authors
3

4
#include <pbdrv/clock.h>
5

6
#include <pbio/control.h>
7
#include <pbio/drivebase.h>
8
#include <pbio/servo.h>
9

10
#include <pbio/os.h>
11

12
#if PBIO_CONFIG_MOTOR_PROCESS != 0
13

14
static pbio_os_process_t pbio_motor_process;
15

16
static pbio_error_t pbio_motor_process_thread(pbio_os_state_t *state, void *context) {
131,582✔
17

18
    static pbio_os_timer_t timer;
19

20
    PBIO_OS_ASYNC_BEGIN(state);
131,582✔
21

22
    timer.start = pbdrv_clock_get_ms() - PBIO_CONFIG_CONTROL_LOOP_TIME_MS;
36✔
23
    timer.duration = PBIO_CONFIG_CONTROL_LOOP_TIME_MS;
36✔
24

25
    for (;;) {
26
        // Update drivebase
27
        pbio_drivebase_update_all();
26,944✔
28

29
        // Update servos
30
        pbio_servo_update_all();
26,944✔
31

32
        // Increment start time instead waiting from here, making the
33
        // loop time closer to the target on average.
34
        timer.start += PBIO_CONFIG_CONTROL_LOOP_TIME_MS;
26,944✔
35

36
        // In the rare case that polling was delayed too long, we need to
37
        // ensure that the next poll is a minimum of 1ms in the future so we
38
        // don't have 0 time deltas in the control code.
39
        while (pbio_os_timer_is_expired(&timer)) {
26,944✔
UNCOV
40
            timer.start++;
×
41
        }
42

43
        PBIO_OS_AWAIT_UNTIL(state, pbio_os_timer_is_expired(&timer));
158,490✔
44
    }
45

46
    // Unreachable.
UNCOV
47
    PBIO_OS_ASYNC_END(PBIO_ERROR_FAILED);
×
48
}
49

50
void pbio_motor_process_start(void) {
36✔
51
    pbio_os_process_start(&pbio_motor_process, pbio_motor_process_thread, NULL);
36✔
52
}
36✔
53

54
#endif // PBIO_CONFIG_MOTOR_PROCESS
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc