looking for help with usb-serial and chprintf
Posted: Sat Jul 21, 2012 6:54 pm
I am trying to use chprintf with usb-serial in general functions. I can see how it works when
writing command functions using the shell.c module. I have been playing with this for several
days now, and have not had much luck figuring out how to get this to work.
here is the error I am getting.. Program compiles and works fine when I comment out chprintf
The chprintf is the very last line in the code below.
===================================================
R:\ChibiOS\projects\usb_2>make
Compiling main.c
main.c: In function 'main':
main.c:136:3: error: incompatible type for argument 1 of 'chprintf'
In file included from main.c:29:0:
../../../chibios/os/various/chprintf.h:42:8: note: expected 'struct BaseSequentialStream *' but argument is of type 'SerialUSBDriver'
make: *** [build/obj/main.o] Error 1
==================================================================
writing command functions using the shell.c module. I have been playing with this for several
days now, and have not had much luck figuring out how to get this to work.
here is the error I am getting.. Program compiles and works fine when I comment out chprintf
The chprintf is the very last line in the code below.
===================================================
R:\ChibiOS\projects\usb_2>make
Compiling main.c
main.c: In function 'main':
main.c:136:3: error: incompatible type for argument 1 of 'chprintf'
In file included from main.c:29:0:
../../../chibios/os/various/chprintf.h:42:8: note: expected 'struct BaseSequentialStream *' but argument is of type 'SerialUSBDriver'
make: *** [build/obj/main.o] Error 1
==================================================================
Code: Select all
/*
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
2011,2012 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "ch.h"
#include "hal.h"
#include "shell.h"
#include "chprintf.h"
//#include "myPWM.h"
//#include "myADC.h"
#include "myUSB.h"
#include "myMisc.h"
/*
* assert Shell Commands to functions
*/
static const ShellCommand commands[] =
{
{"mem", cmd_mem},
{"threads", cmd_threads},
{"toggle", cmd_toggle},
{"t", cmd_toggle},
{"blinkspeed", cmd_blinkspeed},
{"bs", cmd_blinkspeed},
/*
{"cycle", cmd_cycle},
{"c", cmd_cycle},
{"ramp", cmd_ramp},
{"r", cmd_ramp},
{"measure", cmd_measure},
{"m", cmd_measure},
{"measureAnalog", cmd_measureA},
{"ma", cmd_measureA},
{"measureDirect", cmd_measureDirect},
{"md", cmd_measureDirect},
{"measureContinuous", cmd_measureCont},
{"mc", cmd_measureCont},
{"readContinuousData", cmd_measureRead},
{"rd", cmd_measureRead},
{"stopContinuous", cmd_measureStop},
{"sc", cmd_measureStop},
*/
{NULL, NULL}
};
/*
* Shell configuration
*/
#define SHELL_WA_SIZE THD_WA_SIZE(2048)
static const ShellConfig shell_cfg1 =
{
(BaseSequentialStream *)&SDU1,
commands
};
/*
* Application entry point.
*/
int main(void)
{
char msg[]="sos sos sos";
/*
* Shell thread
*/
Thread *shelltp = NULL;
/*
* System initializations.
* - HAL initialization, this also initializes the configured device drivers
* and performs the board-specific initializations.
* - Kernel initialization, the main() function becomes a thread and the
* RTOS is active.
*/
halInit();
chSysInit();
/*
* Activate custom stuff
*/
// mypwmInit();
// myADCinit();
/*
* Creates the blinker thread.
*/
startBlinker();
/*
* Activates the USB driver and then the USB bus pull-up on D+.
*/
myUSBinit();
/*
* Main loop, does nothing except spawn a shell when the old one was terminated
*/
while (TRUE)
{
if (!shelltp && isUsbActive())
{
shelltp = shellCreate(&shell_cfg1, SHELL_WA_SIZE, NORMALPRIO);
}
else if (chThdTerminated(shelltp))
{
chThdRelease(shelltp); /* Recovers memory of the previous shell. */
shelltp = NULL; /* Triggers spawning of a new shell. */
}
chThdSleepMilliseconds(5000);
SendMorse( msg );
chprintf( SDU1, "%s\n", msg );
}
}