Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 3000  / 2 Years ago, fri, december 31, 2021, 8:38:46

When working with a wireless driver module, noise in the wireless medium is reported to the module as a s32 data type, which is defined in linux/types.h.



I would like to use printk() to print out this value to the syslog, however when I do I get unintelligible results. Current attempts have been:



printk("%d", val);  
printk("%d", (int) val);
printk("%3i", (int)val);
printk("%3i", val);
printk("%lx", val);
printk("%lx", long val);


I don't understand is how to format this for printing. I have also not been able to find any information thus far on how to do so.



Since it deals with kernel data types, I thought it might be appropriate to post in askubuntu.


More From » kernel

 Answers
5

It turns out that the sign extension was important:



sign_extend32(AR5K_REG_MS(value, AR5K_PHY_NF_MINCCA_PWR), 8)



where:



AR5K_PHY_NF_MINCCA_PWR 0x0ff80000 /* Minimum measured noise level, read from hardware in 1 dBm units */



The AR5K_REG_MS functions masks and shifts that value read from the hardware register with respect to the minimum measured noise level .



sign_extend32 /* sign extend a 32-bit value using specified bit as sign-bit */



After these are completed, the number can be written to syslog using '%d' for formatting.


[#33012] Friday, December 31, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
onbean

Total Points: 29
Total Questions: 102
Total Answers: 115

Location: Benin
Member since Fri, Mar 24, 2023
1 Year ago
onbean questions
Fri, Mar 18, 22, 19:49, 2 Years ago
Tue, Dec 6, 22, 11:51, 1 Year ago
Mon, Jun 7, 21, 17:21, 3 Years ago
Mon, Jan 16, 23, 04:48, 1 Year ago
Mon, Oct 17, 22, 14:51, 2 Years ago
;