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

Userland app for distance sensor #463

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cristianaprecup
Copy link

@cristianaprecup cristianaprecup commented Aug 5, 2024

This pull request adds an app that provides a simple interface to read measurements from a connected distance sensor
(tock/tock#4138).

Files added:

libtock_sync/sensors/distance.c
libtock_sync/sensors/distance.h
libtock/sensors/syscalls/distance_syscalls.c
libtock/sensors/syscalls/distance_syscalls.h
libtock/sensors/distance.c
libtock/sensors/distance.h

File modified:

examples/sensors/main.c

//
// A returncode indicating whether the distance read was completed
// successfully.
returncode_t libtocksync_distance_read(int* distance);
Copy link
Contributor

Choose a reason for hiding this comment

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

These function do not have an async version, I would place them only on libtock/sensors.


int libtock_distance_get_maximum_distance(void) {
return command(DRIVER_NUM_DISTANCE, 3, 0, 0).data[0];
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a newline.

returncode_t libtock_distance_set_upcall(subscribe_upcall callback, void* opaque);

// Initiate an ambient distance measurement.
returncode_t libtock_distance_command_read(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
returncode_t libtock_distance_command_read(void);
returncode_t libtock_distance_read(void);

return tock_subscribe_return_to_returncode(sval);
}

returncode_t libtock_distance_command_read(void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
returncode_t libtock_distance_command_read(void) {
returncode_t libtock_distance_read(void) {

Comment on lines +13 to +15
returncode_t ret;

ret = libtock_distance_set_upcall(distance_upcall, cb);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
returncode_t ret;
ret = libtock_distance_set_upcall(distance_upcall, cb);
returncode_t ret = libtock_distance_set_upcall(distance_upcall, cb);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants