Skip to content

Instantly share code, notes, and snippets.

@sepfy
sepfy / read.sh
Created September 20, 2020 04:03
echo "scale=2; -45 + 175*$(cat /sys/class/sensor/sht31/temperature)/65535" | bc
echo "scale=2; 100*$(cat /sys/class/sensor/sht31/humidity)/65535" | bc
int val = 0;
int temp, humi;
u8 bytes[6] = {0};
const u8 cmd[6] = {0};
u32 s;
printk("[%s][%d]\n", __func__, __LINE__);
s = i2c_smbus_write_i2c_block_data(i2c_client, 0x24, 1, cmd);
if(s < 0) {
...
//char* reportedProperties = serializeToJson(&car);
char reportedProperties[512];
sprintf(reportedProperties, "{\"temperature\": 27.6, \"humidity\": 67.3}");
if (reportedProperties != NULL)
{
(void)IoTHubDeviceClient_LL_SendReportedState(iotHubClientHandle, (const unsigned char*)reportedProperties, strlen(reportedProperties), reportedStateCallback, NULL);
# Check gpio usage
mount -t debugfs debugfs /sys/kernel/debug
cat /sys/kernel/debug/gpio
#include <linux/module.h>
#include <linux/device.h>
#include <linux/err.h>
int value = 0;
static ssize_t attr_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
PWD := $(shell pwd)
KVERSION := $(shell uname -r)
KERNEL_DIR = /usr/src/linux-headers-$(KVERSION)/
MODULE_NAME = mydev
obj-m := $(MODULE_NAME).o
all:
make -C $(KERNEL_DIR) M=$(PWD) modules
clean:
cmake_minimum_required(VERSION 3.1)
project(func)
add_library(func func.c)
option(UNITTEST_ENABLE "Build the unittest code" OFF)
file(GLOB func_SRC "*.c")
file(GLOB unittest_SRC "*unittest*")
cmake_minimum_required(VERSION 3.1)
project(app)
file(GLOB APP_SOURCES "*.c")
foreach(sourcefile ${APP_SOURCES})
string(REPLACE ".c" "" appname ${sourcefile})
string(REPLACE "${PROJECT_SOURCE_DIR}/" "" appname ${appname})
add_executable(${appname} ${sourcefile})
endforeach(sourcefile ${APP_SOURCES})
# Execute command
execute_process(COMMAND echo -e "\\033[0;33mHello command\\033[0m")
cmake_minimum_required(VERSION 3.1)
project(samples)
add_subdirectory(func)
add_executable(main main.c)
# Install target
install(TARGETS main
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/
)