hrektts Posted December 7, 2015 Posted December 7, 2015 Hi, I wonder if anyone can give me some advice please? I would like to use "sprintf" in User Servo Algorithm to format double variables. Are there any functions to achieve this? I found "rtsprintf" in /opt/ppmac/usralgo/usrcode.h in Power UMAC. However, it was just a prototype. Thanks, hrektts
Omron Forums Support Posted December 7, 2015 Posted December 7, 2015 I cannot think of why you would need to use sprintf in a user servo. What are you trying to achieve specifically?
hrektts Posted December 8, 2015 Author Posted December 8, 2015 I would like to log data in a user servo. My program is composed of a user servo and a background C program. I want them to work as follows: 1) composes formatted string in a user servo <- I will use "sprintf" here. 2) passes the string to a FIFO, which I wrote, in a user servo 3) gets the string from a FIFO in a background C program 4) writes the string to a file Are there any established ways?
shansen Posted December 8, 2015 Posted December 8, 2015 A much better way to do this is to pass your data directly to your background C program via FIFO or shared memory. Then your background task can convert the data to string and write it to a file. I think sprintf can technically be done in the kernel (via vsnprintf), but it is tricky and can really mess up the determinism of your servo/phase loops if you aren't careful.
Omron Forums Support Posted December 8, 2015 Posted December 8, 2015 I agree with shansen. That is how you should do it.
hrektts Posted December 9, 2015 Author Posted December 9, 2015 That makes sense. Thank you for your suggestions. hrektts
Recommended Posts