Protocol for PBH-204 to Control Digital Input and Output Port

Today we are going to introduce a protocol to control digital input and output ports(DIOs) which can be used with PBH-204.

Existing Sollae Systems’  remote I/O device servers use a protocol called Modbus/TCP. If a user uses a ModMap program we provide, there is no problem with running the remote I/O device servers.

However, you are required to realize a Modbus/TCP on your own for a programmable device server, which may or may not that complicated. So, we want to show you making a simpler protocol than the Modbus/TCP with PHPoC for those who have difficulty with realizing it.

1. A goal of the protocol design and restrictions

To make a structure of the protocol as simple as possible, we set a goal and restrictions.

  • A protocol to control DIOs, which can be used instead of the Modbus/TCP and used to control DIO.
  • Meaningful data such as a control command, port number can be shown as 1 byte size number and those numbers can be composed in a row.
  • Cannot send a command packet in a row, or cannot send multiple commands in one packet.
  • After receiving a response packet to a command packet, another command packet can be sent.

In summary, the protocol consists of a single digit number.

2.  Command type

The commands support reading values from DIO or changing output ports’ state as shown below.

[Explanation of the Commands]


Now, let’s take a look at the command structure in detail.

[Command 1 and 2]

(1)  Request Packet

A request packet command that query the status of the DI or OD has the following structure.


“N” specifies the number of ports of you want to know the status, and specify the port number in the following byte. Port number starts from 0. There are 4 of each DI and DO for PBH-204, so the range of available port numbers is 0 to 3.

For example, when you make 4 bytes like “2203″ applyng into the above structure, it becomes a request packet to retrieve the 0th and 3rd output port.

(2) Response Packet

(2-1) If a request is successful:

If a process of a command completes successfully, a response packet is in the following structure.


The response code is 1. ”N” means the number of port. After the “N”, port number and port status are followed. For the port status, we use 0 for OFF and 1 for ON.

For example, 7 bytes like “1220130″ applying into the above structure, it becomes a response packet for the output port; 0 is ON(1) and 3 is OFF(0).

(2-2) If a request fails:

If the process of the command fails, a response packet is in the following structure.


A structure of the response to the failure is in the following table.


[Command 3 and 4]

(1) Request Packet

A request packet to check all of DI or DO status is 1 byte.


(2) Response Packet

This packet structure is the same as the response packet for command 1 and 2. Please scroll up to find the explanation.

[Command 5]

(1) Request Packet


“N” specifies the number of ports of you want to change the status. After the “N”, port number and port status are followed.

For example, 6 bytes like “520121″ applying into the above structure, it becomes a request packet for the output port: 0 and 2 are ON in this case.

(2) Response Packet

(2-1) If a request is successful:

If a process of the command 5 completes successfully, a response packet(2 bytes) is in the following structure.


For the response code, we use 1.

(2-2) If a request fails:

This is the same as when the command 1 and 2 request fails.

[Command 6]

(1) Request Packet

This response packet, composed with two bytes, changes all DO status to be in the same state at the same time.


0 indicates OFF and 1 indicates ON for the status of the output port.

(2) Response Packet

Since it is changing the status of DO, this is the same with the command 5′s response packet.

We attached a PHPoC language based program source code and a program for window to do the control test for PBH-204. You may download and test these.




This is the end of this posting! Thank you for reading!

Client Multi-Monitoring

This posting is about how to enable a serial device to be monitored by several servers. We used PBH-101 for this test.


To send data from a serial device to a maximum of four hosts at the same time.


Please refer to the following link:


PBH-101 operates as a client, and  it saves information of up to four servers. When PBH-101 receives data from a serial device, it sends the data to the certain saved servers.  그림1

[Development Process]

1. Making an UI

We made an UI with a sample source to configure setting values. The sample source can be downloaded in Sollae Systems’ PHPoC forum. ( > Download > PHPoC Library & Sample Code)

Please follow a file route of the sample source below :

[example] -> [www] -> [pbh_setup] -> index.php, sc_envs.php, setup.php, setup_ok.php, favicon.ico

Among these files, we opened “setup.php” and modified it.

- setup.php그림3

We made input boxes of server’s IP addresses (serverip1~4) and listening port numbers (serverport1~4).  그림2

2. Saving Data of a Server

We used a sample source ”setup_ok.php” to save data of servers. We stored a value passed in from the “setup.php” to user env area. Its format is “serverip1 value; serverip2 value; serverip3 value; serverip4 value; serverport1 value; serverport2 value; serverport3 value; serverport4 value;” and we saved all in once to a variable names $server.


We inserted server information, and saved it.

3. Checking Stored Information from the Web

To check which value is stored, we brought data from envu user area in “setup.php”. Its format (serverip1 value; serverip2 value; …) is separated by a semicolon(;) to parse individual values.

A function to separate called explode(). For example $server = explode(“;”, $server); will create an array, and the data will be saved as $sever[0] = “serverip1 value”, $sever[1] = “serverip2 value”… $server[7] = “serverport4 value”. We tried to put it to the value of the array with the matching variables.


