printf  with  void TERMIO_PutString(const char *p)      (mc9s12dp256)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

printf  with  void TERMIO_PutString(const char *p)      (mc9s12dp256)

跳至解决方案
1,739 次查看
Snail_cz
Contributor I

Hi,

I am trying to use printf function. It works with “void TERMIO_PutChar(char ch);”, but I need whole string at once. So, I want to use this function: “void TERMIO_PutString(const char *p);”. It doesn’t work even I define this string: “_TERMIO_HAS_PUT_STRING_”.

The original function definition in TERMIO.h:

#ifdef _TERMIO_HAS_PUT_STRING_
  void TERMIO_PutString(const char *p);
#endif

I tried somethnig like this:

void TERMIO_PutString(const char *p){
  while(*p){
     vSCI0_send( (signed char) *p);
     p++;
  }
}

Thanks,

Excuse my English.

标签 (1)
标记 (1)
0 项奖励
1 解答
581 次查看
CrasyCat
Specialist III

Hello

 

This is just a function prototype for a function that can be called by printf to write output to stdout as a whole string.

 

Idea here is that printf is ready to support that as soon as a programmer implements such a function.

As stated in my previous email the fact that you want to send the whole string at once is probably a requirement from the device you want to use for stdout.

 

So you need to write the driver for that device.

 

The SCI we are using as stdout in TermIO.c can only transfer one character at a time. So there is no reason for implementing a PutString function there.

 

CrasyCat

在原帖中查看解决方案

0 项奖励
3 回复数
581 次查看
Snail_cz
Contributor I

Hi,

ok, thank you.

And do you know why in this file (TERMIO.h) is a definition for this function ?

0 项奖励
582 次查看
CrasyCat
Specialist III

Hello

 

This is just a function prototype for a function that can be called by printf to write output to stdout as a whole string.

 

Idea here is that printf is ready to support that as soon as a programmer implements such a function.

As stated in my previous email the fact that you want to send the whole string at once is probably a requirement from the device you want to use for stdout.

 

So you need to write the driver for that device.

 

The SCI we are using as stdout in TermIO.c can only transfer one character at a time. So there is no reason for implementing a PutString function there.

 

CrasyCat

0 项奖励
581 次查看
CrasyCat
Specialist III

Hello

 

THere is no implementation of TERMIO_PutString available in the layout.

You have to implement it yourself.

 

If you need ability to send the whole string at once, you are probably using something else as a SCI as standard output.

In this case you need to write the low level function for your peripheral yourself.

Implementation will depend on the peripheral used.

 

CrasyCat

0 项奖励