Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update temperature and humidity to use 2.0 API #178

Merged
merged 6 commits into from Feb 24, 2021
Merged

Conversation

phil-levis
Copy link
Contributor

In porting over the capsules, somehow the libtock-c parts were missed for temperature and humidity. This updates them to the 2.0 syscall API. Part of #177

@phil-levis phil-levis mentioned this pull request Feb 20, 2021
16 tasks
@bradjc bradjc added the tock-2.0 Pull request is part of the transition to Tock 2.0 label Feb 22, 2021
Copy link
Member

@ppannuto ppannuto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic looks fine, but this seems to inconsistently change things from callback to upcall -- I don't really have strong feelings about which word we use, but currently "callback" is the term used throughout most of libtock-c, if we're going to change names, I think we should do it consistently rather than have a mix of terms (inviting the question: what is the difference between a callback and an upcall?)

libtock/humidity.c Outdated Show resolved Hide resolved
@bradjc
Copy link
Contributor

bradjc commented Feb 24, 2021

I think it makes sense to call what happens when a capsule calls .schedule() an upcall. That differentiates it from a .set_client()-based callback.

I don't think that means we should automatically rename libtock-c, however. The API and terminology presented to userspace applications using libtock-c does not need to be based on the terminology of the kernel. Callbacks in a main.c file look like any other callback in any other language, and renaming them to upcalls is I think unnecessarily adding complexity. Whether they are the direct result of a kernel upcall or come from more software layers in libtock-c (alarms are a good example of this) is not really a concern of an app developer, to them it just looks like a callback.

Changing subscribe() to take an upcall function pointer makes sense, but I don't think we should change the libtock-c APIs to upcall at the same time.

@phil-levis
Copy link
Contributor Author

phil-levis commented Feb 24, 2021

I think it's good if the libtock-c function names say "callback" rather than "upcall"; as you point out, they might be software-only and so not actually be an upcall. "callback" is the superset so it gives implementation flexibility.

But what about the typedef for an argument to subscribe? If we keep it as is, such that applications pass subscribe_upcall function pointers, the name upcall leaks out.

The clean way to do this is for a libtock-c library to filter the upcall into a callback. While the upcall provides 4 arguments, for example, it might be the callback only has 2. So the type you pass to a subscribe is a subscribe_upcall but the type you pass to humidity_set_callback is a function pointer with a single argument, the humidity value.

direct function call passed to subscribe.

So the internal functions in temperature.c and humidity.c that
are passed to subscribe() are called upcalls, but arbitrary
function pointers passed from userpsace are called callbacks.
This way the API doesn't say whether it's an upcall or not,
but the internal implementation knows its own function is so
calls it such.
@phil-levis phil-levis dismissed ppannuto’s stale review February 24, 2021 19:37

Changed it back to callback as suggested.

@phil-levis
Copy link
Contributor Author

bors r+

@bors
Copy link
Contributor

bors bot commented Feb 24, 2021

Build succeeded:

@bors bors bot merged commit e876f64 into tock-2.0-dev Feb 24, 2021
@bors bors bot deleted the sensors_2.0 branch February 24, 2021 19:50
bors bot added a commit that referenced this pull request Feb 25, 2021
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>
bors bot added a commit that referenced this pull request Feb 25, 2021
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>
tyler-potyondy pushed a commit to tyler-potyondy/libtock-c that referenced this pull request Mar 13, 2024
178: Update temperature and humidity to use 2.0 API r=phil-levis a=phil-levis

In porting over the capsules, somehow the libtock-c parts were missed for temperature and humidity. This updates them to the 2.0 syscall API. Part of tock#177 

Co-authored-by: Philip Levis <pal@cs.stanford.edu>
tyler-potyondy pushed a commit to tyler-potyondy/libtock-c that referenced this pull request Mar 13, 2024
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 tock#182
- [x] temperature @phil-levis tock#178 
- [x] ~aes~ 
- [x] ~st7735~ tock#185 
- [x] pca9544a @alevy 
- [x] lsm303dlhc tock#191 @alexandruradovici 
- [x] usb @alistair23 tock#189 
- [x] ~console~ (minor, fixed in this PR) @phil-levis tock#177 
- [x] proximity @alevy  tock#181
- [x] ltc294x @alevy tock#180 
- [x] ~tmp006~ tock#184 
- [x] l3gd20 tock#192 @alexandruradovici 
- [x] lps35hb tock#187 
- [x] humidity @phil-levis tock#178 
- [x] max17205 tock#183 
- [x] ipc @alevy tock#176, tock#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tock-2.0 Pull request is part of the transition to Tock 2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants