本文整理汇总了C++中serialPrint函数的典型用法代码示例。如果您正苦于以下问题:C++ serialPrint函数的具体用法?C++ serialPrint怎么用?C++ serialPrint使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serialPrint函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cliFuncConfig
void cliFuncConfig(void *cmd, char *cmdLine) {
char param[8];
if (state > ESC_STATE_STOPPED) {
serialPrint(stopError);
}
else if (sscanf(cmdLine, "%8s", param) != 1) {
cliUsage((cliCommand_t *)cmd);
}
else if (!strcasecmp(param, "default")) {
configLoadDefault();
serialPrint("CONFIG: defaults loaded\r\n");
}
else if (!strcasecmp(param, "read")) {
configReadFlash();
serialPrint("CONFIG: read flash\r\n");
}
else if (!strcasecmp(param, "write")) {
if (configWriteFlash()) {
serialPrint("CONFIG: wrote flash\r\n");
}
else {
serialPrint("CONFIG: write flash failed!\r\n");
}
}
else {
cliUsage((cliCommand_t *)cmd);
}
}
示例2: serialPrint
void IMUTester::readSerialCommand() {
int serialData = Serial.read();
if (serialData != -1)
// clear some space
serialPrint("\n\n\n");
switch (serialData)
{
case -1:
break;
case 'i':
//initialize(Serial.read());
break;
case 'a':
reportAccel = toggle(reportAccel);
break;
case 'y':
reportGyro = toggle(reportGyro);
break;
case 'Y':
reportGyroAll = toggle(reportGyroAll);
break;
case 'g':
reportGPS = toggle(reportGPS);
break;
case 'c':
reportComp = toggle(reportComp);
break;
default:
serialPrint("unknown command: ");
serialPrintln(serialData);
}
}
示例3: cliLs
int cliLs(const char ** argv)
{
FILINFO fno;
DIR dir;
char *fn; /* This function is assuming non-Unicode cfg. */
#if _USE_LFN
TCHAR lfn[_MAX_LFN + 1];
fno.lfname = lfn;
fno.lfsize = sizeof(lfn);
#endif
FRESULT res = f_opendir(&dir, argv[1]); /* Open the directory */
if (res == FR_OK) {
for (;;) {
res = f_readdir(&dir, &fno); /* Read a directory item */
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
#if _USE_LFN
fn = *fno.lfname ? fno.lfname : fno.fname;
#else
fn = fno.fname;
#endif
serialPrint(fn);
}
}
else {
serialPrint("%s: Invalid directory \"%s\"", argv[0], argv[1]);
}
return 0;
}
示例4: cliUsage
void cliUsage(cliCommand_t *cmd) {
serialPrint("usage: ");
serialPrint(cmd->name);
serialWrite(' ');
serialPrint(cmd->params);
serialPrint("\r\n");
}
示例5: cliDisplay
int cliDisplay(const char ** argv)
{
int address = 0;
for (const MemArea * area = memAreas; area->name != NULL; area++) {
if (!strcmp(area->name, argv[1])) {
dump((uint8_t *)area->start, area->size);
return 0;
}
}
if (!strcmp(argv[1], "adc")) {
extern uint16_t Analog_values[NUMBER_ANALOG];
for (int i=0; i<NUMBER_ANALOG; i++) {
serialPrint("adc[%d] = %04X", i, Analog_values[i]);
}
}
else if (!strcmp(argv[1], "outputs")) {
for (int i=0; i<NUM_CHNOUT; i++) {
serialPrint("outputs[%d] = %04X", i, channelOutputs[i]);
}
}
else if (!strcmp(argv[1], "time")) {
struct gtm utm;
gettime(&utm);
serialPrint("time = %4d-%02d-%02d %02d:%02d:%02d.%02d0", utm.tm_year+1900, utm.tm_mon+1, utm.tm_mday, utm.tm_hour, utm.tm_min, utm.tm_sec, g_ms100);
}
else if (toInt(argv, 1, &address) > 0) {
int size = 256;
if (toInt(argv, 2, &size) >= 0) {
dump((uint8_t *)address, size);
}
}
return 0;
}
示例6: cliDisplay
int cliDisplay(const char ** argv)
{
int address = 0;
for (const MemArea * area = memAreas; area->name != NULL; area++) {
if (!strcmp(area->name, argv[1])) {
dump((uint8_t *)area->start, area->size);
return 0;
}
}
if (!strcmp(argv[1], "adc")) {
for (int i=0; i<NUMBER_ANALOG; i++) {
serialPrint("adc[%d] = %04X", i, Analog_values[i]);
}
}
else if (!strcmp(argv[1], "outputs")) {
for (int i=0; i<NUM_CHNOUT; i++) {
serialPrint("outputs[%d] = %04X", i, channelOutputs[i]);
}
}
else if (toInt(argv, 1, &address) > 0) {
int size = 256;
if (toInt(argv, 2, &size) >= 0) {
dump((uint8_t *)address, size);
}
}
return 0;
}
示例7: cliFuncRpm
void cliFuncRpm(void *cmd, char *cmdLine) {
float target;
if (state < ESC_STATE_RUNNING) {
serialPrint(runError);
}
else {
if (sscanf(cmdLine, "%f", &target) != 1) {
cliUsage((cliCommand_t *)cmd);
}
else if (p[FF1TERM] == 0.0f) {
serialPrint("Calibration parameters required\r\n");
}
else if (target < 100.0f || target > 10000.0f) {
serialPrint("RPM out of range: 100 => 10000\r\n");
}
else {
if (runMode != CLOSED_LOOP_RPM) {
runRpmPIDReset();
runMode = CLOSED_LOOP_RPM;
}
targetRpm = target;
sprintf(tempBuf, "RPM set to %6.0f\r\n", target);
serialPrint(tempBuf);
}
}
}
示例8: millis
int IMUTester::timeComp()
{
finish = millis();
serialPrint(comp.getRawX()); serialPrint(",");
serialPrint(comp.getRawY()); serialPrint(",");
return millis() - finish;
}
示例9: cliPrintParam
void cliPrintParam(int i) {
const char *format = "%-20s = ";
sprintf(tempBuf, format, configParameterStrings[i]);
serialPrint(tempBuf);
sprintf(tempBuf, configFormatStrings[i], p[i]);
serialPrint(tempBuf);
serialPrint("\r\n");
}
示例10: cliFuncBinary
void cliFuncBinary(void *cmd, char *cmdLine) {
if (state > ESC_STATE_STOPPED) {
serialPrint(stopError);
}
else {
serialPrint("Entering binary command mode...\r\n");
cliTelemetry = 0;
commandMode = BINARY_MODE;
}
}
示例11: cliInit
void cliInit(void) {
serialPrint(cliHome);
serialPrint(cliClear);
sprintf(version, "%s.%d", VERSION, getBuildNumber());
cliFuncVer(0, 0);
serialPrint("\r\nCLI ready.\r\n");
cliPrompt();
}
示例12: cliFuncStop
void cliFuncStop(void *cmd, char *cmdLine) {
if (state < ESC_STATE_NOCOMM) {
serialPrint(runError);
}
else {
runStop();
cliFuncChangeInput(ESC_INPUT_UART);
serialPrint("ESC stopping\r\n");
}
}
示例13: cliFuncBoot
void cliFuncBoot(void *cmd, char *cmdLine) {
if (state != ESC_STATE_DISARMED) {
serialPrint("ESC armed, disarm first\r\n");
}
else {
serialPrint("Rebooting in boot loader mode...\r\n");
timerDelay(0xffff);
rccReset();
}
}
示例14: cliFuncArm
void cliFuncArm(void *cmd, char *cmdLine) {
if (state > ESC_STATE_DISARMED) {
serialPrint("ESC already armed\r\n");
}
else {
if (runMode != SERVO_MODE)
cliFuncChangeInput(ESC_INPUT_UART);
runArm();
serialPrint("ESC armed\r\n");
}
}
示例15: cliFuncStart
void cliFuncStart(void *cmd, char *cmdLine) {
if (state == ESC_STATE_DISARMED) {
serialPrint("ESC disarmed, arm first\r\n");
}
else if (state > ESC_STATE_STOPPED) {
serialPrint("ESC already running\r\n");
}
else {
runStart();
serialPrint("ESC started\r\n");
}
}