vprintf output doesn't end up in __sys_write

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

vprintf output doesn't end up in __sys_write

1,785件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MindBender on Thu Jul 16 02:12:13 MST 2015
I have created function __sys_write according to this prototype:
int __sys_write(int file, char *buf, int len)

All my printf output is now diverted to my __sys_write. Unfortunately, vprintf output is not. The same goes for vfprintf stdout. Output seems to be discarded.

Is this not supported?
0 件の賞賛
返信
4 返答(返信)

1,669件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MindBender on Fri Jul 17 04:41:58 MST 2015
No, it's not:
long console_send(char *buf, long len)
{
return UART_Send(this_uart, (uint8_t*)buf, len, BLOCKING);
}

int __sys_write(int file, char *buf, int len)
{
return console_send(buf, len);
}

But I may have had a couple of printf's throughout the code polluting the test result above.
0 件の賞賛
返信

1,669件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Jul 16 07:42:08 MST 2015
vprintf will output via a character at a time via a putc style interface.So if you stop on __sys_write, you should only ever see a len of 1 character being passed into it for output being made from vprintf. Anything beyond the first character in the buffer is hence basically random.

Is your __sys_write function ignoring the len parameter?

Regards,
LPCXpresso Support
0 件の賞賛
返信

1,669件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by MindBender on Thu Jul 16 07:04:25 MST 2015
> Does you __sys_write even get called during your call to vprintf? (i.e. set a breakpoint on your __sys_write function).

I was sure that it wasn't, but I have just removed my work-around and put vprintf back, and __sys_write gets called. However, the data it receives doesn't make much sense; It is readable text, and even text that was printed during program execution, but with text is repeated and appears out-of-order. And yet, I do make __sys_write return the length. Making it return 0 shows a slight improvement, but that's not how it's supposed to be.

> Please also confirm target MCU, which version of LPCXpresso is being used and which debug probe.

LPC1788, LPCXpresso v7.8.0 [Build 426] [2015-05-28], Link2
And I'm using RedLib, obviously.

I think I will just stick with my work-around; Stripping my application down and testing for reproductions would cost a lot of time. Thank you for offering anyway.
0 件の賞賛
返信

1,669件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Jul 16 02:34:23 MST 2015
There are no know issues here - for example see this previous thread (the functionality here has not changed since):

[list]
  [*]https://www.lpcware.com/content/forum/lpcxpresso-and-redlib-vprintf-problems
[/list]

Does you __sys_write even get called during your call to vprintf? (i.e. set a breakpoint on your __sys_write function).

Anyway, I suggest that you post an example project that shows up the problem, or at least provide your linker map file in case that provides any clues.

[list]
  [*]https://www.lpcware.com/content/faq/lpcxpresso/how-importexport-projects
[/list]

Please also confirm target MCU, which version of LPCXpresso is being used and which debug probe.

Regards,
LPCXpresso Support
0 件の賞賛
返信