Search results

  1. K

    ssh_connect

    I've been using the following script snippet to connect to a remote server in order to run lm-sensors on the remote server and it's worked fine (I've changed the IP and password for this post of course) $connection = ssh2_connect('xxx.xxx.xxx.x', 22); ssh2_auth_password($connection, 'root'...
  2. K

    fseek

    I want to read a binary file, 128 bytes at time, perform some other code and come back to the file and pick up at the next 128 bytes, continuing until feof Will this do it? fseek($file,1,SEEK_CUR);
  3. K

    xmodem?

    Yea I know it's an old protocol but still... Anyone figure out how to do it in PHP? Searching the forum turns up nothing xmodem related
  4. K

    Event Stream handling

    I am trying to get server sent event streams working. As a test, I placed the following in a php file: header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); // recommended to prevent caching of event data. function sendMsg($msg) { echo "data: $msg" . PHP_EOL...
  5. K

    Includes

    I have a file (global.php) that used by many different other files in a project I'm doing. This file contains many things including connecting to a MySQL database as well as loading a php_serial_class. So at the top of php file that needs these resources, I use include("global.php"); In one...
  6. K

    Connection to `ssl://pear.php.net:443' failed:

    As the title says. I'm trying to install the dio-0.2.0 package (Raspian Buster) and first did a pecl list-all and the above was returned Help?
  7. K

    Script run from crontab

    I have a script that is called from crontab. : 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/php /var/www/settime.php I checked back later and notice many instances of php running: root@mypi:~# ps aux |grep settime root 1646 0.0 0.0 1856 380 ? Ss 10:20 0:00...
  8. K

    Fgets() timeout?

    I have a USB to serial converter (/etc/ttyUSB0) that I read from, using fgets. I'm looking for a way, that if nothing is received with a few seconds, the script terminates. As in a "serial timeout". Of course, fgets seems to hang forever if it never sees a EOL and I need a way around that
  9. K

    I don't see the error with this array

    $handle = fopen("/etc/rpt.fifo", "r") or die("Unable to open file!"); $buffer = trim(fgets($handle)); $ary = explode (",", $buffer); $x = $ary[2]; print $x; flush(); pclose($handle); When I run it, it reports: Notice: Undefined offset: 2 on...
  10. K

    Opening a "terminal window" from php

    Here's the scenario: From a php created webpage, I'd like to open some sort of terminal window that runs a python script. My python script includes a progress indicator ("command line" type) and then close the window after the script is finished. The problem I've seen with calling shell or...
  11. K

    Passing class to Function

    I'm using php_serial.class.php, called once require_once("php_serial.class.php"); and call it $serial: $serial = new phpSerial; in a global.php file that sets up the serial com parameters. In another file, I include global.php that contains my other code to send and read from the class In...
  12. K

    Differences in php/MariaDB between Raspbian and "regular" Debian?

    Perhaps this isn't the place for this but I've run into a problem moving code from a development server (running Debian Buster on a Pentium PC platform) to a Raspberry Pi, running Raspbian Buster. I have a bit of php code that doesn't throw any errors but doesn't display its webpage properly (it...
  13. K

    Help with INNER JOIN and aliases

    I'm taking over existing code from someone else but I am kind of a newbie with MySQL. Not a complete newbie but not overly experienced either. One of the php files calls a database table named "config" and loads a webpage with the info, using the following code: SELECT m.sub ...
  14. K

    Looking for a simple timer, so why doesn't this work?

    $start = intval(date(s)); echo "Start " . "$start\r\n"; Sleep(1.0); $stop = intval(date(s)); echo "Stop " . "$stop\r\n"; echo "Elapsed time is " . $stop - $start . "\r\n";
  15. K

    4 bytes to float (single)

    Take the following 4 bytes, stored in the order shown: 0, 0, 220, 66 The above bytes represent the number 110.0, stored as (from the compiler I use for embedded processor work) as a "single", which they define as a "signed 32 bit binary number". I take that to be the same as a float How can I...
  16. K

    Exracting the high and low nibble of a byte

    Take the following code that reads in the following lines from a text file: 1,161 2,169 3,1 4,0 5,117 Each value after the comma is a byte that contains 2 bytes (with a value of 0 - 15) that were stored by shifting a 1st byte to the left. You get the idea... $myfile = fopen("test.mem"...
  17. K

    Why doesn't this work under PHP 7?

    <?php $sub = "12"; if(strlen($sub < 3)){$sub = "0" . $sub;} echo "$sub\r\n"; ?> I'd expect the result to be 012 but it's 12
  18. K

    $.get call not working

    The python script works fine and should return HTML. I don't see the output of the python script on the calling HTML page. <HEAD> <link rel="stylesheet" type="text/css" href="stylesheet.css"> </HEAD> <body style="text-align:center" onload="myFunction()"> <H3>Your firmware is being loaded...
  19. K

    Why doesn't this call the php file I think it should?

    This is just test of something but it should work, right? (yes, jquery.js in the same directory as this php file. And this is also on Linux if that matters) <script src="jquery.js"></script> <script> function myFunction() { $.GET("otherphpfile.php"); return false; } </script>...
  20. K

    Reading serial port doesn't work if called from function

    I posted about having problems calling a class from within a function a few weeks ago. As it turns out, the problem seems to be more that of accessing hardware from a function. The following code DOES echo the value of read /dev/ttyS0 for me (Debian): <?php $read= fopen("/dev/ttyS0", "r") or...
Back
Top