Difference between revisions of "Bot test"

From Flowcode Help
Jump to navigationJump to search
Line 4: Line 4:
 
|-
 
|-
 
| width="20%" style="color: gray;" | Author
 
| width="20%" style="color: gray;" | Author
| Matrix Ltd.
+
| Matrix TSL
 
|-
 
|-
 
| width="20%" style="color: gray;" | Version
 
| width="20%" style="color: gray;" | Version
| 2.0 (Release)
+
| 1.0 (Release)
 
|-
 
|-
 
| width="20%" style="color: gray;" | Category
 
| width="20%" style="color: gray;" | Category
| Wireless
+
| Comms: Networking
 
|}
 
|}
  
  
  
==[[File:Component Icon cff93310_545b_4948_a8fa_12b119c5f7a7.png|Image]] Bluetooth (EB024, Generic AT) component==
+
==[[File:Component Icon 91049bf5_2436_42dc_947a_c30c86463d98.png|Image]] Network Communications component==
Low level routines for controlling a standard AT Bluetooth interface.
+
A component designed to simplify the process of TCP/IP communications.
Also available in the form of the EB024 Bluetooth E-block.
+
Compatible with most of the Flowcode supported TCP/IP and WIFI components.
 +
A useful building block for creating components such as IoT and Modbus TCP.
  
 
==Examples==
 
==Examples==
===Making a device discoverable===
 
  
Example program to set up the Bluetooth module to be discoverable with a pair key. Any data received is then output onto the LCD component. You can connect to the Bluetooth device using a PC with Bluetooth connection and using software such as Flowcode 6, RealTerm or HyperTerminal. Alternatively you can connect using a smart phone running a terminal emulator app or via another embedded Bluetooth board.
 
{{Fcfile|BluetoothDiscover.fcfx|Bluetooth Discover}}
 
Script 1 contains the AT commands to setup the Bluetooth device to be discoverable with pair key "1234".
 
  
[[File:DiscoverableScript.jpg]]
+
Here are some examples showing the Network Communications component in action.
  
 +
By itself the component provides a generic TCP/IP layer to drive the simulation runtime.
  
===Searching for a device===
+
Here is a simple example showing the component used by itself to request data from a remote server on the internet.
  
Example program to scan for local discoverable Bluetooth devices. For each device found the MAC address is displayed on to the LCD.
+
{{Fcfile|NetworkComms-Client.fcfx|Example Network Comms Client}}
{{Fcfile|BluetoothInquire.fcfx|Bluetooth Inquiry}}
 
===Connecting to a device===
 
  
Example program to connect to a specific Bluetooth device address and send data to the device.
 
{{Fcfile|BluetoothConnect.fcfx|Bluetooth Connect}}
 
The device MAC address is specified using the "CreateCommandString" and "SendCommand" macros.
 
  
[[File:ConnectToMAC.jpg]]
+
===Library Components===
  
==Downloadable macro reference==
+
Components such as [[Component:_Webserver_(GENERIC_ROM_FAT)_(Comms:_Networking)|Webserver (GENERIC)]], [[Component:_MQTT_Client_(Comms:_System)|MQTT]] and [[Component:_Modbus_TCP_Master_(Comms:_System)|Modbus TCP]] can connect to and control the network comms layer.
  
===<span style="font-weight: normal;"><u><tt>StringRead</tt></u></span>===
+
[[File:NetComms1.jpg]]
Returns the ASCII value of character idx of the Response string.
 
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''idx''
+
Here is a simple example showing the component used with the [[Component:_Webserver_(GENERIC_ROM_FAT)_(Comms:_Networking)|Webserver (GENERIC)]] component.
::Needs to be a equal to or less than the string length of the response in order to retrieve a valid character.
 
  
 +
{{Fcfile|NetworkComms-Server.fcfx|Example Network Comms Web Server}}
  
'''Return value'''
+
===Embedded Components===
  
:[[Variable Types|BYTE]]
+
The Network Communications component can also be connected to embedded TCP/IP and WIFI style modules allowing for the abstraction to work with specific networking hardware modules.
  
 +
[[File:NetComms2.jpg]]
  
===<span style="font-weight: normal;"><u><tt>SendScript</tt></u></span>===
 
Sends Script idx
 
  
Note that the general property Number of Scripts needs to be set so that it allows the scripts to be accessed and sent.  
+
Here is the current status of the Network Communications component with the various embedded modules.  
  
Returns 0 for success and 1 for error
+
{| class="wikitable"
 +
! Embedded Component
 +
! Other Variants of Component
 +
! Support Status
 +
|-
 +
|[[Component:_TCPIP_(Raspberry_Pi)_(Comms:_Networking)|TCP/IP (Raspberry Pi)]]
 +
|N/A
 +
|Fully Supported
 +
|-
 +
|[[Component:_WLAN_(EB069,_ESP8266)_(ESP8266)_(Wireless)|WLAN (ESP8266)]]
 +
|WLAN (ESP-12S), WIFI (BL0136), WIFI (ESP8266)
 +
|Fully Supported
 +
|-
 +
|[[Component:_TCPIP_(W5500)_(Comms:_Networking)|TCP/IP (W5500)]]
 +
|N/A
 +
|Fully Supported
 +
|-
 +
|[[Component:_TCPIP_(ENC28J60)_(Comms:_Networking)|ENC28J60]]
 +
|N/A
 +
|On Hold
 +
|-
 +
|[[Component:_TCPIP_(NM7010A)_(Comms:_Networking)|TCP/IP (NM7010A)]]
 +
|TCP/IP (EB023v1)
 +
|On Hold
 +
|-
 +
|[[Component:_TCPIP_(WIZ810MJ)_(Comms:_Networking)|TCP/IP (W5100)]]
 +
|TCP/IP (EB023v2), TCP/IP (WIZ810MJ)
 +
|On Hold
 +
|-
 +
|[[Component:_WLAN_(EB069,_WIZ610wi)_(Wireless)|WLAN (WIZ610WI)]]
 +
|WIFI (EB069)
 +
|On Hold
 +
|}
  
'''Parameters'''
 
  
:[[Variable Types|BYTE]] ''idx''
+
We are working through and adding support as and when we get chance so if you have a module that isn't listed or would like to try and prioritise a specific module then you can let us know via the user forums.
::Refers to the Script page to send (1-4).
 
  
 +
==Downloadable macro reference==
  
'''Return value'''
+
===<span style="font-weight: normal;"><u><tt>Connect</tt></u></span>===
 
+
Connects to an IP address as a client on the specified port.
:[[Variable Types|BYTE]]
 
 
 
  
===<span style="font-weight: normal;"><u><tt>SendCommand</tt></u></span>===
+
Some TCP/IP modules (RPI and ESP8266) will accept a URL instead of an IP address.
Sends the command buffer.
 
  
Returns 1 for success in sending the command.
+
Returns: 0=Fail, 1=OK
 
 
Returns 0 for errors.
 
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''ExpectEcho''
+
:[[Variable Types|<- STRING]] ''Address''
::Remote module automatically echos back data: 1 = On (Expect echo), 0 = off
+
::IP address as a string e.g. "192.168.1.1" or URL on some TCP/IP modules
 +
::''This parameter may be returned back to the caller''
  
:[[Variable Types|BYTE]] ''SendCR''
+
:[[Variable Types|UINT]] ''Port''
::Automatically adds \n to the end of the command data: 1 = append CR, 0 = no CR.
 
  
  
 
'''Return value'''
 
'''Return value'''
  
:[[Variable Types|BYTE]]
+
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
  
  
===<span style="font-weight: normal;"><u><tt>CreateCommandString</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>Receive</tt></u></span>===
Assigns a string of characters to the Command buffer.
+
Attempts to receive up to a specified number of bytes from the active connection.
  
Returns 1 for success in adding the characters to the buffer.
+
Returns the number of bytes received.
 
 
Returns 0 for errors, including Buffer overflow.
 
  
 
'''Parameters'''
 
'''Parameters'''
Line 107: Line 121:
 
:[[Variable Types|<- STRING]] ''Data''
 
:[[Variable Types|<- STRING]] ''Data''
 
::''This parameter may be returned back to the caller''
 
::''This parameter may be returned back to the caller''
 +
 +
:[[Variable Types|UINT]] ''Count''
 +
::Maximum number of bytes to read
  
  
 
'''Return value'''
 
'''Return value'''
  
:[[Variable Types|BYTE]]
+
:[[Variable Types|UINT]]
  
  
===<span style="font-weight: normal;"><u><tt>StringReceive</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>Send</tt></u></span>===
Checks for a response string.
+
Sends the specified number of bytes via the active connection.
  
Returns the length of the response string if one is present otherwise returns 0.
+
Returns the number of bytes sent, 0=Fail.
  
 
'''Parameters'''
 
'''Parameters'''
  
:''This macro has no parameters''
+
:[[Variable Types|<- STRING]] ''Data''
 +
::Array containing the data to send
 +
::''This parameter may be returned back to the caller''
  
 
+
:[[Variable Types|UINT]] ''Count''
'''Return value'''
+
::Number of bytes to send from the data array
 
 
:[[Variable Types|BYTE]]
 
 
 
 
 
===<span style="font-weight: normal;"><u><tt>CreateCommand</tt></u></span>===
 
Adds a single characters to the end of the Command buffer.
 
 
 
Returns 1 for success in adding the characters to the buffer.
 
 
 
Returns 0 for errors, including Buffer overflow.
 
 
 
'''Parameters'''
 
 
 
:[[Variable Types|BYTE]] ''Character''
 
::ASCII value or single character,
 
  
  
 
'''Return value'''
 
'''Return value'''
  
:[[Variable Types|BYTE]]
+
:[[Variable Types|UINT]]
 
 
  
===<span style="font-weight: normal;"><u><tt>Send_byte</tt></u></span>===
 
''<span style="color:red;">No additional information</span>''
 
  
 +
===<span style="font-weight: normal;"><u><tt>Listen</tt></u></span>===
 +
Bind the socket to a port on the local host and set to listen mode.
  
 +
Returns: 0=Fail, 1=OK
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''ByteVal''
+
:[[Variable Types|UINT]] ''Port''
  
  
 
'''Return value'''
 
'''Return value'''
  
:''This call does not return a value''
+
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
 
 
  
===<span style="font-weight: normal;"><u><tt>WaitForResponse</tt></u></span>===
 
Waits for a response message of type response_code for timeout ms.
 
  
Returns: 0 for a Response of type response_code
+
===<span style="font-weight: normal;"><u><tt>SocketOpen</tt></u></span>===
 +
Attempts to create a socket on the local device.
  
255 (0xFF) for a timeout or invalid response
+
This must be succesful to allow TCP/IP communications with a remote destination.
  
Response string length for any Response not of type response_code
+
Returns: 0=Fail / 1=OK
  
 
'''Parameters'''
 
'''Parameters'''
  
:[[Variable Types|BYTE]] ''response_code''
+
:''This macro has no parameters''
::1:OK / 2:ERROR / 3:CONNECT / 4:NO CARRIER / 5:AUDIO / 6:PAIR / 7:RING
 
 
 
:[[Variable Types|BYTE]] ''timeout''
 
::The timeout value will need to set to allow sufficient time for the response to arrive.
 
  
  
 
'''Return value'''
 
'''Return value'''
  
:[[Variable Types|BYTE]]
+
:[[Variable Types|BOOL]] : Returns true if the operation is a success, else false
  
  
===<span style="font-weight: normal;"><u><tt>Initialise</tt></u></span>===
+
===<span style="font-weight: normal;"><u><tt>SocketClose</tt></u></span>===
Required to be used whenever the Bluetooth component is used in a program.
+
Closes the current socket connection
 
 
Initialises the Bluetooth component ready for use.
 
  
 
'''Parameters'''
 
'''Parameters'''
Line 207: Line 203:
  
 
==Property reference==
 
==Property reference==
<span style="font-weight: normal;"><u>Command Buffer Size</u></span>
+
<span style="font-weight: normal;"><u>TCP/IP Component</u></span>
 
 
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''CommandBufferSize''.
 
 
 
Maximum number of bytes that can be stored in the outgoing command buffer.
 
 
 
<span style="font-weight: normal;"><u>Response Buffer Size</u></span>
 
 
 
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''ResponseBufferSize''.
 
 
 
Maximum number of bytes that can be stored in the incoming response buffer.
 
 
 
<span style="font-weight: normal;"><u>Script Count</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''SCRIPTS''.
 
 
 
Controls how many AT scripts are stored into non-volatile memory
 
 
 
<span style="font-weight: normal;"><u>Script 1</u></span>
 
 
 
This property is of type ''Multiple lines of text'' and can be referenced with the variable name ''SCRIPT1''.
 
 
 
Data to send for script 0, each command should be terminated with a carriage return
 
 
 
<span style="font-weight: normal;"><u>Channel</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::CHANNEL''.
 
 
 
UART Channel selector
 
 
 
Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels.
 
 
 
Hardware channels use the selected peripheral on-board the target microcontroller.
 
 
 
<span style="font-weight: normal;"><u>TX</u></span>
 
 
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::TX''.
 
 
 
Pin to be used for Transmit data
 
 
 
<span style="font-weight: normal;"><u>RX</u></span>
 
 
 
This property is of type ''Single digital pin'' and can be referenced with the variable name ''cal_uart::RX''.
 
 
 
Pin to be used for Receive data
 
 
 
<span style="font-weight: normal;"><u>Use Flow Control</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::FLOWEN''.
 
 
 
Flow Control (Handshake) enable or disable.
 
 
 
    On: Two I/O pins are used to control the flow of data in and out of the device.
 
 
 
    Off: Flow control is disabled.
 
 
 
<span style="font-weight: normal;"><u>Baud Options</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::BAUD_LIST''.
 
 
 
Baud rate option selector
 
 
 
<span style="font-weight: normal;"><u>Baud Rate</u></span>
 
 
 
This property is of type ''Signed integer'' and can be referenced with the variable name ''cal_uart::BAUD''.
 
 
 
''<span style="color:red;">No additional information</span>''
 
 
 
 
 
 
 
<span style="font-weight: normal;"><u>Console Columns</u></span>
 
 
 
This property is of type ''Unsigned integer'' and can be referenced with the variable name ''cal_uart::ConsoleColumns''.
 
 
 
Number of characters that can be displayed on a single line of the console.
 
 
 
<span style="font-weight: normal;"><u>Console Data</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ConsoleData''.
 
 
 
Selects if the console data is automatically generated or not
 
 
 
<span style="font-weight: normal;"><u>Scope Traces</u></span>
 
 
 
This property is of type ''True or false'' and can be referenced with the variable name ''cal_uart::ScopeTraces''.
 
 
 
Selects if the scope traces are automatically added to the data recorder window or not.
 
 
 
    Simulation - draws an approximation of the UART data onto the scope trace.
 
 
 
    ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.
 
 
 
<span style="font-weight: normal;"><u>Data Source</u></span>
 
 
 
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::DataSource''.
 
 
 
Simulation data source used to allow the component to connect to various remote devices
 
 
 
    Nothing - Simulation data is ignored
 
 
 
    COM port - Routes the communication data to and from a physical or virtual COM port
 
  
    Injector - Routes the communication data via a data injector component on the Panel.
+
This property is of type ''Panel object'' and can be referenced with the variable name ''Component''.
  
<span style="font-weight: normal;"><u>Injector</u></span>
+
Property to point to the TCP/IP or WIFI component you want to use.
  
This property is of type ''Fixed list of ints'' and can be referenced with the variable name ''cal_uart::Injector''.
+
If unconnected then default to simulated TCP/IP network communications using the PC network adapter.
  
Selects which injector component to route the communication data via.
+
<span style="font-weight: normal;"><u>Status</u></span>
  
Add injector components to the panel before they will be available in this list.
+
This property is of type ''Line of text'' and can be referenced with the variable name ''Status''.
  
Injector components are available from the Comms component category.
+
Informs the user of the current status of support for the connected component.

Revision as of 13:07, 19 August 2021


Author Matrix TSL
Version 1.0 (Release)
Category Comms: Networking


Image Network Communications component

A component designed to simplify the process of TCP/IP communications. Compatible with most of the Flowcode supported TCP/IP and WIFI components. A useful building block for creating components such as IoT and Modbus TCP.

Examples

Here are some examples showing the Network Communications component in action.

By itself the component provides a generic TCP/IP layer to drive the simulation runtime.

Here is a simple example showing the component used by itself to request data from a remote server on the internet.

FC6 Icon.png Example Network Comms Client


Library Components

Components such as Webserver (GENERIC), MQTT and Modbus TCP can connect to and control the network comms layer.

NetComms1.jpg


Here is a simple example showing the component used with the Webserver (GENERIC) component.

FC6 Icon.png Example Network Comms Web Server

Embedded Components

The Network Communications component can also be connected to embedded TCP/IP and WIFI style modules allowing for the abstraction to work with specific networking hardware modules.

NetComms2.jpg


Here is the current status of the Network Communications component with the various embedded modules.

Embedded Component Other Variants of Component Support Status
TCP/IP (Raspberry Pi) N/A Fully Supported
WLAN (ESP8266) WLAN (ESP-12S), WIFI (BL0136), WIFI (ESP8266) Fully Supported
TCP/IP (W5500) N/A Fully Supported
ENC28J60 N/A On Hold
TCP/IP (NM7010A) TCP/IP (EB023v1) On Hold
TCP/IP (W5100) TCP/IP (EB023v2), TCP/IP (WIZ810MJ) On Hold
WLAN (WIZ610WI) WIFI (EB069) On Hold


We are working through and adding support as and when we get chance so if you have a module that isn't listed or would like to try and prioritise a specific module then you can let us know via the user forums.

Downloadable macro reference

Connect

Connects to an IP address as a client on the specified port.

Some TCP/IP modules (RPI and ESP8266) will accept a URL instead of an IP address.

Returns: 0=Fail, 1=OK

Parameters

<- STRING Address
IP address as a string e.g. "192.168.1.1" or URL on some TCP/IP modules
This parameter may be returned back to the caller
UINT Port


Return value

BOOL : Returns true if the operation is a success, else false


Receive

Attempts to receive up to a specified number of bytes from the active connection.

Returns the number of bytes received.

Parameters

<- STRING Data
This parameter may be returned back to the caller
UINT Count
Maximum number of bytes to read


Return value

UINT


Send

Sends the specified number of bytes via the active connection.

Returns the number of bytes sent, 0=Fail.

Parameters

<- STRING Data
Array containing the data to send
This parameter may be returned back to the caller
UINT Count
Number of bytes to send from the data array


Return value

UINT


Listen

Bind the socket to a port on the local host and set to listen mode.

Returns: 0=Fail, 1=OK

Parameters

UINT Port


Return value

BOOL : Returns true if the operation is a success, else false


SocketOpen

Attempts to create a socket on the local device.

This must be succesful to allow TCP/IP communications with a remote destination.

Returns: 0=Fail / 1=OK

Parameters

This macro has no parameters


Return value

BOOL : Returns true if the operation is a success, else false


SocketClose

Closes the current socket connection

Parameters

This macro has no parameters


Return value

This call does not return a value


Simulation macro reference

This component does not contain any simulation macros


Property reference

TCP/IP Component

This property is of type Panel object and can be referenced with the variable name Component.

Property to point to the TCP/IP or WIFI component you want to use.

If unconnected then default to simulated TCP/IP network communications using the PC network adapter.

Status

This property is of type Line of text and can be referenced with the variable name Status.

Informs the user of the current status of support for the connected component.