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

pybricks / pybricks-micropython / 9389878479

05 Jun 2024 06:51PM UTC coverage: 56.454%. First build
9389878479

push

github

laurensvalk
pbio/sys: Rename program_load to storage.

This will store program data, user data, and soon system settings. We also previously moved the load part to another file.

So this can just be storage, which is easier to follow. This is a blanket rename that does (should) not change any code.

1 of 14 new or added lines in 4 files covered. (7.14%)

3757 of 6655 relevant lines covered (56.45%)

20258494.24 hits per line

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

52.94
/lib/pbio/sys/command.c
1
// SPDX-License-Identifier: MIT
2
// Copyright (c) 2022-2023 The Pybricks Authors
3

4
#include <assert.h>
5
#include <stdint.h>
6

7
#include <pbdrv/reset.h>
8
#include <pbio/protocol.h>
9

10
#include "./bluetooth.h"
11
#include "./storage.h"
12
#include "./program_stop.h"
13
#include "./user_program.h"
14

15
/**
16
 * Parses binary data for command and dispatches handler for command.
17
 * @param [in]  data    The raw command data.
18
 * @param [in]  size    The size of @p data in bytes.
19
 */
20
pbio_pybricks_error_t pbsys_command(const uint8_t *data, uint32_t size) {
1✔
21
    assert(data);
1✔
22
    assert(size);
1✔
23

24
    pbio_pybricks_command_t cmd = data[0];
1✔
25

26
    switch (cmd) {
1✔
27
        case PBIO_PYBRICKS_COMMAND_STOP_USER_PROGRAM:
28
            pbsys_program_stop(false);
29
            return PBIO_PYBRICKS_ERROR_OK;
30
        case PBIO_PYBRICKS_COMMAND_START_USER_PROGRAM:
31
            return pbio_pybricks_error_from_pbio_error(pbsys_user_program_start_program());
×
32
        case PBIO_PYBRICKS_COMMAND_START_REPL:
33
            return pbio_pybricks_error_from_pbio_error(pbsys_user_program_start_repl());
×
34
        case PBIO_PYBRICKS_COMMAND_WRITE_USER_PROGRAM_META:
×
NEW
35
            return pbio_pybricks_error_from_pbio_error(pbsys_storage_set_program_size(
×
36
                pbio_get_uint32_le(&data[1])));
37
        case PBIO_PYBRICKS_COMMAND_WRITE_USER_RAM:
×
NEW
38
            return pbio_pybricks_error_from_pbio_error(pbsys_storage_set_program_data(
×
39
                pbio_get_uint32_le(&data[1]), &data[5], size - 5));
40
        case PBIO_PYBRICKS_COMMAND_REBOOT_TO_UPDATE_MODE:
41
            pbdrv_reset(PBDRV_RESET_ACTION_RESET_IN_UPDATE_MODE);
42
            return PBIO_PYBRICKS_ERROR_OK;
43
        case PBIO_PYBRICKS_COMMAND_WRITE_STDIN:
1✔
44
            #if PBSYS_CONFIG_BLUETOOTH
45
            if (pbsys_bluetooth_rx_get_free() < size - 1) {
1✔
46
                return PBIO_PYBRICKS_ERROR_BUSY;
47
            }
48
            pbsys_bluetooth_rx_write(&data[1], size - 1);
1✔
49
            #endif
50
            // If no consumers are configured, goes to "/dev/null" without error
51
            return PBIO_PYBRICKS_ERROR_OK;
1✔
52
        default:
×
53
            return PBIO_PYBRICKS_ERROR_INVALID_COMMAND;
×
54
    }
55
}
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