scanf/printf not working when calling generated C code
35 次查看(过去 30 天)
显示 更早的评论
In Matlab I have generated C code (.c/.h files) from a Matlab function using codegen from Matlab Coder.
I call this function in a while loop on an ARM quad-core Cortex A53 using AMD Vitis.
Before calling this function I use scanf/printf to get user input and to print to the serial monitor. However, scanf/printf only work once in the 1st iteration (before calling the function) and not in the 2nd iteration or later (after calling the function).
Is this a common problem and has anyone encountered this problem before?
I think, but am not sure, that the problem is in the generated C code and not in Vitis itself.
Thank you in advance!
3 个评论
dpb
about 9 hours 前
编辑:dpb
about 3 hours 前
Probably no one has ever done precisely the same thing with the combination of environment and hardware so it's extremely likely the answer to that question is "No".
Knowing nothing of what the function does nor anything about the system you're running, it's unlikely anybody here can help.
If not calling the function removes the symptoms, then it is conclusive that something in either the calling/return linkage is broken or the function itself did something damaging outside returning its expected output(s). One next debugging step would be to create an empty null function in its stead and test calling it. If that is successful, then add the argument list alone, then the output arguments until find what step causes something to break. You could also try replacing the function call with something simple like timestwo.c and make sure the code generator can handle the simple case first. It's always possible there is something unique in the development environment it doesn't know about -- maybe a default convention assumed isn't the same as expected.
"... I use scanf/printf to get user input and to print to the serial monitor"
I would suspect that the serial connection got broken would be a fairly likely possibility...
If that doesn't uncover the problem, you'll probably have to submit the whole enchilada to Mathworks suppor.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!