|
RocketLogger
2.0.2
|
#include <errno.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <fcntl.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include "sysfs.h"
Include dependency graph for sysfs.c:Go to the source code of this file.
Macros | |
| #define | SYSFS_STRING_BUFFER_LENGTH 16 |
| String buffer size for dynamic string operations. More... | |
Functions | |
| int | sysfs_export (char const *const sysfs_file, int value) |
| int | sysfs_unexport (char const *const sysfs_file, int value) |
| int | sysfs_is_exported (char const *const sysfs_path) |
| int | sysfs_export_unexported (char const *const sysfs_path, char const *const sysfs_export_file, int value) |
| int | sysfs_unexport_exported (char const *const sysfs_path, char const *const sysfs_unexport_file, int value) |
| int | sysfs_write_string (char const *const sysfs_file, char const *const value) |
| int | sysfs_read_string (char const *const sysfs_file, char *const value, int length) |
| int | sysfs_write_int (char const *const sysfs_file, int value) |
| int | sysfs_read_int (char const *const sysfs_file, int *const value) |
| #define SYSFS_STRING_BUFFER_LENGTH 16 |
String buffer size for dynamic string operations.
Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| int sysfs_export | ( | char const *const | sysfs_file, |
| int | value | ||
| ) |
Copyright (c) 2016-2020, ETH Zurich, Computer Engineering Group All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Export (activate) a sysfs device.
If the ressource is busy an error is returned. You might want to use sysfs_unexport first to make sure a device is deactivated.
| sysfs_file | The sysfs file used to export |
| value | The resource number of the device to export |
Definition at line 50 of file sysfs.c.
References sysfs_write_int().
Referenced by sysfs_export_unexported().
Here is the call graph for this function:| int sysfs_export_unexported | ( | char const *const | sysfs_path, |
| char const *const | sysfs_export_file, | ||
| int | value | ||
| ) |
Export (activate) a sysfs device if it is not exported already.
Returns success immediately if the sysfs device is exported already, otherwise calls and returns sysfs_export result.
| sysfs_path | The sysfs device path to check |
| sysfs_export_file | The sysfs file to use to export |
| value | The resource number of the device to export |
Definition at line 76 of file sysfs.c.
References sysfs_export(), and sysfs_is_exported().
Referenced by pwm_init().
Here is the call graph for this function:| int sysfs_is_exported | ( | char const *const | sysfs_path | ) |
Check wether a sysfs device is exported and fully accessible.
| sysfs_path | The sysfs device path to check |
Definition at line 58 of file sysfs.c.
Referenced by sysfs_export_unexported(), and sysfs_unexport_exported().
| int sysfs_read_int | ( | char const *const | sysfs_file, |
| int *const | value | ||
| ) |
Write an integer to a sysfs device file.
| sysfs_file | The sysfs file to read from |
| value | Pointer to the integer variable to write to |
Definition at line 145 of file sysfs.c.
References sysfs_read_string().
Here is the call graph for this function:| int sysfs_read_string | ( | char const *const | sysfs_file, |
| char *const | value, | ||
| int | length | ||
| ) |
Read a string from a sysfs device file.
| sysfs_file | The sysfs file to read from |
| value | Pointer to the character array to write to |
| length | Max length to the string to read |
Definition at line 121 of file sysfs.c.
Referenced by sysfs_read_int().
| int sysfs_unexport | ( | char const *const | sysfs_file, |
| int | value | ||
| ) |
Unexport (deactivate) a sysfs device.
| sysfs_file | The sysfs file used to unexport |
| value | The resource number of the device to unexport |
Definition at line 54 of file sysfs.c.
References sysfs_write_int().
Referenced by pwm_deinit(), and sysfs_unexport_exported().
Here is the call graph for this function:| int sysfs_unexport_exported | ( | char const *const | sysfs_path, |
| char const *const | sysfs_unexport_file, | ||
| int | value | ||
| ) |
Unexport (deactivate) a sysfs device if it is exported (active).
Returns success immediately if the sysfs device is not exported, otherwise calls and returns sysfs_unexport result.
| sysfs_path | The sysfs device path to check |
| sysfs_unexport_file | The sysfs file to use to unexport |
| value | The resource number of the device to unexport |
Definition at line 91 of file sysfs.c.
References sysfs_is_exported(), and sysfs_unexport().
Here is the call graph for this function:| int sysfs_write_int | ( | char const *const | sysfs_file, |
| int | value | ||
| ) |
Write an integer to a sysfs device file.
| sysfs_file | The sysfs file to write to |
| value | The value to write to write |
Definition at line 136 of file sysfs.c.
Referenced by pwm_deinit(), pwm_init(), sysfs_export(), and sysfs_unexport().