CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
TestingUtility.h
1#ifndef TESTING_UTILITY_H
2#define TESTING_UTILITY_H
3
4#include <Arduino.h>
5#include "Debug.h"
6
7
8void generateRandomString(char buffer[], size_t length) {
9 static const char charset[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10 for (size_t i = 0; i < length; i++) {
11 int key = random(0, sizeof(charset) - 1);
12 buffer[i] = charset[key];
13 }
14 buffer[length] = '\0'; // Null-terminate the string
15 DEBUG_PRINTLN("Generated random string: " + String(buffer));
16
17}
18
19void clearBuffer(char buffer[], size_t length) {
20 memset(buffer, 0, length);
21 DEBUG_PRINTLN("Cleared buffer: " + String(buffer));
22}
23
24String addLeadingZeros(int number, int bits) {
25 String numStr = String(number, BIN);
26 while (numStr.length() < bits) {
27 numStr = "0" + numStr;
28 }
29 return numStr;
30}
31
32#endif
Logging and debug macro definitions for CANTramCore.
#define DEBUG_PRINTLN(x)
Print a debug message with newline.
Definition Debug.h:63