Page 1 of 1

any printf method in ext driver call back functoin?

Posted: Wed Feb 26, 2014 2:33 am
by yushanh
Hi all,

I tried to implement an EXT callback function and would like to print some messages thru usb serial driver in it.
I just found that whenever I go into the ISR callback function, the kernel was stuck. In this case, is there any other way to print?

Code: Select all

static void extcb1(EXTDriver *extp, expchannel_t channel) {
  chprintf((BaseSequentialStream *)&SDU1, "hello\r\n");
  static VirtualTimer vt4;

  (void)extp;
  (void)channel;
  palSetPad(GPIOB, GPIOB_LED4);
  chSysLockFromIsr();
  if (chVTIsArmedI(&vt4))
    chVTResetI(&vt4);
  /* LED4 set to OFF after 200mS.*/
  chVTSetI(&vt4, MS2ST(200), led4off, NULL);
  chSysUnlockFromIsr();
}




Thanks!

Shan.

Re: any printf method in ext driver call back functoin?

Posted: Wed Feb 26, 2014 8:41 am
by Giovanni
Hi,

You can't use streams from a callback context, the state checker stops you, you have to wakeup a thread that then does your I/O on the stream.

Giovanni

Re: any printf method in ext driver call back functoin?

Posted: Wed Feb 26, 2014 10:35 pm
by yushanh
Thanks Giovanni,

Following your instructions here (http://chibios.org/dokuwiki/doku.php?id ... tos:wakeup), now it gets to work!

~S