Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Usman Didi Khamdani  >  Check Active Comm-Ports Class  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: select a comm-port with baud rate
Class: Check Active Comm-Ports Class
Retrieve the list of active COM ports on Windows
Author: By
Last change:
Date: 5 years ago
Size: 1,104 bytes
 

Contents

Class file image Download
<?php

include('check_active_comm_port.class.php');

if(isset(
$_POST['comm'])) {

    if(
$_POST['comm']=='None') {
        echo 
'There\'s no active comm-port that can be used. Please check the connection<br />
        (Right Click on My Computer->Select Properties->Hardware->Device Manager->Ports (COM & LPT))<br />
        If there is a comm-port is active, make sure that it is not being used'
;
    } else {
        echo 
'Port = '.$_POST['comm'].'<br /> Baud Rate = '.$_POST['baud'];
    }


} else {

    
$com = new windows_comm_port();
    
$comm_list $com->comm_list();
    
$baud_list $com->baud_list();

    
$count count($comm_list);
    
$count2 count($baud_list);

    echo 
'<form action="'.$_SERVER['PHP_SELF'].'" method="post">
    Port <select name="comm">'
;
    for(
$i=0;$i<$count;$i++) {
        echo 
'<option value="'.$comm_list[$i].'">'.$comm_list[$i].'</option>';    
    }
    echo 
'</select> Baud Rate <select name="baud">';
    for(
$i=0;$i<$count2;$i++) {
        echo 
'<option value="'.$baud_list[$i].'">'.$baud_list[$i].'</option>';    
    }
    echo 
'</select> <input type="submit" value="Select" />
    </form>
    <hr />'
;

}

?>