PRINTF (DbgConsole_Printf) doesn't work for negative float

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

PRINTF (DbgConsole_Printf) doesn't work for negative float

971 次查看
blmckinley
Contributor II

Using MCUXpresso 
Product: MCUXpresso IDE
Version: MCUXpresso IDE v24.12 [Build 148] [2025-01-10]
Operating system: Windows 11
VM: OpenJDK 64-Bit Server VM (64 bit)

The PRINTF macro that resolves to DbgConsole_Printf is supposed to provide small, lightweight print to terminal features. But it does not print negative float values correctly. This is apparently a known issue but it took me 2 solid days of fooling around with my code trying to figure out why my values had the wrong sign. 

The solution proposed in https://community.nxp.com/t5/MCUXpresso-SDK/Printing-negative-floats-with-DbgConsole-Printf-in-mcuxp...
is not really adequate since stdio brings in all kinds of other libraries and expands the amount of flash memory required. That is the whole reason that the SDK even provides a lightweight print function.

So it is really NOT a good solution, and the issue should remain open. How is it that this bug still exists in the SDK after TWO entire years? This is a ridiculously straightforward problem to solve. Please fix the SDK and stop wasting your developers' valuable time.


0 项奖励
回复
3 回复数

805 次查看
mayliu1
NXP Employee
NXP Employee

Hi @blmckinley ,

Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.

I suggest you can refer to this NXP community post:

Solved: Printing negative floats with DbgConsole_Printf in mcuxpresso SDK 2.15 - NXP Community

Please try it.

Best Regards

MayLiu

0 项奖励
回复

778 次查看
blmckinley
Contributor II
Thank you for the reply. As I mention in my post, although the printf() function does work for negative numbers, that is not a solution for a bug in the SDK function DbgConsole_Printf().

Your users deserve bug-free SDKs and I highly recommend you fix the bug as outlined.
0 项奖励
回复

662 次查看
mayliu1
NXP Employee
NXP Employee

Hi @blmckinley ,

Thanks for your feedback, I have already created an internal ticket for your question.

Best Regards

May Liu

