Difference between revisions of "Program Examples:Serial Com:Serial Com Example/zh-hans"

From SoftMC-Wiki
Jump to: navigation, search
(Created page with "{{Languages}} The following example demonstrates the setup of a serial connection with softMC. The program opens COM2 and waits for at least 3 bytes to arrive. Then it sends ...")
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{Languages}}
+
{{Languages|Program_Examples:Serial_Com:Serial_Com_Example}}
The following example demonstrates the setup of a serial connection with softMC.
+
以下示例演示了使用softMC进行串口连接的设置。
  
The program opens COM2 and waits for at least 3 bytes to arrive. Then it sends a message "done" and closes connection.
+
该程序打开COM2并等待至少3个字节到达。 然后它发送一条消息“done”并关闭连接。
  
 
<syntaxhighlight lang="vb">
 
<syntaxhighlight lang="vb">
Line 36: Line 36:
  
  
The example corresponds to commit SHA-1: ada143a7f402e6bbad24c13c56401a5393ce3d2b in GIT.
+
该示例对应于在GIT中的提交的SHA-1: ada143a7f402e6bbad24c13c56401a5393ce3d2b in GIT.
  
  
== See Also ==
+
== 参见 ==
 
* [[Serial Communication|'''Serial Communication''']]
 
* [[Serial Communication|'''Serial Communication''']]
 
* [[MC-Basic:OPEN|OPEN]]
 
* [[MC-Basic:OPEN|OPEN]]

Latest revision as of 08:22, 16 July 2017

语言: English  • 中文(简体)‎

以下示例演示了使用softMC进行串口连接的设置。

该程序打开COM2并等待至少3个字节到达。 然后它发送一条消息“done”并关闭连接。

common shared str1 as string
common shared iteration_counter as long = 0
common shared time_counter as long = 0

Program

	try 
		close #2
	catch else

	end try

	Open COM2 BaudRate=115200 Parity=0 DataBits=8 StopBit=1 XOnOff=1 As #2

	while (loc(2) < 3) and (time_counter < 120) ' allow 120 seconds for system start up to complete
		sleep 1000
		time_counter = time_counter +1
	end while

	str1 = input$(loc(2),#2)
	?str1

	print #2, "done" 
	sleep 100

	close #2

End Program


该示例对应于在GIT中的提交的SHA-1: ada143a7f402e6bbad24c13c56401a5393ce3d2b in GIT.


参见