serial-port connection to laravel

Viewed 31

I am new to laravel so I am trying to get data from serial port (balance) and updated in my sql or send the data to web application. I wrote code using python and it works fine but laravel seems to understand serial package as model so I tried to write it with php but still it doesn't read well. The question is how to access serial port of the client using website + if it is only could be dony by py how tolet python integrate with laravel
so any ideas ..

python

import time
import serial
from serial import Serial
serials=""
ser=serial.Serial('COM5',9600)
time.sleep(0.5)

time.sleep(1.5)
while 1:
    print(ser.readline())
    print(ser.readline())
    print(ser.readline())

..

php
$output = `mode COM3: BAUD=9600 PARITY=N data=8 stop=1 XON=off TO=on`;
            $fp = fopen('COM3', 'r+');

if (!$fp)
{
      echo "Port not accessible";
}
else
{
     echo "Port COM1 opened successfully";
}
$writtenBytes = fputs($fp, "Hello");

echo"Bytes written to port: $writtenBytes";
$buffer = fgets($fp);
$buffer = fgets($fp);
$buffer = fgets($fp);
$buffer = fgets($fp);

echo "Read from buffer: $buffer";

..

0 Answers
Related