如何使用Posix/C函数检查Linux中是否已经打开了串口?我想检查串口的状态,以检查串口是否打开。
我想知道哪些方法适用于:
检查文件描述符以查看串口是否打开
检查串口文件名以查看串口是否打开,在下面的示例中是“/dev/ttyUSB0 0”
--
// This code is for example purposes only
int open_port()
{
int fd;
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd < 0)
{
p
我尝试用PHP在Linux平台上读取串口。
但是我不能读取任何数据。当我尝试使用.net阅读时,这一次我可以阅读。
我使用"php_serial.class.php“类进行串口操作。你可以通过这个链接阅读这个类:
我的代码是这样的:
<?php
include "php_serial.class.php";
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and wi
这是我的C程序(在Linux中)的相关部分:
while (input != ' '){
write(serial_port, msg, sizeof(msg));
//1. here I would like to wait at least 100 us with the Tx line high
//2. followed by at least 8us with the Tx line low
//3. and then repeat the message
input = mygetch();
}
如您所见,每次通过串口发送msg后,我希望将Tx行设置为10
我的工作是机器人,它必须控制使用无线串行通信。机器人在微控制器上运行(通过燃烧一个.hex文件)。我想用我的Linux () PC来控制它。我是新来的串口编程。我能够发送数据,但我不能读取数据。
在微控制器上运行的几段代码:
函数发送数据:
void TxData(unsigned char tx_data)
{
SBUF = tx_data; // Transmit data that is passed to this function
while(TI == 0) // Wait while data is being transmitted
;
}
我使用 (Linux的串口软件)与我的GSM调制解调器进行交互。实际上,现在我正在尝试通过AT命令来使用我的移动服务提供商的一个服务。
我在这里说,我想看看我的余额:
AT+CUSD=1,*555*87*1234#
OK
+CUSD: 1,"this service will deduct you 5cent from your balance, to continue please enter 1",15
因此,在这里我发送了"1",但没有发生任何事情,会话被关闭。
AT+CUSD=1,1
OK
没有发生任何事情,但会话已关闭。
对于普通的手机,输入1后
我正在尝试在系统的一个串口上设置网络接口。
我使用的是beaglebone和Xbee-wifi模块。基本上,我正在尝试使用TCP/IP协议通过串口bu与2个beaglebone进行通信。
我需要通过ssh、telnet或默认的web端口80连接到beaglebone。因此,我不需要在串行接口上使用单个端口。我需要一个新的接口在串口上运行。
有没有办法做到这一点?
硬件: beaglebone black os : angstrom