Skip to content

Commit

Permalink
Merge #177
Browse files Browse the repository at this point in the history
177: Tock 2.0 switchover r=hudson-ayers a=phil-levis

This PR 
1. removes the Tock 1.0 system calls from tock.c,
2. changes `subscribe_cb` to `subscribe_upcall`
3. updates `driver_exists` to use `command2`

It **does not** yet change the names (e.g., `command2` to `command`). This because many userspace libraries have not been ported to the new system calls:

- [x] tsl2561 @ppannuto #182
- [x] temperature @phil-levis #178 
- [x] ~aes~ 
- [x] ~st7735~ #185 
- [x] pca9544a @alevy 
- [x] lsm303dlhc #191 @alexandruradovici 
- [x] usb @alistair23 #189 
- [x] ~console~ (minor, fixed in this PR) @phil-levis #177 
- [x] proximity @alevy  #181
- [x] ltc294x @alevy #180 
- [x] ~tmp006~ #184 
- [x] l3gd20 #192 @alexandruradovici 
- [x] lps35hb #187 
- [x] humidity @phil-levis #178 
- [x] max17205 #183 
- [x] ipc @alevy #176, #177

This causes an undefined symbol when compiling, so libtock-c is not usable/linkable. But it does compile. As these are fixed, tested, and pushed to `tock-2.0-dev`, I will keep this branch up to date and unblock it when it is ready.

Co-authored-by: Philip Levis <pal@cs.stanford.edu>
Co-authored-by: Hudson Ayers <hayers@stanford.edu>
  • Loading branch information
3 people committed Feb 25, 2021
2 parents e876f64 + ea02b71 commit bcc6357
Show file tree
Hide file tree
Showing 94 changed files with 358 additions and 921 deletions.
6 changes: 3 additions & 3 deletions examples/rot13_client/main.c
Expand Up @@ -19,7 +19,7 @@ static void rot13_callback(__attribute__ ((unused)) int pid,
struct rot13_buf *rb = (struct rot13_buf*)ud;
printf("%d: %.*s\n", rb->length, rb->length, rb->buf);
delay_ms(500);
ipc_notify_svc(rot13_svc_num);
ipc_notify_service(rot13_svc_num);
}

int main(void) {
Expand All @@ -30,12 +30,12 @@ int main(void) {
}

struct rot13_buf *rb = (struct rot13_buf*)buf;
ipc_register_client_cb(rot13_svc_num, rot13_callback, rb);
ipc_register_client_callback(rot13_svc_num, rot13_callback, rb);

rb->length = snprintf(rb->buf, sizeof(rb->buf), "Hello World!");
ipc_share(rot13_svc_num, rb, 64);

ipc_notify_svc(rot13_svc_num);
ipc_notify_service(rot13_svc_num);
return 0;
}

2 changes: 1 addition & 1 deletion examples/rot13_service/main.c
Expand Up @@ -23,7 +23,7 @@ static void rot13_callback(int pid, int len, int buf, __attribute__ ((unused)) v
}

int main(void) {
ipc_register_svc(rot13_callback, NULL);
ipc_register_service_callback(rot13_callback, NULL);
return 0;
}

12 changes: 2 additions & 10 deletions examples/sensors/main.c
Expand Up @@ -9,14 +9,10 @@
#include <sound_pressure.h>
#include <temperature.h>
#include <timer.h>
#include <tmp006.h>
#include <tock.h>
#include <tsl2561.h>

