SPL SerialPort programming - How to start SerialPort programming


1. Re-launch SPL emulator
  1. if SPL emulator is running, please terminate emulator.

  2. Press "F5" key to re-launch SPL emulator on the editor.




2. Add "SerialPort" command
  1. SPL MF Emulator provides four serial ports (COM1 ~ COM4).

  2. COM1 is reserved for the H/W port programming and COM2 is used to transfer SPL script.

  3. You can use COM3 and COM4 as a new serial port.

  4. Double click "SerialPort" item on the tree.



      
    SerialPort    COM3
    	/PortName:COM3
    	/BaudRate:9600
    
      



3. Add simple logic to send data to serial port
  1. You can send data to serial port by using below method.

       portname.Write(string text)
       portname.Write(byte[] buff)

  2. Add lines to send data to serial port as follows.



      
    SerialPort    COM3
    	/PortName:COM3
    	/BaudRate:9600
    
    COM3.Write("Hello")
    
      


  3. Click "Send Script" button to send SPL script to emulator.



4. Executed result
  1. Executed result will be shown as follows.




5. Read data from the SerialPort
  1. Continued in the next tutorial.