3 #define _CRT_SECURE_NO_WARNINGS 4 #define _USE_MATH_DEFINES 43 fout = fopen(filename.c_str(),
"w");
70 char asciiBuffer[255] = {0};
71 for (
int i = 0; i < bufLen; i++)
78 printf(
"%02x ", buffer[i]);
81 if ((buffer[i] >= 0x20) && (buffer[i] < 0x80))
83 ch = (char) buffer[i];
85 int iStrLen = strlen(asciiBuffer);
86 asciiBuffer[iStrLen] = ch;
87 asciiBuffer[iStrLen + 1] =
'\0';
91 printf(
"%s\n", asciiBuffer);
92 strcpy(asciiBuffer,
"");
98 printf(
"%s\n", asciiBuffer);
110 std::stringstream out;
111 for(
int n = 0; n < length; n++)
113 int val = (int)(binary_data[n] & 0xFF);
114 if ((val == 0x20) || (val >= 48 && val <= 57) || (val >= 65 && val <= 90) || (val >= 97 && val <= 122))
116 out << std::string(1,(
char)(val & 0xFF));
120 out <<
"\\x" << std::setfill(
'0') << std::setw(2) << std::hex << val;
131 double sampleRate = 1000.0;
136 for (
double t = 0; t < 5.0; t += 1.0 / sampleRate)
139 testSignal = 1.0 * cos(2 * M_PI * freq * t);
145 testSignal = 1.0 * sin(2 * M_PI * freq * t);
151 #ifdef TEST_DATA_DUMPER 152 int main(
int argc,
char *argv)
static std::string binDataToAsciiString(const uint8_t *binary_data, int length)
int pushData(double timeStamp, std::string info, double val)
std::vector< std::string > infoVec
int main(int argc, char **argv)
Startup routine - if called with no argmuments we assume debug session. Set scanner name variable by ...
int writeDataToCsv(std::string fileName)
int writeToFileNameWhenBufferIsFull(std::string filename)
static DataDumper & instance()
std::vector< double > timeStampVec
std::vector< double > dataVec
int dumpUcharBufferToConsole(unsigned char *buffer, int bufLen)