0 项奖励
回复
%3CLINGO-SUB%20id%3D%22lingo-sub-2303138%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EPRINTF%20(DbgConsole_Printf)%20%E5%AF%B9%E8%B4%9F%E6%B5%AE%E7%82%B9%E6%95%B0%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2303138%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%BF%E7%94%A8%20MCUXpresso%20%3CBR%20%2F%3E%20%E4%BA%A7%E5%93%81%EF%BC%9AmcuxPresso%20IDE%20%3CBR%20%2F%3E%20%E7%89%88%E6%9C%AC%EF%BC%9AmcuxPresso%20IDE%20v24.12%20%5BBuild%20148%5D%20%5B2025-01-10%5D%20%3CBR%20%2F%3E%20%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%EF%BC%9AWindows%2011%20%3CBR%20%2F%3E%20%E8%99%9A%E6%8B%9F%E6%9C%BA%EF%BC%9AOpenJDK%2064%20%E4%BD%8D%E6%9C%8D%E5%8A%A1%E5%99%A8%E8%99%9A%E6%8B%9F%E6%9C%BA%EF%BC%8864%20%E4%BD%8D%EF%BC%89%E8%A7%A3%E6%9E%90%E4%B8%BA%20dbgConsole_Printf%20%E7%9A%84%20PRINTF%20%E5%AE%8F%E6%9C%AC%3CBR%20%2F%3E%3CBR%20%2F%3E%E5%BA%94%E4%B8%BA%E7%BB%88%E7%AB%AF%E5%8A%9F%E8%83%BD%E6%8F%90%E4%BE%9B%E5%B0%8F%E5%B7%A7%E8%BD%BB%E4%BE%BF%E7%9A%84%E6%89%93%E5%8D%B0%E3%80%82%E4%BD%86%E5%AE%83%E4%B8%8D%E8%83%BD%E6%AD%A3%E7%A1%AE%E6%89%93%E5%8D%B0%E8%B4%9F%E6%B5%AE%E7%82%B9%E6%95%B0%E5%80%BC%E3%80%82%E8%BF%99%E6%98%BE%E7%84%B6%E6%98%AF%E4%B8%80%E4%B8%AA%E5%B7%B2%E7%9F%A5%E7%9A%84%E9%97%AE%E9%A2%98%EF%BC%8C%E4%BD%86%E6%88%91%E8%8A%B1%E4%BA%86%E6%95%B4%E6%95%B4%E4%B8%A4%E5%A4%A9%E7%9A%84%E6%97%B6%E9%97%B4%E6%9D%A5%E7%90%A2%E7%A3%A8%E6%88%91%E7%9A%84%E4%BB%A3%E7%A0%81%EF%BC%8C%E8%AF%95%E5%9B%BE%E5%BC%84%E6%98%8E%E7%99%BD%E4%B8%BA%E4%BB%80%E4%B9%88%E6%88%91%E7%9A%84%E5%80%BC%E4%BC%9A%E6%9C%89%E9%94%99%E8%AF%AF%E7%9A%84%E7%AC%A6%E5%8F%B7%E3%80%82%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Fm-p%2F1795964%23M4587%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Fm-p%2F1795964%23M4587%3C%2FA%3E%3CBR%20%2F%3E%20%E4%B8%AD%E6%8F%90%E5%87%BA%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%AE%9E%E9%99%85%E4%B8%8A%E5%B9%B6%E4%B8%8D%E5%85%85%E5%88%86%EF%BC%8C%E5%9B%A0%E4%B8%BA%20stdio%20%E4%BC%9A%E5%B8%A6%E6%9D%A5%E5%90%84%E7%A7%8D%E5%85%B6%E4%BB%96%E5%BA%93%EF%BC%8C%E5%B9%B6%E6%89%A9%E5%A4%A7%E6%89%80%E9%9C%80%E7%9A%84%E9%97%AA%E5%AD%98%E5%AE%B9%E9%87%8F%E3%80%82%E8%BF%99%E5%B0%B1%E6%98%AF%20SDK%20%E7%94%9A%E8%87%B3%E6%8F%90%E4%BE%9B%E8%BD%BB%E9%87%8F%E7%BA%A7%E6%89%93%E5%8D%B0%E5%8A%9F%E8%83%BD%E7%9A%84%E5%85%A8%E9%83%A8%E5%8E%9F%E5%9B%A0%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E5%9B%A0%E6%AD%A4%EF%BC%8C%E8%BF%99%E7%A1%AE%E5%AE%9E%E4%B8%8D%E6%98%AF%E4%B8%80%E4%B8%AA%E5%A5%BD%E7%9A%84%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%EF%BC%8C%E8%BF%99%E4%B8%AA%E9%97%AE%E9%A2%98%E5%BA%94%E8%AF%A5%E7%BB%A7%E7%BB%AD%E6%82%AC%E8%80%8C%E6%9C%AA%E5%86%B3%E3%80%82%E4%B8%BA%E4%BB%80%E4%B9%88%E8%BF%87%E4%BA%86%E6%95%B4%E6%95%B4%E4%B8%A4%E5%B9%B4%EF%BC%8CSDK%20%E4%B8%AD%E4%BB%8D%E7%84%B6%E5%AD%98%E5%9C%A8%E8%BF%99%E4%B8%AA%E9%94%99%E8%AF%AF%EF%BC%9F%E8%BF%99%E6%98%AF%E4%B8%80%E4%B8%AA%E7%AE%80%E5%8D%95%E5%BE%97%E4%BB%A4%E4%BA%BA%E5%8F%91%E6%8C%87%E7%9A%84%E9%97%AE%E9%A2%98%E3%80%82%E8%AF%B7%E4%BF%AE%E5%A4%8D%20SDK%EF%BC%8C%E4%B8%8D%E8%A6%81%E5%86%8D%E6%B5%AA%E8%B4%B9%E5%BC%80%E5%8F%91%E4%BA%BA%E5%91%98%E7%9A%84%E5%AE%9D%E8%B4%B5%E6%97%B6%E9%97%B4%E4%BA%86%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2333210%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2333210%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F232320%22%20target%3D%22_blank%22%3E%40blmckinley%3C%2FA%3E%E3%80%81%3C%2FP%3E%0A%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E5%AF%B9%E6%81%A9%E6%99%BA%E6%B5%A6%E5%8D%8A%E5%AF%BC%E4%BD%93%E4%BA%A7%E5%93%81%E7%9A%84%E5%85%B3%E6%B3%A8%E5%B9%B6%E6%9C%89%E6%9C%BA%E4%BC%9A%E4%B8%BA%E6%82%A8%E6%9C%8D%E5%8A%A1%E3%80%82%3C%2FP%3E%0A%3CP%3E%E6%88%91%E5%BB%BA%E8%AE%AE%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%8F%82%E8%80%83%E6%81%A9%E6%99%BA%E6%B5%A6%3CSPAN%3E%E7%A4%BE%E5%8C%BA%E7%9A%84%3C%2FSPAN%3E%E8%BF%99%E7%AF%87%E5%B8%96%E5%AD%90%EF%BC%9A%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2FMCUXpresso-SDK%2FPrinting-negative-floats-with-DbgConsole-Printf-in-mcuxpresso%2Ftd-p%2F1795380%22%20target%3D%22_blank%22%3E%E5%B7%B2%E8%A7%A3%E5%86%B3%EF%BC%9A%E5%9C%A8%20mcuxpresso%20SDK%202.15%20%E4%B8%AD%E4%BD%BF%E7%94%A8%20DbgConsole_Printf%20%E6%89%93%E5%8D%B0%E8%B4%9F%E6%B5%AE%E7%82%B9%E6%95%B0%20-%20NXP%20Community%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%E8%AF%B7%E6%82%A8%E5%B0%9D%E8%AF%95%E4%B8%80%E4%B8%8B%E3%80%82%3C%2FP%3E%0A%3CP%3E%E9%A1%BA%E7%A5%9D%E5%95%86%E7%A5%BA%EF%BC%81%3C%2FP%3E%0A%3CP%3EMayLiu%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2334110%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2334110%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%E8%B0%A2%E8%B0%A2%E6%82%A8%E7%9A%84%E7%AD%94%E5%A4%8D%E3%80%82%E6%AD%A3%E5%A6%82%E6%88%91%E5%9C%A8%E5%B8%96%E5%AD%90%E4%B8%AD%E6%8F%90%E5%88%B0%E7%9A%84%EF%BC%8C%E8%99%BD%E7%84%B6%20printf()%20%E5%87%BD%E6%95%B0%E7%A1%AE%E5%AE%9E%E5%8F%AF%E4%BB%A5%E5%A4%84%E7%90%86%E8%B4%9F%E6%95%B0%EF%BC%8C%E4%BD%86%E8%BF%99%E5%B9%B6%E4%B8%8D%E8%83%BD%E8%A7%A3%E5%86%B3%20SDK%20%E5%87%BD%E6%95%B0%20DbgConsole_Printf()%20%E4%B8%AD%E7%9A%84%E4%B8%80%E4%B8%AA%E9%94%99%E8%AF%AF%E3%80%82%3CBR%20%2F%3E%3CBR%20%2F%3E%E6%82%A8%E7%9A%84%E7%94%A8%E6%88%B7%E5%BA%94%E8%AF%A5%E5%BE%97%E5%88%B0%E6%B2%A1%E6%9C%89%E9%94%99%E8%AF%AF%E7%9A%84%20SDK%EF%BC%8C%E6%88%91%E5%BC%BA%E7%83%88%E5%BB%BA%E8%AE%AE%E6%82%A8%E6%8C%89%E7%85%A7%E6%A6%82%E8%BF%B0%E7%9A%84%E6%96%B9%E6%B3%95%E4%BF%AE%E5%A4%8D%E9%94%99%E8%AF%AF%E3%80%82%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2342004%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20PRINTF%20%20(DbgConsole_Printf)%20doesn't%20work%20for%20negative%20float%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2342004%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%E4%BD%A0%E5%A5%BD%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F232320%22%20target%3D%22_blank%22%3E%40blmckinley%3C%2FA%3E%E3%80%81%3C%2FP%3E%0A%3CP%3E%E6%84%9F%E8%B0%A2%E6%82%A8%E7%9A%84%E5%8F%8D%E9%A6%88%EF%BC%8C%E6%88%91%E5%B7%B2%E7%BB%8F%E4%B8%BA%E6%82%A8%E7%9A%84%E9%97%AE%E9%A2%98%E5%88%9B%E5%BB%BA%E4%BA%86%E5%86%85%E9%83%A8%E7%A5%A8%E6%8D%AE%E3%80%82%3C%2FP%3E%0A%3CP%3E%E9%A1%BA%E7%A5%9D%E5%95%86%E7%A5%BA%EF%BC%81%3C%2FP%3E%0A%3CP%3E%E5%88%98%E6%A2%85%3C%2FP%3E%3C%2FLINGO-BODY%3E