2013-03-11 1 views
1

리눅스에서 시리얼 포트를 통해 마이크로 컨트롤러와 통신하려고합니다. 나는 목적을 위해 직렬 케이블에 USB를 사용하고,하지만 내 PHP 스크립트는 나에게 다음과 같은 오류주고있다 :리눅스 직렬 통신, PHP 스크립트 문제

치명적인 오류 : 정의되지 않은 함수 deviceSet() 여기

에 전화하는 내 스크립트

입니다
error_reporting(E_ALL); 
ini_set('display_errors', '1');  //displays php errors 

include("php_serial.class.php"); 

$serial = new phpSerial(); 

deviceSet('ttyUSB0'); //for linux serial /dev/ttySP(0-4) for usb /dev/ttyUSBN 

// If you want to change the configuration, the device must be closed 
//$serial->deviceClose(); 
$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(2); //Stop bits (this is the "1" in "8-N-1") 
$serial->confFlowControl("none"); 

$serial->deviceOpen(); 
// To write into $serial->sendMessage("1"); 
$read = $serial->readPort(); 

필자는 php_serial.class 파일이 USB를 통해 직렬 연결을 실행하는 데 문제가 있는지 의문의 여지가 있습니까?

# dmesg | grep tty 
console [tty0] enabled 
usb 3-2: FTDI USB Serial Device converter now attached to ttyUSB0 
ftdi_sio ttyUSB0: ftdi_submit_read_urb - failed submitting read urb, error -1 

감사 :이 문제가있는 것처럼

또한 보인다.

본인은 $ 시리얼 편집 -> deviceSet() 지금

지정된 직렬 포트 라인 (111) 경고에 /var/www/html/php_serial.class.php에서는 유효하지 않습니다 표시 오류의 무리 : 없음 전송률을 설정하려면 장치가 설정되지 않았거나 /var/www/html/php_serial.class.php 204 행에 있습니다 경고 : 패리티를 설정할 수 없습니다 : 장치가/var/www에 설정되거나 열리지 않았습니다. /html/php_serial.class.php on line 254 경고 : 문자의 길이를 설정할 수 없습니다 : 장치는 298 행의 /var/www/html/php_serial.class.php에서 설정되거나 열리지 않습니다 경고 : 설정할 수 없습니다 정지 비트 길이 : 장치가 설정되지 않았거나 335 행의 /var/www/html/php_serial.class.php에 열리지 않았습니다. 경고 : 흐름 제어 모드를 설정할 수 없습니다 : 장치가 설정되어 있지 않거나 열려 있습니다 /var/www/html/php_serial.class.php in line 376 경고 : 장치가 /var/www/html/php_serial.class.php에서 열리기 전에 설정되어야합니다. 경고 : 장치를 열어야합니다 줄에 /var/www/html/php_serial.class.php에서 읽어 474

이이 php_serial.class

+1

'deviceSet는()'네이티브 PHP 함수가 아닙니다. 어디에서 기대하고 있니? –

답변

1

deviceSet()에 문제가하면 시리얼 클래스의 방법이다. 당신이 그것을 부르는 방식으로, 그것은 네이티브 PHP 함수가 될 필요가 있습니다.

이 있어야한다 : $serial->deviceSet('ttyUSB0');

+0

내 게시물을 편집 해 주셔서 감사합니다. – user2137005

+0

코드의 주석처럼/dev/ttyUSB0을 사용해보십시오. – mkaatman

+0

덕분에 큰 도움이되었습니다. – user2137005