我试图通过串行连接(GPIO UART引脚)在Raspberry Pi(B型号,raspian wheezy)和STM32F4板之间发送/接收数据.
要设置串口,我按照以下几个教程中的所有步骤进行操作:http://elinux.org/RPi_Serial_Connection#Preventing_Linux_using_the_serial_port
当无法获取到STM32F4板的连接,我读了你可以在本地测试的PI串口,如果你只需连接TX,RX引脚关PI海誓山盟,它应该只是重复Minicom中输入的数据.
遗憾的是,这也不起作用.
文件'cmdline'和'inittab'中ttyAMA0的设置正常.(如许多教程中所述)
并且还尝试了https://github.com/lurch/rpi-serial-console的自动配置程序
直接将RX连接到rpi上的TX引脚不会在minicom中提供任何输出.我还尝试了一个重复给定输入的python脚本.似乎什么都没有用,我有点迷失在这里.
Minicom启动命令应该是正确的(尝试使用不同的波特率):
root@raspberrypi:/home/jef# minicom -b 9600 -o -D /dev/ttyAMA0
OPTIONS: I18n
Compiled on Apr 28 2012, 19:24:31.
Port /dev/ttyAMA0
Run Code Online (Sandbox Code Playgroud)
在minicom的底部,它总是显示离线状态:
CTRL-A Z for help | 9600 8N1 | NOR | Minicom 2.6.1 | VT102 | Offline
Run Code Online (Sandbox Code Playgroud)
当使用python nothinig检查可用的串口时,会抛出:
python -m serial.tools.list_ports
no ports found
Run Code Online (Sandbox Code Playgroud)
用户在dailout组中,因此不应该是问题(以root和non root身份尝试):
root@raspberrypi:/home/jef# id
uid=0(root) gid=0(root) groups=0(root),20(dialout),1001(indiecity)
Run Code Online (Sandbox Code Playgroud)
验证getty不再使用串口:
root@raspberrypi:/home/jef# ps aux | grep getty
root 2809 0.0 0.1 3740 804 tty1 Ss+ 10:36 …Run Code Online (Sandbox Code Playgroud) 我写了一个函数来查找最接近提交的时间戳的表中的时间戳.查询在Mysql中自行运行正常(通过phpmyadmin测试).但是当我通过php脚本执行它时,结果总是为NULL.
脚本和其他函数中的所有其他查询都正常工作.也没有错误.我必须遗漏一些但却看不到的东西.任何帮助在这里表示赞赏.
功能:
function GetClosestMatch($timestamps){
global $mysqli;
$closestmatch = array();
foreach($timestamps as $timestamp){
if($stmt1 = $mysqli->prepare("SELECT DISTINCT timestamp FROM winlog_data ORDER BY ABS(timestamp - ? ) LIMIT 1")){
mysqli_stmt_bind_param($stmt1,"i", $timestamp);
mysqli_stmt_execute($stmt1);
mysqli_stmt_store_result($stmt1);
mysqli_stmt_bind_result($stmt1, $db_timestamp);
$closestmatch[] = $db_timestamp;
}
}
return $closestmatch;
}
Run Code Online (Sandbox Code Playgroud)
时间戳数组:
array (size=12)
0 => int 1451602800
1 => int 1454281200
2 => int 1456786800
3 => int 1459461600
4 => int 1462053600
5 => int 1464732000
6 => int 1467324000
7 => int 1470002400
8 => int …Run Code Online (Sandbox Code Playgroud)