× Pinout diagram Specifications Firmware Networking Debug

IoT device configuration

A common problem with IoT hardware is to setup configuration parameters for correct operation. For example, we may want to set the sampling loops, network transmission interval, APN for 4G and the device serial number for each PCB. The configuration parameters need to be set on demand and operators need a quick and easy way to change the device configuration from outside without changing the hex file.

To support configuration changes on demand, we need support in the hex file to receive commands on a communication port and set command values in the EEPROM for long term usage. The commands can vary across the PCB and the use cases. For example, a router PCB may need to setup the network transmission interval whereas a node PCB needs to set and store the gateway address. To support multiple commands and do future proofing, Yuktix provides the serial command processor (scp) library that can be integrated with the application hex files. The application hex writer needs to focus only on the commands he or she needs to integrate in the hex file. Few commands are provided by the scp lib itself, like the serial command. Rest of the commands can be written according to the scp lib convention to provide seamless command support.

With scp lib, you can send commands on a standard serial line and no new software is required. You can send commands from a Linux, PC or mac OSX. The only hardware you need is a serial cable. Further, if a BLE serial line is available then you can send commands from a phone as well. The PCB would publish the list of supported commands an operator can use to tweak the configuration.

scp lib details

The serial command processor (scp) library expects commands in a certain format. All commands begin with a dot and continue till the first space is found. Anything after the first space and upto the end of the line is treated as argument to that command.

command details
                    
        // The commands are located at run time 
        // using a lookup table     
        struct scp_command_lookup {
            const char *name ;
            void *command;
            void (*handler) (void *command, char*buffer, uint8_t offset);
        };

        // The commands used by a user program  
        // should be registered. An application program 
        // only needs to register what it uses.
        
        static struct scp_modem_command modem_command;
        const static struct scp_command_lookup table[NUM_COMMANDS] = {
            {"modem", &modem_command, scp_run_modem},
            ...
        };
        
        // we need to implement or link the command handler 
        // The scp lib will automatically pass the command 
        // struct and the serial buffer to the registered handler. 
        // The use of void* is to handle generic data structures.
        // The access to serial line is via SCP_PRINT macros.
        void scp_run_modem(void *p_command, char *buffer, uint8_t offset) {
            
            char ch;
            struct scp_modem_command *command = p_command;
            volatile unsigned long start_time = millis();  
            ...
            ...
            if(offset == 0) {
                SCP_PRINT("no command received...\r\n");
                return;
            }
            ...
            ...
            if(uart_available(command->modem_port)) {
                ch = uart_getc(command->modem_port);
            ...
            
        }
        
        
        // a command shell is needed to trigger the 
        // command processing based on the state of 
        // mode GPIO. We need to put mode GPIO 
        // in a known state to enter command mode.
        
        static struct scp_shell command_shell;
        command_shell.io_pin_register = &MODE_PIN_REGISTER;
        command_shell.io_ddr_register = &MODE_DDR;
        command_shell.io_signal_pin = MODE_PIN;
        command_shell.io_signal_value = 0;
        ...
        ...
        scp_monitor(&command_shell);
                
            
        // default is to print information 
        shell $ .serial 
        hosac001 
        
        shell $ .modem  AT+CSQ
        +CSQ: 25,99
        OK
                    
                

You can implement any command and register it with an application program. The scp lib provides access to a serial line, the command shell buffer and a command struct holding useful data. The PCB runs in logger mode by default. You need to change the mode JMP settings to enter the programming mode. The mode JMP (open or short) setting should match the one set on command_shell.io_signal_value field.


Entering command mode

  1. Turn OFF power to the board
  2. Connect FTDI USB cable to the port used for command communication
  3. Change the mode jumper settings (open →short OR or short → open)
  4. Turn ON power supply of the board
  5. Open the serial terminal software ON PC with 38400 baud and 8N1 settings
  6. Press reset switch

Mode JUMPER

Yuktix PCB will run in logger mode by default. We change the mode JMP to indicate that we want to enter an interactive programming mode. To go back to the logger mode, we should change the jumper setting back to logger mode again after doing the configuration changes.

Normal mode

  1. Remove mode jumper
  2. Press reset or send .quit command

Cable settings

Red
Vcc NC Do not connect
Orange
Tx MCU Rx
Yellow
Rx MCU Tx
Black
GND  

Serial Terminal on PC

A serial terminal software is required to enter commands in the programming mode. You can use any serial terminal software. We recommend using the Termite software. To view information on Termite setup, check out the Yuktic PCB debugging page.

Common Gotchas

1. Terminal screen is not showing anything?
Check power supply of board it should be turn ON. After that please check cable connection it should be same as instructed above.

2. Terminal screen showing garbage messages?
This problem is occured because of mismatch of baud rate, usually the debug baud rate is 38400, if on setting baud rate 38400 on termite user experience garbage then contact Yuktix Technologies support team.

3. Mode is not changing to SCP mode?
Check Mode jumper as it should be placed on two pins to enter into SCP mode, so if it is plugged in then press reset button again for at least 3 second and wait for 10 second.