Communication device setting

Dependencies:   mbed

main.cpp

Committer:
umezawa
Date:
2020-12-29
Revision:
0:cddb9809247b

File content as of revision 0:cddb9809247b:

#include "mbed.h"
Serial pc(USBTX, USBRX);
Serial com(D1,D0);
DigitalOut NRST(A5);
int i = 0;
char msg[256];

int main()
{
    com.baud(115200);
    pc.baud(115200);
    /*reset*/
    pc.printf("reset\r\n");
    NRST = 1;
    NRST = 0;
    wait(2);
    NRST = 1;
    /*Setting*/
    com.scanf("%s",msg);//受信
    pc.printf("%s\r\n",msg);
    if (strstr(msg,"Select")!=NULL) {
        com.printf("1\r\n");
        pc.printf("Terminal mode\r\n");
        com.printf("node\r\n");
        wait(0.5);
        pc.printf("node\r\n");
        com.printf("1\r\n");
        wait(0.5);
        com.printf("ownid\r\n");
        wait(0.5);
        com.printf("0\r\n");
        wait(0.5);
        pc.printf("ownid\r\n");
        com.printf("dstid\r\n");
        wait(0.5);
        com.printf("1\r\n");
        wait(0.5);
        pc.printf("dstid\r\n");
        com.printf("q\r\n");
        wait(0.5);
        com.printf("2\r\n");
        wait(0.5);
        pc.printf("Operation\r\n");
        com.printf("save\r\n");
        wait(1.0);
        com.printf("start\r\n");
        wait(0.5);
        pc.printf("Setting is finished\r\n");
        com.printf("HEPTA\r\n");
        }else
        {
            pc.printf("error\r\n");
            }
            
}