Send Message Block Icon of block

傳輸訊息指令
Send Message Block

此為傳輸無線訊息給其他的NXT的指令
This block allows you to send a wireless message to another NXT.

NXT無線傳輸設定
Configuring the NXT for Wireless Communication

NXT間若要進行傳輸或接收訊息前,須設定無線傳輸連結。
NXTBefore wireless messages can be sent or received, the participating NXTs must be set up for wireless communication.

NXT的傳輸連結採主從式架構。由一個特定的NXT(主)控制其他NXT(從),在此特定NXT上開啟藍芽目錄並搜尋其他的NXT,當搜尋到其他的NXT後,須為加入的第二個NXT設定連結序號(1, 2, 或 3)。當第一次進行連結時,二個NXT上會顯示請輸入認證碼的畫面,須輸入同一個數字。NXT(主)的連結目錄中會顯示另一NXT(從)的名稱及連結序號。在另一NXT(從)上,則會顯示NXT(主)的名稱及連結序號,其連結序號必為0。當以上二個NXT皆顯示正確訊息後,表示NXT(主)已與另一NXT(從)連結完成。
On the (master) NXT that will communicate with other NXTs, navigate to the Bluetooth category and choose Search that will start a search for other devices. When the search is complete, choose which connection number (1, 2, or 3) you want the second (slave) NXT to be known as. The first time a connection is established between two NXTs, a prompt to enter the Passkey will appear on both NXTs; this needs to be accepted by both. Now when you navigate to the Connection category on the master NXT, the slave NXT should be shown by its name occupying the selected connection number. On the slave NXT, the master NXT should be shown occupying connection number 0. At this point, the master NXT is ready to initiate communication with the slave NXT.

若NXT(主)欲與多個NXT進行連結(最多為3個),重覆上述程序即可。
If the master NXT needs to communicate with multiple NXTs (up to a maximum of three), you should repeat the above process.

注意!若有多個NXT相互進行連結且NXT(主)傳輸訊息給多個NXT時,為了讓藍芽切換傳輸頻率,最少會有一秒鐘的誤差。
Note! If you have multiple NXT devices talking to each other, and your master NXT is also talking to more than one NXT device, you will need to have at least a one second delay built in to the program to allow the Bluetooth radio to change channels before sending the messages.

必須在一NXT上進行上述程序。當NXT(主)設定連結序號後,接收訊息的NXT會自動更新連結。
It’s only necessary to go through this process on one NXT. The receiving NXT will automatically update its connection when the master NXT is setting up its connection number.

連結序號
Connection Number

在無線通訊下,連結序號可視為每一個NXT的位址,並將訊息傳輸給該位址的NXT。
The connection number for each NXT might be considered its address in the wireless world. You send a message to a specific NXT by indicating its connection number.

信箱號碼
Mailbox Number

每個NXT有十個信箱號碼並可儲存訊息。每個信箱可儲存五個訊息,若超過上限時,每加入一個新的訊息就會刪除最前面儲存的訊息。
Each NXT has ten mailbox numbers where wireless messages can be deposited. Each mailbox number can hold up to five messages. If the mailbox number fills up with five messages, adding one more message will cause the NXT to erase the oldest message.

傳輸訊息
Sending a Message

傳輸訊息時(在所有NXT都設定連結序號後),首先選擇傳輸對象的連結序號。然後,再選擇傳輸的訊息格式(文字、數值或邏輯值)並輸入文字、數值或邏輯條件(真/偽)為傳輸之訊息。最後,設定接收端接收此訊息之信箱號碼(可儲存接收的訊息)。訊息格式及訊息都可由資料線輸入。
To send a wireless message (after all NXTs have been configured with connection numbers), first select the connection number of the target NXT. Then choose the message format (Text, Number, or Logic). Input the message by typing in some text or a number, or choosing a logical condition (true or false). Finally, choose the mailbox number (where the message will be stored) at the target NXT. The message format and the message itself can also be specified by using input data wires.

注意:請參閱接收訊息指令,有更多相關資訊。
Note: see the Receive Message block for information on receiving a wireless message.

顯示設定
Display Settings

Image of Send Message block, data hub open

  1. 此為目標NXT連結序號(接收訊息的NXT)
    This is the connection number of the target NXT (that is to receive the message).
  2. 可以使用資料線動態產生訊息格式或訊息。如果需要,則可以用右邊的輸出連接埠來傳遞訊息到其他指令。(請參閱資料集線器,有更多相關資訊。)
    The message type and the message itself can be supplied dynamically using input data wires. The output plugs to the right will pass any input information through to other blocks, if necessary. (See the Data Hub section below for more information.)

傳輸訊息指令參數設定
Configuring the Send Message Block

Image of configuration panel, default conditions

  1. 使用單選按鈕設定傳輸對象NXT的連結序號。
    Use the radio buttons to choose the connection number of the target NXT.
  2. 使用下拉式選單設定訊息格式(文字、數值或邏輯值)。
    The pull-down menu will let you select the message type (Text, Number, or Logic).
  3. 輸入訊息可以是文字或數值(分別選擇文字或數值)。若設定為邏輯條件時,則使用單選按鈕設定真或偽)。
    Input the message by typing in some text or a number (if you have chosen Text or Number respectively), or, if sending a Logic message, using the radio buttons to choose true or false.
  4. 設定接收此訊息之NXT的信箱號碼。Choose the mailbox number at the destination NXT.

傳輸訊息指令的資料集線器參數設定
Configuring the Send Message block’s Data Hub

