Serial commands plus a sample run of Softata Console App with Serial-GPS selection.

c# Console Softatalib App commands for Serial Comms

App Start

SoftataLib.Init(ipaddressStr, port)
SoftataLib.SendMessageCmd("Begin")
string SoftataLib.SendMessageCmd("Version") //Get Arduino app Version
string SoftataLib.SendMessageCmd("Devices") // Get list of device types supported

Setup Serial

SoftataLib.Serial.serialSetup(txPins[1], baudRate, 1);
SoftataLib.Serial.serialSetup(txPins[2], baudRate, 2);

Read a serial line

  • Line is read on Arduino device and transmitted
string msg  = SoftataLib.Serial.readLine(comRx,false);

Send and receive a char

SoftataLib.Serial.serialWriteChar(comTx, sendCh);

recvCh = SoftataLib.Serial.serialGetChar(comRx);

Send and receive a byte

SoftataLib.Serial.serialWriteByte(comTx, sendByte);

recvByte = SoftataLib.Serial.serialGetByte(comRx);

####

Finish: Close app on Arduino device and restart it.

SoftataLib.SendMessageCmd("End");
  • Executing soft reset of device puts it in a known (clear) state.

For Grove Arduino Pico W, serial pins Tx and Rx are the default:

  • Serial1 Tx=0, Rx=1
  • Serial2 Tx=4, Rx=5

Softata Arduino App Serial Commands

  • 0xE0: Serial1/2 Setup
    • param parameter is index to BAUD rate.
  • 0xE1: Serial1/2 Read a char
  • 0xE4: Serial1/2 Write a char
  • 0xE7: Serial1/2 Readline

For all these commands, Other parameter = 1 or 2:

  • Serial1 or Serial2

Commands sent to Arduino server from Softatalib as array of bytes:

  • Length of array
  • The Command (eg 0xE0) -or command class
  • Pin (eg 0 =Tx here)
  • Param: (eg 12 here=9600)
  • Other (eg 1 or 2 here Serial1/2)
  • (Optional) Array of additional data
    • Eg used by Displays

Sample Console app output: GPS

1. Main Menu:

Hello from Soft-ata!

TESTS
1.              Digital
2.              Analog
3.              PWM
4.              Servo
5.              Sensors
6.              SPI
7.              OneWire
8.              Serial
9.              NeopixelDisplay
10.             LCD1602Display
11.             PotLightSoundAnalog
12.             USonicRange
13.             PotRelay
14.             PotServo

Please make a selection (Default is 13):8
Testtype: Serial
  • Option 8: Serial chosen

2. Connecting to Softata service on Anduino device

Connecting to Softata Server.
Socket created to 192.168.0.9:4242
Sending 2 data bytes
Sent 2 bytes
Received Ready [5] bytes

Sending 2 data bytes
Sent 2 bytes
Received 3.10 [4] bytes

Softata Version: 3.10
Sending 2 data bytes
Sent 2 bytes
Received DEVICES:sensor,actuator,communication,display [45] bytes
DEVICES:sensor,actuator,communication,display

3. Serial Options Menu

Serial Test
1. Serial 1
2. Serial 2
3. (Tx)Serial 1 -> (Rx)Serial 2
4. (Tx)Serial 2 -> (Rx)Serial 1
5. Quit
Selection:2
  • Option 2: Serial2 for Tx and Rx chosen
  • Options 3 & 4 only for loopback tests

4. Serial Mode Menu

  • Options 1 nd 2 are loopback tests.
  • Option 3 requires Grove Serial GPS connected to Serial1 or Serial2 (as per previous menu).
    • Note: If options3 or 4 chosen on previous menu, GPS is not an option for this menu.
Serial mode Selection:
1. ASCII
2. Byte
3. GPS
4. Quit
Selection:3
  • GPS chosen

5. Enter BAUD Rate

BAUD Rate (Default 9600).
Enter BAUD:9600
  • 9600 chosen
  • Note: Value is validated against a list of valid BAUD rates. The index of it (12 in this case) is what is sent to the Arduino devices as this fits into one byte.

6. Setting up

Sending 5 data bytes
Sent 5 bytes
Received OK: [3] bytes

Sending 5 data bytes
Sent 5 bytes
Received OK: [3] bytes

7. Running

  • Reading Serial2 at 9600 line by line
  • Note first line is incomplete. Can be ignored
Reading GPS
Press [Esc] to stop
        9YQQ59-9i$GNGGA,114717.000,3744.80795,S,14453.73980,E,1,07,1.4,61.9,M,5.1,M,,*57
        $GNGLL,3744.80795,S,14453.739801,01,01,ANTENNA OK*35
        $GNGGA,114718.000,3744.80786,S,65,E,114718.000,A,A*5C
        $GNGSA,A,3,04,07,09,16,30,,,,,,$GNGGA,114719.000,3744.80770,S,14453.73929,E,1,07,1.4,61.0,M,5.1,M,,*58
        $GNGLL,3744.80770,S,14453.739291,01,01,ANTENNA OK*35
        $GNGGA,114720.000,3744.80765,S,.73922,E,114720.000,A,A*59
        $GNGSA,A,3,04,07,09,16,30,,,,,,$GNGGA,114721.000,3744.80762,S,14453.73921,E,1,07,1.4,60.7,M,5.1,M,,*5E
        $GNGLL,3744.80762,S,14453.739211,01,01,ANTENNA OK*35
        $GNGGA,114722.000,3744.80760,S,453.73920,E,114722.000,A,A*5C

8. [Esc] pressed

  • Finishing up
ending 2 data bytes
Sent 2 bytes
Received Done [4] bytes

C:\SoftataConsole.exe (process 16972) exited with code 0.

9. Done


 TopicSubtopic
   
 This Category Links 
Category:Softata Index:Softata
  Next: > Softata
<  Prev:   Softata