static bool isl29035 = false;
// TODO: modify tmp006 to comply with the generic temperature interface
// and then remove tmp006!!!
static bool tmp006 = false;
static bool isl29035 = false;
static bool tsl2561 = false;
static bool lps25hb = false;
static bool temperature = false;
Expand All @@ -33,7 +29,6 @@ static void timer_fired(__attribute__ ((unused)) int arg0,
__attribute__ ((unused)) int arg2,
__attribute__ ((unused)) void* ud) {
int light = 0;
int16_t tmp006_temp = 0;
int tsl2561_lux = 0;
int lps25hb_pressure = 0;
int temp = 0;
Expand All @@ -46,7 +41,6 @@ static void timer_fired(__attribute__ ((unused)) int arg0,

/* *INDENT-OFF* */
if (isl29035) ambient_light_read_intensity_sync(&light);
if (tmp006) tmp006_read_sync(&tmp006_temp);
if (tsl2561) tsl2561_lux = tsl2561_get_lux_sync();
if (lps25hb) lps25hb_pressure = lps25hb_get_pressure_sync();
if (temperature) temperature_read_sync(&temp);
Expand All @@ -58,7 +52,6 @@ static void timer_fired(__attribute__ ((unused)) int arg0,
if (sound_pressure) sound_pressure_read_sync(&sound_pressure_reading);

if (isl29035) printf("ISL29035: Light Intensity: %d\n", light);
if (tmp006) printf("TMP006: Temperature: %d\n", tmp006_temp);
if (tsl2561) printf("TSL2561: Light: %d lux\n", tsl2561_lux);
if (lps25hb) printf("LPS25HB: Pressure: %d\n", lps25hb_pressure);
if (temp) printf("Temperature: %d deg C\n", temp/100);
Expand All @@ -79,7 +72,6 @@ int main(void) {
printf("[Sensors] All available sensors on the platform will be sampled.\n");

isl29035 = driver_exists(DRIVER_NUM_AMBIENT_LIGHT);
tmp006 = driver_exists(DRIVER_NUM_TMP006);
tsl2561 = driver_exists(DRIVER_NUM_TSL2561);
lps25hb = driver_exists(DRIVER_NUM_LPS25HB);
temperature = driver_exists(DRIVER_NUM_TEMPERATURE);
Expand All @@ -104,4 +96,4 @@ int main(void) {
timer_every(1000, timer_fired, NULL, &timer);

return 0;
}
}
2 changes: 1 addition & 1 deletion examples/services/ble-env-sense/main.c
Expand Up @@ -127,7 +127,7 @@ int main (void) {
printf("[BLE] Environmental Sensing IPC Service\n");

// Listen for IPC requests to configure the sensor values.
ipc_register_svc(ipc_callback, NULL);
ipc_register_service_callback(ipc_callback, NULL);

// Setup BLE
conn_handle = simple_ble_init(&ble_config)->conn_handle;
Expand Down
8 changes: 4 additions & 4 deletions examples/services/ble-env-sense/test-with-sensors/main.c
Expand Up @@ -51,7 +51,7 @@ static void do_sensing_cb(__attribute__ ((unused)) int now,

update->type = SENSOR_IRRADIANCE;
update->value = light;
ipc_notify_svc(_svc_num);
ipc_notify_service(_svc_num);
_ipc_done = false;
yield_for(&_ipc_done);
}
Expand All @@ -61,7 +61,7 @@ static void do_sensing_cb(__attribute__ ((unused)) int now,

update->type = SENSOR_TEMPERATURE;
update->value = temp;
ipc_notify_svc(_svc_num);
ipc_notify_service(_svc_num);
_ipc_done = false;
yield_for(&_ipc_done);
}
Expand All @@ -71,7 +71,7 @@ static void do_sensing_cb(__attribute__ ((unused)) int now,

update->type = SENSOR_HUMIDITY;
update->value = humi;
ipc_notify_svc(_svc_num);
ipc_notify_service(_svc_num);
_ipc_done = false;
yield_for(&_ipc_done);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ int main(void) {
delay_ms(1500);

sensor_update_t *update = (sensor_update_t*) buf;
ipc_register_client_cb(_svc_num, ipc_callback, update);
ipc_register_client_callback(_svc_num, ipc_callback, update);
ipc_share(_svc_num, buf, 64);

timer_in(1000, do_sensing_cb, NULL, &_timer);
Expand Down
4 changes: 2 additions & 2 deletions examples/services/ble-env-sense/test/main.c
Expand Up @@ -38,12 +38,12 @@ int main(void) {
delay_ms(1500);

sensor_update_t *update = (sensor_update_t*) buf;
ipc_register_client_cb(_svc_num, ipc_callback, update);
ipc_register_client_callback(_svc_num, ipc_callback, update);

update->type = SENSOR_HUMIDITY;
update->value = 185;
ipc_share(_svc_num, buf, 64);

ipc_notify_svc(_svc_num);
ipc_notify_service(_svc_num);
return 0;
}
2 changes: 1 addition & 1 deletion examples/tests/callback_remove_test01/main.c
Expand Up @@ -28,7 +28,7 @@ int main(void) {
uint32_t frequency = alarm_internal_frequency();
uint32_t interval = (500 / 1000) * frequency + (500 % 1000) * (frequency / 1000);
uint32_t now = alarm_read();
alarm_internal_subscribe((subscribe_cb*) cb, NULL);
alarm_internal_subscribe((subscribe_upcall*) cb, NULL);
alarm_internal_set(now, interval);

// Now block in this app for a while. This should give the timer time to
Expand Down
11 changes: 0 additions & 11 deletions examples/tests/tmp006/Makefile

This file was deleted.

90 changes: 0 additions & 90 deletions examples/tests/tmp006/main.c

This file was deleted.

2 changes: 1 addition & 1 deletion examples/tutorials/05_ipc/led/main.c
Expand Up @@ -56,6 +56,6 @@ int main(void) {
// First get the number of LEDs setup on this board.
_number_of_leds = led_count();

ipc_register_svc(ipc_callback, NULL);
ipc_register_service_callback(ipc_callback, NULL);
return 0;
}
10 changes: 5 additions & 5 deletions examples/tutorials/05_ipc/logic/main.c
Expand Up @@ -27,7 +27,7 @@ static void ipc_callback(__attribute__ ((unused)) int pid,
static uint8_t get_number_of_leds(void) {
_done = false;
_led_buf[0] = 0;
ipc_notify_svc(_led_service);
ipc_notify_service(_led_service);
yield_for(&_done);

return _led_buf[0];
Expand All @@ -40,15 +40,15 @@ static void set_led(uint8_t led_index, uint8_t led_state) {
_led_buf[1] = led_index; // Choose the LED.
_led_buf[2] = led_state; // Set the LED.
_done = false;
ipc_notify_svc(_led_service);
ipc_notify_service(_led_service);
yield_for(&_done);
}

// Use the RNG service to get two random bytes.
static uint16_t get_two_random_bytes(void) {
_done = false;
_rng_buf[0] = 2;
ipc_notify_svc(_rng_service);
ipc_notify_service(_rng_service);
yield_for(&_done);

return (_rng_buf[0] << 8) | _rng_buf[1];
Expand All @@ -63,7 +63,7 @@ int main(void) {
}

// Setup IPC for LED service
ipc_register_client_cb(_led_service, ipc_callback, NULL);
ipc_register_client_callback(_led_service, ipc_callback, NULL);
ipc_share(_led_service, _led_buf, 64);

// Retrieve a handle to the RNG service.
Expand All @@ -74,7 +74,7 @@ int main(void) {
}

// Setup IPC for RNG service
ipc_register_client_cb(_rng_service, ipc_callback, NULL);
ipc_register_client_callback(_rng_service, ipc_callback, NULL);
ipc_share(_rng_service, _rng_buf, 64);

// First need to get the number of LEDs.
Expand Down
2 changes: 1 addition & 1 deletion examples/tutorials/05_ipc/rng/main.c
Expand Up @@ -51,6 +51,6 @@ static void ipc_callback(int pid, int len, int buf, __attribute__ ((unused)) voi
int main(void) {
// Register the IPC service for this app. It is identified by the PACKAGE_NAME
// of this app.
ipc_register_svc(ipc_callback, NULL);
ipc_register_service_callback(ipc_callback, NULL);
return 0;
}

0 comments on commit bcc6357

Please sign in to comment.