LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-27-2019, 02:29 PM   #1
kernelb
LQ Newbie
 
Registered: Nov 2019
Posts: 1

Rep: Reputation: Disabled
How to read temperature in linux


Hi all for learning purpose i have created a driver under driver/thermal ( xyz_thermal.c) which can read temperature ( just passing dummies value). But now how can i read this vlue from userspace. i tried /sys/class/thermal/ but i didn't see thermal zone which i created. Can any one help me on this?

Changes what i have done.

xyz_thermal.c


*/
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/of.h>
#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/io.h>
#include <linux/thermal.h>
#include <linux/reset.h>
#include <linux/types.h>


struct xyz_therm_info {
struct device *dev;
struct thermal_zone_device *tz_device;
int irq_tj1;
int irq_tj2;
int irq_tj3;
};



static int xyz_read_temp(void *data, int *temperature)
{
struct mtk_thermal *mt = data;

temperature = 100;
return 0;
}

static const struct thermal_zone_of_device_ops xyz_thermal_ops = {
.get_temp = xyz_read_temp,
};


static int xyz_thermal_probe(struct platform_device *pdev)
{

}

static struct platform_device_id xyz_thermal_devtype[] = {
{ .name = "xyz-thermal", },
{},
};

MODULE_DEVICE_TABLE(platform, xyz_thermal_devtype);

static struct platform_driver xyz_thermal_driver = {
.driver = {
.name = "xyz-thermal",
},
.probe = xyz_thermal_probe,
.id_table = xyz_thermal_devtype,
};

module_platform_driver(xyz_thermal_driver);

also did changes in kconfig and make file and enable it on .config file

i want to know what i am missing here or is i am doing it correctly?
 
Old 11-28-2019, 03:17 PM   #2
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,334

Rep: Reputation: 224Reputation: 224Reputation: 224
I don't know the answer. Perhaps you can find inspiration in tools/thermal/tmon in the kernel source.
 
Old 12-07-2019, 08:14 AM   #3
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 329

Rep: Reputation: 161Reputation: 161
I would suggest you examine, or maybe use libsensors, that is used by sensors(1) and is able to get the info you want.
 
  


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
C++ Tinyb ble temperature reader application gives constant readings which doesn't reflect the actual temperature variation ba_kirang Programming 1 05-27-2019 04:33 PM
Temperature inside computer box and CPU temperature Lola Kews Linux - Hardware 14 11-29-2013 07:22 PM
How can I read CPU temperature ankit4u1 Programming 3 05-30-2007 02:48 AM
How to read hard disk temperature ? bennethos Linux - General 2 12-29-2004 10:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:40 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration