|
SBB Host
Host communication with the self balancing bike.
|
A namespace providing utility functions. More...
Classes | |
| struct | hhmmss_t |
| A structure for handling elapsed time in hour, minute, second format. More... | |
Functions | |
| int | filecp (const char FileSource[], const char FileDestination[]) |
| Copy a file. More... | |
| int | getIP_and_subnetmask (uint32_t *ip=nullptr, uint32_t *mask=nullptr, std::string *ip_str=nullptr, std::string *mask_str=nullptr) |
| Get the local IP and subnet mask. More... | |
| uint32_t | get_remoteIP (uint32_t ip, uint32_t mask, std::string *str=nullptr) |
| Get the remote IP. More... | |
| uint32_t | get_broadcastIP (uint32_t ip, uint32_t mask, std::string *str=nullptr) |
| Get the broadcast IP. More... | |
| uint32_t | ip_str2num (std::string ip_str) |
| Convert IP from string to uint32. More... | |
| std::string | hex2str (unsigned int v) |
| Convert HEX from unsigned int to string. More... | |
| bool | str2hex (std::string str, unsigned int *p_v) |
| Convert HEX from string to unsigned int. More... | |
| float | average (std::vector< float > const &v) |
| Get the average of a vector of float. More... | |
| float | rms (std::vector< float > const &v) |
| Get the RMS of a vector of float. More... | |
| std::string | get_home_path () |
| Get the HOME path. More... | |
| void | beep (int mode) |
| Send a beep message. More... | |
| bool | set_env_var (std::string key, std::string val) |
| Set a local environment variable. More... | |
| hhmmss_t | sec2hhmmss (int secs) |
| Convert elapsed seconds to hh::mm:ss format. More... | |
A namespace providing utility functions.
Namespace providing a number of utility functions.
| float utils::average | ( | std::vector< float > const & | v | ) |
Get the average of a vector of float.
Function to get the average of a std::vector<float>.
| void utils::beep | ( | int | mode | ) |
Send a beep message.
Function to send a beep message in Windows. This is just a wrapper of the Windows function MessageBeep(mode). In Linux it does nothing.
| mode | The beep mode to be used. See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep for details. |
| int utils::filecp | ( | const char | FileSource[], |
| const char | FileDestination[] | ||
| ) |
Copy a file.
Robust function to copy file from source to destination.
| FileSource | Char array with the source file path. |
| FileDestination | Char array with the destination file path. |
| uint32_t utils::get_broadcastIP | ( | uint32_t | ip, |
| uint32_t | mask, | ||
| std::string * | str = nullptr |
||
| ) |
Get the broadcast IP.
Function to get the broadcast IP from the local IP and subnet mask.
| ip | Local IP. |
| mask | Subnet mask. |
| str | Pointer where save the broadcast IP in string format (XXX.XXX.XXX.XXX). |
| std::string utils::get_home_path | ( | ) |
Get the HOME path.
Function to get a home path (i.e. HOME in Linux, Documents in Windows). If Documents is not found in Windows, C:\ is used. File separator used is consistent with the operative system.
| uint32_t utils::get_remoteIP | ( | uint32_t | ip, |
| uint32_t | mask, | ||
| std::string * | str = nullptr |
||
| ) |
Get the remote IP.
Function to get the remote IP from the local IP and subnet mask.
| ip | Local IP. |
| mask | Subnet mask. |
| str | Pointer where save the remote IP in string format (XXX.XXX.XXX.XXX). |
| int utils::getIP_and_subnetmask | ( | uint32_t * | ip = nullptr, |
| uint32_t * | mask = nullptr, |
||
| std::string * | ip_str = nullptr, |
||
| std::string * | mask_str = nullptr |
||
| ) |
Get the local IP and subnet mask.
Function to get the local IP address and subnet mask.
| ip | Pointer where saving the local IP. |
| mask | Pointer where saving the subnet mask. |
| ip_str | Pointer where saving the local IP in string format (XXX.XXX.XXX.XXX). |
| mask_str | Pointer where saving the subnet mask in string format (XXX.XXX.XXX.XXX). |
| std::string utils::hex2str | ( | unsigned int | v | ) |
Convert HEX from unsigned int to string.
Function to convert a HEX value (as an unsigned int) to a string.
| v | The HEX value as an unsigned int. |
| uint32_t utils::ip_str2num | ( | std::string | ip_str | ) |
Convert IP from string to uint32.
Function to convert IP from string to uint32.
| ip_str | The IP. |
| float utils::rms | ( | std::vector< float > const & | v | ) |
Get the RMS of a vector of float.
Function to get the RMS (root-mean-squared) of a std::vector<float>.
| hhmmss_t utils::sec2hhmmss | ( | int | secs | ) |
Convert elapsed seconds to hh::mm:ss format.
Function to convert elapsed seconds in hours, minutes, and seconds format.
| secs | The elapsed seconds. |
hhmmss_t struct containing hours, minutes, and seconds. | bool utils::set_env_var | ( | std::string | key, |
| std::string | val | ||
| ) |
Set a local environment variable.
Function to set a local environment variable. This is just a wrapper for the putenv function.
| key | The name of the environment variable. |
| val | The value of the environment variable. |
| bool utils::str2hex | ( | std::string | str, |
| unsigned int * | p_v | ||
| ) |
Convert HEX from string to unsigned int.
Function to convert a HEX (as a string) to an unsigned int
| str | The HEX value as an string. |
| p_v | The pointer to the unsigned int value. |