User avatar
richiepp
Posts: 140
Joined: Wed Dec 19, 2012 4:56 pm

Run Picocom in the background

Tue Feb 18, 2014 7:00 pm

I have some PHP that sends serial messages to an Arduino. To get it to work I need to, or so it seems, to have a serial terminal open on the pi. I'm using Picocom which I can run in the background by typing

picocom /dev/ACM0 &

After that the PHP communicates with the Arduino through serial. But if I end my Putty session and close my terminal it no longer works. So I created a shell script to run at reboot

Code: Select all

#!/usr/bin/bash
picocom /dev/ttyACM0 &
In my sudo crontab I have the following

Code: Select all

@reboot /var/www/cgi-bin/serial-open-port.sh
Despite this Picocom doesn't seem to be running and no serial signals are sent. My PHP is essentially the example from the PHP Serial Class example.

Code: Select all

<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
include "php_serial.class.php";

$serial = new phpSerial;
$serial->deviceSet("/dev/ttyACM0");
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->deviceOpen();
$serial->sendMessage("0");

$serial->deviceClose();

echo "We sent a zero";
?>

User avatar
richiepp
Posts: 140
Joined: Wed Dec 19, 2012 4:56 pm

Re: Run Picocom in the background

Tue Feb 18, 2014 7:01 pm

How can I keep the serial port open and available for PHP and other web applications?

Thanks
Rich

frandroid
Posts: 1
Joined: Sun Nov 15, 2015 3:19 pm

Re: Run Picocom in the background

Sun Nov 15, 2015 3:21 pm

I've the same issue. I always need to start picocom (the serial service I use) manually after every boot. I've tried to start it automaticaly but no succes so far... I am currently working on it. If you have solved it I would like to know how.
If I find a solution I wil surely post it here!

Return to “Other programming languages”