LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 06-14-2021, 09:30 AM   #1
madironman
LQ Newbie
 
Registered: Jun 2021
Posts: 2

Rep: Reputation: Disabled
Unhappy Reading /sys/class/hwmon/hwmon0/temp1_input multiple times freezes and crashes the system with no logs


Hi all, I have a application code that reads from the lm75 temperature sensor which is connected via i2c.
the application opens the sys file "/sys/class/hwmon/hwmon0/temp1_input" and using fscanf reads the data and process it. My problem is if i have multiple calls to reading the file the system crashes with no logs even after enabling debugs and setting console log levels appropriately. I added spinlocks in lm75 driver where the register is read and that didn't change anything . Please help me out fellow penguins..
 
Old 06-14-2021, 11:09 AM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,412
Blog Entries: 7

Rep: Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954Reputation: 1954
Quote:
I have a application code
You have given almost 0 info.

What programming language? PHP, C C++ ? Show the bit of code that is reading it.
 
Old 06-14-2021, 11:57 PM   #3
madironman
LQ Newbie
 
Registered: Jun 2021
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thumbs up

Hi, sorry I didn't attach any reference code. it just does fopen and fscanf on the /sys... file , the application code looks similar to this...

int getsensortemps()
{

FILE* tempfile = NULL;
int *tempvalue = 0;
tempfile = fopen("/sys/class/hwmon/hwmon0/temp1_input", "r");
if( tempfile == NULL )return -1;
if(fscanf(tempfile, "%d" ,tempvalue) > 0){
*tempvalue=*tempvalue / 100;
fclose(tempfile);
return *tempvalue;
}
fclose(tempfile);
return -1
}

my problem is multiple process access this function
1) A background process which updates temp periodically
2) A CLI command which gives temp output

both access this function, and sometimes this causes crash with no logs. I even tried cat /sys/class/hwmon/hwmon0/temp1_input this also produced crash. The crash is not certain to happen but occurs randomly , with probability increasing with how fast we access the /sys/.... file...

the lm75 sensor code is generic one..

thanks in advance

https://elixir.bootlin.com/linux/lat...s/hwmon/lm75.c
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] reading from hwmon temperature sensor 103 igok99 Linux - Newbie 13 08-26-2019 03:38 PM
Back up logs file and create a script showing the backed up logs and the running logs Billy_6052 Programming 5 12-13-2014 02:32 AM
[SOLVED] Conky and hwmon kasl33 Debian 4 08-01-2011 04:00 PM
/sys/class/hwmon Question Aztral Linux - General 1 08-11-2009 02:00 PM
jackd and alsa hwmon on an m-audio mobilepre ninja master Linux - Hardware 2 10-07-2008 03:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 06:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration