mysql — я пытаюсь связаться с микроконтроллером через последовательный порт. но мой скрипт 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 Windows (if
// your Linux serial device is /dev/ttyS0 for COM1, etc.)
$serial->deviceSet("COM3");

// Set for 9600-8-N-1 (no flow control)
$serial->confBaudRate(9600); //Baud rate: 9600
$serial->confParity("none");  //Parity (this is the "N" in "8-N-1")
$serial->confCharacterLength(8); //Character length     (this is the "8" in "8-N-1")
$serial->confStopBits(1);  //Stop bits (this is the "1" in "8-N-1")
$serial->confFlowControl("none");

// Then we need to open it
$serial->deviceOpen();

// Read dataa
$read = $serial->readPort();

print "<pre>";
print_r($read);
print "</pre>";

// Print out the data
echo $read;
// print exec("echo 'r9g9b9' > /dev/ttyACM0");
print "RESPONSE(1): {$read}<br><br>";

// If you want to change the configuration, the device must be closed.
$serial->deviceClose();

// If you want to change the configuration, the device must be closed.
$serial->deviceClose();
?>

Это ошибки

Предупреждение: Невозможно установить скорость передачи: в C: \ xampp \ htdocs \ sensorApp \ php_serial.class.php в строке 253

Предупреждение: невозможно установить четность: в строке C: \ xampp \ htdocs \ sensorApp \ php_serial.class.php в строке 299

Предупреждение: невозможно установить длину символа: в C: \ xampp \ htdocs \ sensorApp \ php_serial.class.php в строке 337

Предупреждение: невозможно установить длину стоп-бита: в C: \ xampp \ htdocs \ sensorApp \ php_serial.class.php в строке 375

Неустранимая ошибка: невозможно установить управление потоком: в C: \ xampp \ htdocs \ sensorApp \ php_serial.class.php в строке 424

П.С. как сохранить полученные данные в базу данных mysql

0

Решение

Я предполагаю, что ваш php_serial.class.php это: https://code.google.com/p/php-serial/source/browse/trunk/php_serial.class.php?r=11

Вы должны сначала сделать var_dump($serial) перед настройкой скорости передачи, чтобы увидеть, работает ли инициализация как задумано. Он должен примерно содержать следующее:

_os = "windows";
_windevice = "COM3"_device = "\\.\com3"_dState = 1  // SERIAL_DEVICE_SET

Если это до сих пор работало, откройте оболочку и посмотрите, работает ли ручная настройка скорости передачи:

mode COM3 BAUD=9600
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector