Serial (RS232) <-> Socket communication on TPS
Power Tibbit #09 or #10 or #33,#18, Connector Tibbit #19, #20 and RS232 Tibbit #01
Female-to-Female DB9 cable
Power source to power TPP2G2 board
Router for LAN Network
TPP2-G2 TiOS firmware (4.00.01)
TDST (Tibbo Device Server Toolkit)
TIDE (Tibbo Integrated Development Environment)
Drivers of respective manufacturer of USB-to-RS232 cable pre-installed on your computer
IO Ninja Application pre-installed on your PC
TPP2-G2 (TPS) Connection Layout:
TPP2-G2 board (TPS) with RS232 Tibbit #01 with Tibbit #19 (DB9 Connector) connected to the PC over Ethernet and USB port. You can involve the LAN network between the PC and TPS or connect directly and assign the IP addresses to PC and TPS from the same subnet.
To connect to TPS over serial and ethernet, we use the IO Ninja application; you can install the IO Ninja application from here; at the start, you can use the free subscription and later, you can buy the plugins as per your project requirements. In my case, I am using a Serial session and a TCP (Client) session.
Relating to the USB-to-Serial cable, you can download the drivers for your Windows PC from the respective manufacturer website. After installing the drivers and connecting the cable, you should detect the Serial COM port in the Device Manager under Ports (COM and LTP). In my case, the COM port number is "6", which you will get in the drop-down pallet of the IO Ninja Serial session.
CODY for Startup:
Generate the project using Cody by selecting the TPP2G2 board as your device and adding the respective Tibbits shown in the connection layout.
CODY will define the Serial and Socket port, and the user can select the respective parameters like baud rate, parity, flow-control and data bits. For the socket, the parameters are Name of the socket, Client/Server, Protocol (TCP/UDP), listening ports, Network Interfaces (WIFI/Ethernet/PPP) on which this socket will be available.
In my case, I selected the parameters shown in the above snapshot, making the TPS as TCP server listening on port "5555" and Serial (RS232) with disabled flow-control and baud rate of 38400. You can change these parameters as per your project requirements. The respective code structure is generated by CODY, which you can check in real-time in CODY itself.
The code is almost perfect using TPP2G2 as a selected device in CODY, but we need to add a few lines of code to redirect the data from Serial-to-Socket and vice-versa. You need the respective code under the events called "on_sock_data_arrival" and "on_ser_data_arrival".
dim x as string
if sock.num=S1_SOCK_NUM then
dim y as string
if ser.num=SER_TBT01_S1 then
Connect the TPP2G2 board to the power supply and LAN network and compile the application to check for errors. After compiling, select the target device (TPP2G2) and start to debug.
Open the Serial Sessions and TCP connection session (Client) in the IO Ninja application on your PC. Connect the TCP socket by filling the respective IP address and port of the TPP2G2, defined by you on the TCP socket using CODY. Connect the Serial COM port with the correct baud rate and flow control (disable) in IO Ninja. If all goes well, both the serial and socket connects without any errors, then you can use the "Text" tab in IO Ninja to send small chunks of data in text mode, or you can choose the "File" tab to send a large file for data transfer. Do check the TX and RX bytes; you can also compare the Checksum calculator to match the CRC values in TCP and Serial session of IO Ninja for any data loss during the transfer.
The final results will appear like this.