文档中提到了xrdp软件,remmina就提供了rdp的客户端,果断的搞起,sudo apt install xrdp发现老是无法下载,但是对端ip是能ping通的,sudo ping www.baidu.com发现能获取到ip但是屏出来的数据无法正常频率拿取,初步怀疑是由于dns的问题导致的,果断sudo systemd-resolve --status发现dns里面有一些信息,果断在/etc/systemd/resolved.conf加上8.8.8.8 114.114.114.114发现还是无法解决问题,果断换个方向,把源更改成过国内的其他源,
然后再通过sudo apt install xrdp的方式装上xrdp,在做一些配置,妥妥的图形界面来了。
没有显示器也能享受界面带来的美感。
观察到资源里面有案例代码,又有传感器,果断上手来上一个
#include <stdio.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
#include <linux/i2c.h>
#define DEVICE_NAME "/dev/i2c-2"
#define DEVICE_ADDR 0x38
int main()
{
int fd,i,ret=0;
unsigned char rd_buf[13] = {0x10};
unsigned char wr_buf[13] = {0};
printf("hello,this is read_write i2c test \\\\n");
fd =open(DEVICE_NAME, O_RDWR);
if (fd< 0)
{
printf("open"DEVICE_NAME"failed \\\\n");
return -1;
}
if (ioctl(fd,I2C_SLAVE_FORCE, DEVICE_ADDR) < 0)
{
printf("set slave address failed \\\\n");
return -1;
}
wr_buf[0] = 0xe1;
wr_buf[1] = 0x08;
wr_buf[2] = 0x00;
write(fd, wr_buf, 3);
while(1)
{
wr_buf[0] = 0xac;
wr_buf[1] = 0x33;
wr_buf[2] = 0x00;
write(fd, wr_buf, 3);
sleep(1);
ret=read(fd, rd_buf, 6);
if (ret != 6)
{
continue;
}
/*
printf("ret is %d \\\\r\\\\n",ret);
for(i=0;i<6;i++)
{
printf("rd_buf is :%d\\\\n",rd_buf[i]);
}
*/
int h1 = 0 ,t1 = 0;
h1 = rd_buf[1];
h1 = (h1<<8) | rd_buf[2];
h1 = (h1<<8) | rd_buf[3];
h1 = h1>>4;
h1 = (h1*1000)/1024/1024;
t1 = rd_buf[3];
t1 = t1 & 0x0000000F;
t1 = (t1<<8) | rd_buf[4];
t1 = (t1<<8) | rd_buf[5];
t1 = (t1*2000)/1024/1024 - 500;
printf("thermo:%d%d.%d",t1/100,(t1/10)%10,t1%10);
printf("humid:%d%d.%d\\\\r\\\\n",h1/100,(h1/10)%10,h1%10);
printf("\\\\r\\\\n");
sleep(1);
}
close(fd);
return 0;
}
简单修改一下,编译执行。
妥妥的获取到了当前环境中的温湿度
更多回帖