In order to ensure that the storing was successfully done, we put the parsing value into the input box value.



We made sure that it was loaded well in a web page. 그림7

4. The Actual Connection Operation and a Data Communication

First of all, we proceeded development using the sample source.

[example] -> [pbh_101] -> 101_uart_tcp_ac.php

We copied the contents and pasted to the “init.php”. After opening the sample code, you can find two included libraries that are stated in the first row.

[lib] -> sd_101.php, sn_tcp_ac.php

You must include two files for the Uart and TCP communication.



Like “setup.php”, we brought data from envu user area (please refer to the step 3). PBH-101 used tcpn_client() with the parsed value to connect to the servers. It was connected with 4 servers at the same time, and after the connection it sent data that were read from a serial port to the servers (the first red box in the below image). Also, we added a source for PBH-101 to receive data from the server side (the second red box in the below image).


This was the end of the test!

For those who want to test, please download the following file using PHPoC Debugger. multi_client

Also note that PHPoC tutorial video is here in the following link, so please check out!

Accessing a Console Port through a WebSocket

Today we will go through how to access a console port(Cisco Wireless LAN Controller) with a programmable device server through a web browser. Web-socket is a protocol that allows a browser to communicate bidirectionally straying from a limitation of existing HTTP.

Before using Web-socket, we programmed a Web-socket server and its client in a programmable device server, PBH-101 by using PHPoC Debugger.  1

We used PHPoC Support Package for serial port programming. After all programming is done, we connected a console port of a wireless LAN controller to a serial port of PBH-101.  2

Then we ran a web browser in our computer and access Web-socket client page, and insert an IP address in the address bar with entering  web socket client page. We can see that the access has been successfully made after clicking “Connect” button.  3

When the wireless LAN controller is powered, you can view the output messages via the console port on the browser. 4

Finally, we have logged in to the wireless LAN controller.  5

We logged out after checking the system log information to close the connection with the wireless LAN controller.  6

The process described above can be found in the following video.

Monitoring and Controlling PBH-204 Input/Output Port

This posting is about web-related simple test of PHPoC. We used PBH-204 for the test.


Purpose of this test is to monitor and control input/output ports of PBH-204 through a web browser.

What we need to prepare for this test is in the other posting. Please refer to the link. 

If you are new to Sollae Systems’ PBH-204, please visit our website to find out programmable device server.

Going back to the test, here is a diagram of it.web_ex_diagram    You can simply monitor and control PBH-204′s input and output ports through a web browser.

[Development Process]

1. Making basic framework

We need two files for the process. One is an “index.php” script that has a function to show input/output port status and to control the output port, and the other is “manage.php” which is to get information to provide. In this example, we made a list of Sollae Systems’ contact for those who need technical help. You may make a new list or other script for this page as the way you want. web_ex_base

2. Page composition

These following images are a smartphone browser screen and a real picture of our programmable device server when a connection is made!index_merge (1)


You can recognize two parts in the “index.php” file image below which shows input/output ports. index_button

3. Port status check and output port control

main_code    Red box in the image above indicates important PHPoC codes to check port status. We used dio_in()  from a library, “sd_204.php” to check it. For the part where we control ports, we used dio_out() from the same library.

We used _GET(), the basic internal function, to receive a value for port control. This function can be used to get a value on URL that is transmitted by HTTP GET method.

You may refer to the attached source codes and images as a guide when you carry out the test to create your own web pages! :)

Source code & Images: ex_PBH-204_www

PHPoC Application: Web based Signboard

Programmable device servers (PBH-101, PBH-104, PBH-204) are very easy to control and make a script by PHP based language, PHPoC.

Sollae Systems’ programmable device server is especially useful in WoT(Web of Things) environment because the device server supports making a webpage that is linked with smart phones or other smart equipment.

You may find useful information in Sollae Systems homepage and PHPoC homepage.

Sollae Systems Homepage:
PHPoC Homepage:
This posting is about how to control serial equipment (signboard in this case) by using Sollae Systems’ programmable device server. Below is setup of the application.webcontrol


What we will show you is Web-based Internet Signboard. To test the simple application, we prepare a signboard, which communicates via RS232, and programmable device server(PBH-101). Then, we are making it accessible from your smartphone, tablet, or PC, whichever can use a web-browser.pbh101_signboard


Next is to send messages to the signboard. We use open source from the signboard controller company, and use PHPoC Debugger program to make up a source that runs the application.phpocd


Then we made a user UI to send messages from a  webpage. PHPoC is compatible with a PHP scripting language, so it is very easy to develop it. As you already know from the above, we use PHPoC Debugger to program, and made index.php with HTML tag and CSS for the webpage UI as shown below.123


This can be shown on the browser below.index_capture

We must download two files of signboard communication that are created by PHPoC Debugger to the programmable device server through a USB port. Then, we connect the signboard with it by a serial cable.

Now everything is ready to test the application!

After accessing to the programmable device server through the web, we can send messages by clicking “Send” button.index_send_message

Below is is the result of what we have done!사진

Thank you for reading! :)