Tutorial Video
Hardware
- PHPoC Blue or PHPoC Black
- Micro USB to USB Cable (to upload source code to PHPoC Device)
- RS232 Board (PES-2201)
- RS232 to USB cable (DB9 Female)
Quick Steps
Source code of this example is a part of PHPoC Support Packet (PSP). You need to:
- Download PHPoC Support Package.
- Upload example\p4s\01.php_task\06.uart_hello to PHPoC Blue/Black.
- Click "Run" button on PHPoC Debugger.
Source Code
Source files includes:
- init.php: this file is run when PHPoC system is powered or reset. It is used to specify which file is run is system loop.
- task0.php: this file is run in system loop of PHPoC devices.
init.php
This file is run when PHPoC system is powered or reset. It is used to specify that task0.php is run is system loop.
PHP Code:
<?php
system("php task0.php");
?>
task0.php
[Full Code]
PHP Code:
<?php
if(_SERVER("REQUEST_METHOD"))
exit; // avoid php execution via http request
include_once "/lib/sd_340.php";
uart_setup(0, 9600, "N81N");
while(1)
{
uart_write(0, "hello, world!\r\n");
sleep(1);
}
?>
[Explanation]
Source code of this file does:
- Setup UART port (baurate, parity, data bit, stop bit and flow control ).
- Send 'hello, world!' via UART,
See Also
- Hello, World! - Printing Message to PHPoC Debugger Console.
- Hello, World! - Printing Message to Webpage.
- Hello, World! - Using Image on Embedded Web.
- Hello, World! - Sending Message via WebSocket.
- Hello, World! - Drawing on HTML5 Canvas.
Other Resources