Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用C语言实现串行通信_C_Serial Port_Uart - Fatal编程技术网

用C语言实现串行通信

用C语言实现串行通信,c,serial-port,uart,C,Serial Port,Uart,我试图读取msp430fr5739微控制器的车载温度传感器,并在终端上显示结果 使用C任务应该完成 可以在上找到所有代码和自定义库 我的操作系统是ubuntu,我使用的IDE是 这是主菜单 #include <msp430fr5739.h> #include "system.h" #include "temp.h" #include "uart.h" /* main.c 1. Switches and LEDs 2. 3. Temp sens */

我试图读取
msp430fr5739
微控制器的车载温度传感器,并在终端上显示结果

使用
C
任务应该完成

可以在上找到所有代码和自定义库

我的操作系统是ubuntu,我使用的IDE是

这是主菜单

#include <msp430fr5739.h>
#include "system.h"
#include "temp.h"
#include "uart.h"
/*
    main.c
    1. Switches and LEDs
    2.
    3. Temp sens
 */ 

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

    unsigned int tempVal = 0;   // temp readings

    LEDs_INIT();                // Init leds
    SWITCHEs_INIT();            // Init Switches    
    serialBegin();              // Begin Serial communication at 9600 buad

    while (1)
    {
        __bis_SR_register(LPM4_bits + GIE); // Enter LPM4 with interrupts enabled
        tempVal = getThermisterVal();

    }
    return 0;
}
#包括
#包括“system.h”
#包括“温度h”
#包括“uart.h”
/*
main.c
1.开关和LED
2.
3.温度传感器
*/ 
内部主(空){
WDTCTL=WDTPW | WDTHOLD;//停止看门狗定时器
无符号int-tempVal=0;//临时读数
LED_INIT();//初始化LED
开关_INIT();//初始化开关
serialBegin();//在9600 buad开始串行通信
而(1)
{
__bis_SR_寄存器(LPM4_位+GIE);//在中断启用的情况下输入LPM4
tempVal=getherMisterVal();
}
返回0;
}
我试着按照主板附带的代码进行操作,结果lib发布在上(我没有发布所有lib和代码,只是因为太长)

现在我真的在努力解决串行通信部分,我知道从微控制器发送的字节必须由PC上的某种串行监视器应用程序读取。
感谢您的帮助

使用libserialport()。如果你愿意的话,我制作了一个兼容cmake的版本:()。@Scott,一些示例代码会很好:)我的意思是,它确实取决于应用程序。Libserialport使用起来相对简单(这里有大量的doxygen文档:),但您必须解析从MCU中输出的数据,这取决于数据的序列化方式。是的,没错!我只是想从你的fork中
make
llib,它会导致无法计数的失败,例如
CMakeFiles/serialport shared.dir/build.make:62:target'CMakeFiles/serialport shared.dir/serialport.c.o'的配方失败make[2]:***[CMakeFiles/serialport shared.dir/serialport.c.o]错误1 CMakeFiles/Makefile 2:67:目标“CMakeFiles/serialport shared.dir/all”的配方失败生成[1]:***[CMakeFiles/serialport shared.dir/all]错误2 Makefile:83:目标“all”的配方失败
是否使用MinGW?如果您使用的是Unix/OSX,我将使用标准的libserialport repo。如果您需要windows LIB,请告诉我,我可以为您编译它们。如果你愿意的话,我制作了一个兼容cmake的版本:()。@Scott,一些示例代码会很好:)我的意思是,它确实取决于应用程序。Libserialport使用起来相对简单(这里有大量的doxygen文档:),但您必须解析从MCU中输出的数据,这取决于数据的序列化方式。是的,没错!我只是想从你的fork中
make
llib,它会导致无法计数的失败,例如
CMakeFiles/serialport shared.dir/build.make:62:target'CMakeFiles/serialport shared.dir/serialport.c.o'的配方失败make[2]:***[CMakeFiles/serialport shared.dir/serialport.c.o]错误1 CMakeFiles/Makefile 2:67:目标“CMakeFiles/serialport shared.dir/all”的配方失败生成[1]:***[CMakeFiles/serialport shared.dir/all]错误2 Makefile:83:目标“all”的配方失败
是否使用MinGW?如果您使用的是Unix/OSX,我将使用标准的libserialport repo。如果您需要windows LIB,请告诉我,我可以为您编译它们。