2024-09-18 21:48:57 -05:00
|
|
|
/**
|
|
|
|
* This function splits a data frame using the project-specified separator,
|
|
|
|
* allowing you to customize frame parsing for different project requirements.
|
2022-06-10 07:04:07 -05:00
|
|
|
*
|
2024-09-18 21:48:57 -05:00
|
|
|
* Global variables can maintain a constant output array, enabling a single
|
|
|
|
* Serial Studio project to display information consistently, even with varying
|
|
|
|
* frame types.
|
2022-06-10 07:04:07 -05:00
|
|
|
*
|
2024-09-18 21:48:57 -05:00
|
|
|
* @param[in] frame The latest received frame as a string.
|
|
|
|
* @param[in] separator The data separator defined in the JSON project.
|
|
|
|
* @return Array of strings containing the parsed frame elements.
|
2022-06-10 07:04:07 -05:00
|
|
|
*
|
2024-09-18 21:48:57 -05:00
|
|
|
* @note Only data within the delimiters is processed.
|
|
|
|
* @note Declare global variables outside @c parse() for state/configuration.
|
|
|
|
*
|
|
|
|
* @example
|
|
|
|
* Given frame: "value1,value2,value3", separator: ","
|
|
|
|
* Returns: ["value1", "value2", "value3"]
|
2022-06-10 07:04:07 -05:00
|
|
|
*/
|
|
|
|
function parse(frame, separator) {
|
|
|
|
return frame.split(separator);
|
2024-09-18 21:48:57 -05:00
|
|
|
}
|