Jump to content

Recommended Posts

Okay lets say I have my hardware, I'm connected to it via terminal. If I press the clear command ("Capital C + enter") it clears the money counter. Now how would I begin sending date via PHP to a serial port? A quick hello world example would be lovely, but if you can't, do you have any good tutorial links?

Link to comment
https://forums.phpfreaks.com/topic/143274-possible/#findComment-751390
Share on other sites

You would need to setup an interface to send commands to be used with those various functions genericnumber provided.  You can make a form with a text field or text area or dropdown or whatever, and use the posted info in one of those functions.  Or you could make links that send command string via GET method.  Or if you're looking for a more real-time solution like if you were to be working from the command prompt, you could look into doing it with ajax.

Link to comment
https://forums.phpfreaks.com/topic/143274-possible/#findComment-751396
Share on other sites

Okay well I read over the exec info on php.net

 

this is what I came up with

 

 
<?php 
for($i = 1; $i <= 2; ++$i){

if($i == 1){ 
$command="cd C:\Program Files (x86)\\teraterm\\";
$output=shell_exec($command." 2>&1");  //system call
print "<pre>$output</pre>\n";          //show output 
print "<br />" . $command;
} else {

$command="TTERMPRO /I";
$output=shell_exec($command." 2>&1");  //system call
print "<pre>$output</pre>\n";          //show output 
print "<br />" . $command;

}

} 

?>

 

I move to the terminal freeware program directory, but once im in the directory I try to execute a command, TTERMPRO /I

 

this is the returns I get

 

 

 

 


cd C:\Program Files (x86)\teraterm\
'TTERMPRO' is not recognized as an internal or external command,
operable program or batch file.


TTERMPRO /I 

 

http://ttssh2.sourceforge.jp/manual/en/commandline/teraterm.html is a list of commands for tera term

Link to comment
https://forums.phpfreaks.com/topic/143274-possible/#findComment-751447
Share on other sites

cd C:\Program Files (x86)\teraterm\

 

 

should be

 

cd "C:\Program Files (x86)\teraterm\"

 

 

so:

 

$command='cd "C:\\Program Files (x86)\\teraterm\\"';

 

 

I don't think PHP uses shell_exec in a traditional shell sense by the way.  What I mean is, if you change the current working directory, I don't know if you will still be in that directory on the next shell_exec call.  Guess you can try it though ;p.

Link to comment
https://forums.phpfreaks.com/topic/143274-possible/#findComment-751457
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.