SPL SerialPort programming - How to start SerialPort programming
1. Re-launch SPL emulator
- if SPL emulator is running, please terminate emulator.
- Press "F5" key to re-launch SPL emulator on the editor.
2. Add "SerialPort" command
- SPL MF Emulator provides four serial ports (COM1 ~ COM4).
- COM1 is reserved for the H/W port programming and COM2 is used to transfer SPL script.
- You can use COM3 and COM4 as a new serial port.
- Double click "SerialPort" item on the tree.
| |
SerialPort COM3
/PortName:COM3
/BaudRate:9600
| |
|
3. Add simple logic to send data to serial port
- You can send data to serial port by using below method.
portname.Write(string text)
portname.Write(byte[] buff)
- Add lines to send data to serial port as follows.
| |
SerialPort COM3
/PortName:COM3
/BaudRate:9600
COM3.Write("Hello")
| |
|
- Click "Send Script" button to send SPL script to emulator.
4. Executed result
- Executed result will be shown as follows.
5. Read data from the SerialPort
- Continued in the next tutorial.
|