可以使用資料線(來自其他指令之資料集線器)連結至傳輸訊息指令以達到動態設定的目的。
You can control the Send Message block dynamically by connecting data wires (from other blocks’ data hubs) to the Send Message block’s data hub.

當選取傳輸訊息指令後,擊點指令左下角的邊界,可打開資料集線器。
Open a block’s data hub by clicking the tab at the lower left edge of the block after it has been placed on the work area.

Image showing unopened tab on a generic block

連接到集線器左邊連接埠的資料線是屬於負責傳遞資料進入指令中, 而要從指令送出資料時,則須從集線器的右邊連接埠連接資料線.
Data wires carrying input information to a block are connected to the plugs on the left side of its data hub. Data wires carrying output information are connected to the plugs on the right side.

Image of data wires

[A]輸入連接埠 [A] Input plug
[B]輸出連結部 [B] Output plug
[C]數字資料線(黃) [C] Number data wire (yellow)
[D]邏輯資料線(綠) [D]Logic data wire (green)
[E]文字資料線(橘) [E]Text data wire (orange)
[F]無效資料線(灰) [F]Broken data wire (gray)

資料由輸入端傳至傳出端
Passing data from the input plug to the output plug

如果輸入連接埠有對應的輸出連接埠(請參閱 A 以上)時,那麼輸入的資料就會原封不動地傳遞到輸出連接埠.在這樣的情況下, 如果輸入連接埠連著資料線,那麼就只能使用輸出連結埠來做連結. 也就是說,當連結輸出連接線到這樣的輸出連接埠,而不透過相對應的輸入資料線時,就會讓該輸出連接線呈現無效的狀態.
If an input plug has a corresponding output plug (see A above), the input data will pass through from the input plug to the output plug without being changed. In this case, you can only use the output plug if the input plug is connected to an input data wire; connecting an output data wire to such an output plug without a connected input data wire will cause the output data wire to be “broken” (and colored gray).

特定的資料型態
Data wires carry specific types of data

每條資料線都負責傳送特定資料型態.例如,一條從邏輯連接埠拉出的資料線則只能連結到另一個同屬邏輯連接埠的集線器上.
Each data wire carries a specific type of data between blocks. For example, if a data wire is dragged from a logic plug on a block’s data hub, it can only be connected to a logic plug on another block’s data hub. The chart below shows what kind of data each plug can accept or send out.

資料線顏色
Data wire colors

資料線依照特定的顏色作識別:黃色資料線傳送數值資料、綠色資料線傳送邏輯資料(真/偽)及橘色資料線傳送文字資料
Data wires are identified with specific colors: wires carrying number data are colored yellow, wires carrying logic data are colored green, and wires carrying text data are colored orange.

無效的資料線
“Broken” data wires

如果資料線連結到錯誤資料型態的連接埠時,則該資料線會呈現斷線無效狀態並以灰色表示.而有無效的資料線存在就無法下載程式.
If you try to connect a data wire to a plug of the wrong data type, the data wire will be broken (and colored gray). You will not be able to download your program if a data wire is broken.

點選無效的資料線時,在工作區右下方的幫助視窗中會看到無效的原因.
If you click a broken wire you can read why it is broken in the small help window in the lower right corner of the work area.

資料必須在連接埠的限制範圍內
Data must be within the possible range of the plug

如果資料線傳輸該連接埠資料範圍之外的資料時,該指令不是忽略資料就是轉成合理範圍內的資料.對那些只能接收少量輸入值的連接埠來說(例如,0,1,或2),該連結埠就會忽略超出範圍的數值.
If an input data wire transmits a value outside the possible range of the plug it is connected to, the block will either ignore the value or change it to a value within its range. For plugs that allow just a few input values (example: just 0, 1, or 2), the plug will ignore the input if a value arrives outside its range.

而對那些可以接收大量範圍輸入值(例如: 0~100)的連接埠來說,該連接埠就會將數值轉成可接受的範圍. 例如, 移動指令的動力連接埠接收到150的輸入值時,那麼移動指令就會轉成100(也就是動力連接埠的範圍內).
For plugs that accept larger input ranges (example: 0 – 100), the plug will force any input outside its range to fit. For example, if a Move block’s Power plug receives an input value of 150, the block will change the input value to 100 (i.e., a number within the Power plug’s range).

下表表示傳輸訊息指令的資料集線器中的各種連接埠:
This chart shows the different characteristics of the plugs on the Send Message block’s data hub:

  連接埠
Plug
資料型態
Data Type
資料範圍
Possible Range
資料意義
What the Values Mean
連接埠例外說明
This Plug is Ignored When...
Port 連結序號
Connection
數值
Number
0 - 3 連結序號為0時,訊息將由NXT(從)傳輸至NXT(主)。
Connection number to send to. Choosing "0" will send messages from slave NXT to master NXT.
 
Port 信箱號碼
Mailbox
數值
Number
1 - 10 儲存接收的訊息
Receiver's mailbox to put message in
 
Port 文字
Text
文字
Text
最多可輸入58個字元
58 character maximum
傳輸的訊息
Message to send
非文字的傳輸訊息格式
Message Type not Text
Port 數值
Number
數值
Number
-2147483648 - 2147483647 傳輸的訊息
Message to send
非數值的傳輸訊息格式
Message Type not Number
Port 邏輯
Logic
邏輯
Logic
真/偽
True/False
傳輸的訊息
Message to send
非邏輯的傳輸訊息格式
Message Type not Logic