This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
//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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check gpio usage | |
mount -t debugfs debugfs /sys/kernel/debug | |
cat /sys/kernel/debug/gpio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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*") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Execute command | |
execute_process(COMMAND echo -e "\\033[0;33mHello command\\033[0m") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/ | |
) |