当前位置:网站首页>Raspberry Pie: the serial port has been unable to read the information sent by the upper computer
Raspberry Pie: the serial port has been unable to read the information sent by the upper computer
2022-07-24 09:45:00 【Jiang tengxia】
Raspberry pie serial port has been unable to read the information sent by the upper computer
Error message :
No error message …( What programmers fear most is that they don't report errors BUG Is that right ).
however , Strangely enough , After entering the value from the keyboard , Enter again , Something magical has happened .....
Raspberry pie takes the value I input from the keyboard as a serial command !!
reason
When writing the startup serial port code , You can't write that
Control_Voice.c Under the document
// Error code :
int init_Voice(struct Command *cmd ,char *ip,char *port){
int fd;
if(fd = serialOpen("/dev/ttyAMA0",9600) == -1){
/* After debugging , In this way if In the sentence , Assign to fd The value of is 0, yes 0 ah ! Guys !!! Although the document says, it's not -1, The normal value is returned ,( I believe you're a ghost !!!) But there are problems here ~~~~*/
exit(-1);
}
cmd->fd = fd;
return fd;
}
correct
int fd;
fd = serialOpen("/dev/ttyAMA0",9600); // Purple sauce is OK
if(fd == -1){
exit(-1);
}
cmd->fd = fd;
return fd;
4、
if(fd = serialOpen("/dev/ttyAMA0",9600) == -1){
/* After debugging , In this way if In the sentence , Assign to fd The value of is 0, yes 0 ah ! Guys !!! Although the document says, it's not -1, The normal value is returned ,( I believe you're a ghost !!!) But there are problems here ~~~~*/
exit(-1);
}
cmd->fd = fd;
return fd;
}
correct
int fd;
fd = serialOpen("/dev/ttyAMA0",9600); // Purple sauce is OK
if(fd == -1){
exit(-1);
}
cmd->fd = fd;
return fd;
边栏推荐
- 详解LinkedList
- ThreeJs
- An article takes you to understand the operation of C language files in simple terms
- 07 Jason module
- [Luogu p5829] [template] mismatch tree (string) (KMP)
- Basic knowledge of PHP - complete collection of PHP functions
- [don't bother to strengthen learning] video notes (III) 3. SARS (lambda)
- Why add where exists() to the update select statement? And update with a with statement
- What's the difference between testing / developing programmers' professionalism and salted fish? They don't want to be excellent coders?
- How to improve office efficiency through online collaborative documents
猜你喜欢
Gin framework uses session and redis to realize distributed session & Gorm operation mysql

Compilation and linking of programs

Spark Learning: using RDD API to implement inverted index
![CAS principle [concurrent programming]](/img/f0/77e7e1079f70198c601b0f1e25106e.png)
CAS principle [concurrent programming]
![Cyclicbarrier and countdownlatch [concurrent programming]](/img/38/3305a0cdb6de40e1370cc93c8e5014.png)
Cyclicbarrier and countdownlatch [concurrent programming]

This article takes you to understand the dynamic memory allocation of C language

Aruba学习笔记06-无线控制AC基础配置(CLI)
![[note] what is kernel / user space? Let's start with how the CPU runs the program](/img/b5/0ab4f2841faf3573b4502d2cd09069.png)
[note] what is kernel / user space? Let's start with how the CPU runs the program

Little dolphin "transformed" into a new intelligent scheduling engine, which can be explained in simple terms in the practical development and application of DDS

Scarcity in Web3: how to become a winner in a decentralized world
随机推荐
Installation UMI tutorial (error reporting and solutions)
Spark Learning: build SQL to meet the specified optimization rules
This article takes you to understand the dynamic memory allocation of C language
CUDA day 2: GPU core and Sm core components [easy to understand]
MySQL status view qps/tps/ cache hit rate view
SQL optimization principles
[don't bother with reinforcement learning] video notes (I) 3. Why use reinforcement learning?
[note] what is kernel / user space? Let's start with how the CPU runs the program
Leetcode skimming: dynamic planning 03 (climb stairs with minimum cost)
[example] v-contextmenu right click menu component
Lung CT segmentation challenge 2017 dataset download and description
NVIDIA set persistent mode
Li Kou 300 longest increasing subsequence dynamic programming
[C language] implementation of three versions of address book small project (including source code)
The next stop of data visualization platform | gifts from domestic open source data visualization datart "super iron powder"
[don't bother with intensive learning] video notes (III) 1. What is SARS?
Vim: extend the semantic analysis function of YCM for the third-party library of C language
Getting started with sorting - insert sorting and Hill sorting
PHP Basics - PHP magic constants
Firewalld firewall related commands