华为云IoT智慧物流案例04 | 4G网卡拨号(广和通L610-CAT.1模组)与北斗定位模组(中科微电子)数据解析

本文介绍了如何使用广和通L610-CAT.1模组进行4G网络拨号,并通过PPP脚本实现网络功能。同时,讲解了北斗定位模组的数据解析,包括连接、数据获取和定位信息解析。该案例对于物联网智慧物流中的设备通讯与位置追踪具有指导意义。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

华为云IoT智慧物流案例04 | 4G网卡拨号(广和通L610-CAT.1模组)与北斗定位模组(中科微电子)数据解析

回顾

衔接上个章节,稍微调整代码,令1个IIC接口同时接入2个设备并获取数据。
程序修改
1
2
3
4
5

//作者:实柏
//日期:2021-6-30

/************************************************************/
//包含头文件
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/ioctl.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/select.h>
#include<sys/time.h>
#include<errno.h>
//宏定义

#define SHT30_Address                               0x44         //1000100
#define BH1750_Address                              0x23         //0100011
#define I2C_RETRIES                                 0x0701
#define I2C_TIMEOUT                                 0x0702
#define I2C_SLAVE                                   0x0703       //IIC从器件的地址设置
#define I2C_BUS_MODE                                0x0780

typedef unsigned char uint8;
int fd = -1;

//函数声明
static uint8 dev_Init(void);
static uint8 BH1750_IIC(void);
static uint8 SHT30_IIC(void);
static uint8 BH1750_Dat_To_Lux(uint8* buf);

//
static uint8 dev_Init(void)
{
    fd  = open("/dev/i2c-0", O_RDWR);               // open file and enable read and  write

    if (fd < 0)
    {
        perror("Can't open /dev/BH1750 \n");       // open i2c dev file fail
        exit(1);
    }

    printf("open /dev/i2c-0 success !\n");          // open i2c dev file succes
    
}

static uint8 BH1750_IIC(void)
{
    if (ioctl(fd, I2C_SLAVE,BH1750_Address) < 0)
    { //set i2c address
        printf("fail to set i2c device slave address!\n");
        close(fd);
        return - 1;
    }

    printf("set slave address to 0x%x success!\n", BH1750_Address);
  
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值