• VEXcode Robotics Logo VEX Robotics Logo
  • VEX API Home Button VEX API Home Button
  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white
मुख्य सामग्री पर जाएं
Ctrl+K

< Back to Platform Select

  • VEX EXP
  • VEX EXP API संदर्भ
  • VEXlink
  • संदेश लिंक
हिंदी
  • English
  • العربية
  • বাংলা
  • Česky
  • Deutsch
  • Ελληνικά
  • Español
  • Español Latinoamericano
  • Suomi
  • Français
  • Gaeilge
  • Magyar
  • Bahasa Indonesia
  • 日本語
  • 한국어
  • Lietuvių
  • Latviešu
  • മലയാളം
  • Nederlands
  • Polski
  • Português
  • Русский
  • Svenska
  • ไทย
  • Türkçe
  • Українська
  • Tiếng Việt
  • 简体中文
  • 繁體中文
  • VEXcode Robotics Logo

अनुभाग नेविगेशन

  • ब्लाकों
  • Python
    • ड्राइवट्रेन
    • गति
    • आवाज़
    • दृष्टि
    • स्क्रीन
    • नियंत्रक
    • संवेदन
    • जड़त्वीय
    • 3-तार वाले उपकरण
    • वायवीय
    • दिमाग
    • एसडी कार्ड
    • 6-एक्सिस आर्म
    • सिग्नल टावर
    • VEXlink
      • संदेश लिंक
      • सीरियललिंक
    • सांत्वना देना
    • तर्क
    • माइक्रो पायथन लाइब्रेरीज़
  • C++
  • VEXcode ट्यूटोरियल

प्लेटफ़ॉर्म नेविगेशन

  • VEX 123 logo in purple VEX 123 logo in white
  • VEX GO logo in lime green VEX GO logo in white
  • VEXcode AIM logo in blue VEXcode AIM logo in white
  • VEX IQ logo in blue VEX IQ logo in white
  • VEX EXP logo in red VEX EXP logo in white
  • VEX V5 logo in red VEX V5 logo in white
  • VEX CTE logo in green VEX CTE logo in white
  • VEX AIR logo in orange VEX AIR logo in white
  • VEXcode VR logo in gold VEXcode VR logo in white

संदेश लिंक#

  • परिचय

  • एक लिंक बनाएं

  • उपलब्ध विधियाँ

    • is_linked

    • भेजना

    • प्राप्त करें

    • प्राप्त

परिचय#

MessageLink दो EXP Brains को छोटे स्ट्रिंग संदेशों और वैकल्पिक रूप से छोटे डेटा भेजकर संवाद करने की सुविधा देता है। इसे रोबोट-टू-रोबोट समन्वय के लिए डिज़ाइन किया गया है — जैसे कि रूटीन शुरू करना, सेंसर के परिणाम साझा करना या किसी अन्य रोबोट पर व्यवहार को सक्रिय करना।

send के प्रत्येक उपयोग से लिंक्ड EXP ब्रेन की कतार में एक संदेश जुड़ जाता है, और कतार को पहले आओ, पहले जाओ (FIFO) के आधार पर पढ़ा जाता है। यदि दूसरे EXP ब्रेन द्वारा receive का उपयोग करने से पहले कई संदेश भेजे जाते हैं, तो उन्हें संग्रहीत किया जाएगा और भेजे जाने के क्रम में एक-एक करके वापस किया जाएगा। क्योंकि संदेश कतार में लग सकते हैं, प्रत्येक लूप में एक ही स्थिति को बार-बार भेजने से बैकलॉग बन सकता है; समय-संवेदनशील लॉजिक के लिए, केवल तभी भेजें जब मान बदलते हों।

महत्वपूर्ण: दोनों रोबोटों को एक ही समय में MessageLink का उपयोग करने वाले प्रोजेक्ट चलाने होंगे, अन्यथा कोई संदेश भेजा/प्राप्त नहीं किया जाएगा।

इस पृष्ठ पर उदाहरण के तौर पर link MessageLink का नाम दिया गया है। आवश्यकतानुसार इसे अपने द्वारा निर्धारित नाम से बदलें।

नीचे उपलब्ध विधियों की सूची दी गई है:

  • is_linked – यह बताता है कि क्या यह ब्रेन अपने युग्मित ब्रेन से सक्रिय रूप से जुड़ा हुआ है।

  • send – युग्मित मस्तिष्क को एक संदेश भेजता है।

  • receive – अगले आने वाले संदेश की प्रतीक्षा करता है और उसे लौटाता है।

  • received – जब भी कोई नया संदेश प्राप्त होता है, तो कॉल करने के लिए एक फ़ंक्शन पंजीकृत करता है।

एक लिंक बनाएं#

दोनों EXP ब्रेन पर एक मैसेजलिंक बनाएं ताकि उनके बीच एक संचार चैनल स्थापित हो सके—या तो V5 रोबोट रेडियो के साथ वायरलेस तरीके से या वायर्ड स्मार्ट केबल के माध्यम से—ताकि रोबोट एक दूसरे को संदेश भेज सकें।

MessageLink(smartport, name, linktype, wired)

पैरामीटर

विवरण

smartport

इस लिंक के लिए उपयोग किया जाने वाला स्मार्ट पोर्ट—वह पोर्ट जिससे V5 रोबोट रेडियो जुड़ा हुआ है (वायरलेस) या जिसमें स्मार्ट केबल लगी हुई है (वायर्ड)। इसे Ports.PORTx के रूप में लिखा जाता है, जहाँ x पोर्ट संख्या है।

name

इस लिंक को दिया जाने वाला अद्वितीय नाम (स्ट्रिंग के रूप में)।
ध्यान दें: यह नाम इतना लंबा होना चाहिए कि एक अद्वितीय आईडी बन सके, ताकि यह गलती से किसी अन्य टीम के लिंक से मेल न खाए।

linktype

यह ब्रेन इस लिंक पेयर के लिए जिस भूमिका का उपयोग करेगा। प्रत्येक पेयर में एक मैनेजर और एक वर्कर होना चाहिए:

  • VexlinkType.MANAGER – उस रोबोट के लिए उपयोग करें जो अधिक या बड़े संदेश भेजेगा। मैनेजर की आउटबाउंड बैंडविड्थ अधिक होती है (~1040 बाइट्स/सेकंड)।
  • VexlinkType.WORKER – उस रोबोट के लिए उपयोग करें जो कम या छोटे संदेश भेजेगा। वर्कर की आउटबाउंड बैंडविड्थ कम होती है (~520 बाइट्स/सेकंड)।

wired

वैकल्पिक। यह लिंक वायर्ड है या वायरलेस:

  • True – EXP ब्रेन स्मार्ट केबल के माध्यम से जुड़े हैं।
  • False (डिफ़ॉल्ट) – EXP ब्रेन V5 रोबोट रेडियो का उपयोग करके वायरलेस तरीके से कनेक्ट होते हैं।

रोबोट 1 का कोड

"""
Create a wireless link in Port 1
name: VEXRoboticsLink123456789
linktype: Manager
"""
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

रोबोट 2 के लिए कोड

"""
Create a wireless link in Port 1
name: VEXRoboticsLink123456789
linktype: Worker
"""
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

उपलब्ध विधियाँ#

एक बार आपका MessageLink सेटअप हो जाए और Brains लिंक हो जाएं, तो आप नीचे दिए गए तरीकों का उपयोग करके संदेश भेज सकते हैं, प्राप्त कर सकते हैं और उनका जवाब दे सकते हैं।

is_linked#

is_linked विधि यह लौटाती है कि क्या MessageLink पर EXP Brains एक दूसरे के साथ युग्मित हैं।

  • True – दोनों EXP ब्रेन युग्मित हैं और इस लिंक पर संवाद कर रहे हैं।

  • False – इस लिंक पर दो EXP ब्रेन युग्मित नहीं हैं।

नोट: किसी भी कोड को चलाने से पहले, प्रोजेक्ट की शुरुआत में यह सुनिश्चित करना हमेशा अच्छा अभ्यास है कि EXP Brains लिंक किए गए हैं।

Usage:
link.is_linked()

पैरामीटर

विवरण

इस विधि के कोई मानदंड नहीं हैं।

रोबोट 1 का कोड

# Tell the other robot when the screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")

# Continuously send if the screen is being pressed
while True:
    if brain.screen.pressing():
        link.send("pressed")
    else:
        link.send("released")

    wait(50, MSEC)

रोबोट 2 के लिए कोड

# Display if the other robot's screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

# Continuously check if Robot 1 has sent "pressed"
while True:
    brain.screen.clear_screen()
    brain.screen.set_cursor(1, 1)
    brain.screen.print("Robot 2 - Worker")
    brain.screen.next_row()

    if link.receive() == "pressed":
        brain.screen.new_line()
        brain.screen.print("Manager is being pressed!")

    wait(50, MSEC)

send#

send दूसरे लिंक्ड EXP ब्रेन को एक स्ट्रिंग और/या एक पूर्णांक और/या फ्लोट भेजता है।

Usage:
send(string, integer, float)

पैरामीटर

विवरण

string

दूसरे लिंक किए गए EXP ब्रेन को भेजने के लिए स्ट्रिंग।

integer

वैकल्पिक। दूसरे लिंक किए गए EXP ब्रेन को भेजने के लिए एक पूर्णांक।

float

वैकल्पिक। दूसरे लिंक किए गए EXP ब्रेन को भेजने के लिए एक फ्लोट मान। फ्लोट मान 4 दशमलव स्थानों तक स्वरूपित होते हैं; यदि कम दशमलव स्थान दिए जाते हैं, तो 4 दशमलव स्थान दिखने तक अंत में शून्य जोड़े जाते हैं।

यदि केवल string भेजी जाती है, तो दूसरा लिंक किया गया EXP ब्रेन ठीक वही स्ट्रिंग प्राप्त करता है।

यदि integer और/या float शामिल हैं, तो प्राप्तकर्ता ब्रेन को एक एकल एन्कोडेड स्ट्रिंग प्राप्त होती है जो सभी फ़ील्ड को इस क्रम में संयोजित करती है: .string_integer_float

उदाहरण: link.send(“string”, 1, 2.55) .string_1_2.5500 के रूप में प्राप्त किया जाता है।

रोबोट 1 का कोड

# Tell the other robot when the screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")

# Continuously send if the screen is being pressed
while True:
    if brain.screen.pressing():
        link.send("pressed")
    else:
        link.send("released")

    wait(50, MSEC)

रोबोट 2 के लिए कोड

# Display if the other robot's screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

# Continuously check if Robot 1 has sent "pressed"
while True:
    brain.screen.clear_screen()
    brain.screen.set_cursor(1, 1)
    brain.screen.print("Robot 2 - Worker")
    brain.screen.next_row()

    if link.receive() == "pressed":
        brain.screen.new_line()
        brain.screen.print("Manager is being pressed!")

    wait(50, MSEC)

रोबोट 1 का कोड

# Tell the other robot where the screen was pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")
brain.screen.next_row()
brain.screen.print("Tap to send circles")

# Send the coordinates whenever the screen is pressed
while True:
    if brain.screen.pressing():
        x = brain.screen.x_position()
        y = brain.screen.y_position()

        link.send("touch", x, y)

    wait(10, MSEC)

रोबोट 2 के लिए कोड

# Draw a circle where Robot 1's screen was pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 2 - Worker")

while True:
    # Get the full encoded string
    circle_coordinates = link.receive(200)

    if circle_coordinates:

        # Split the encoded string by _
        parts = circle_coordinates.split("_")

        if len(parts) == 3:
            # Convert the coordinates back into numbers
            x = float(parts[1])
            y = float(parts[2])

            brain.screen.set_fill_color(Color.WHITE)
            brain.screen.draw_circle(x, y, 20)

    wait(10, MSEC)

receive#

receive दूसरे लिंक्ड EXP ब्रेन से अगला क्यूड मैसेज लौटाता है। मैसेज FIFO क्रम में पढ़े जाते हैं (सबसे पुराना अपठित पहले)। यदि receive कॉल किए जाने पर क्यू खाली है, तो यह निर्दिष्ट timeout तक नए मैसेज की प्रतीक्षा करता है। यदि उस समय सीमा में कोई मैसेज नहीं आता है, तो receive Noneलौटाता है, और उसके बाद भेजा गया कोई भी मैसेज अगली बार receive उपयोग किए जाने पर पढ़ने के लिए क्यू में रहता है।

यदि दूसरे लिंक्ड EXP ब्रेन ने केवल string, receive को भेजा तो वही सटीक स्ट्रिंग वापस मिलती है।

यदि दूसरे लिंक्ड EXP ब्रेन ने एक पूर्णांक और/या फ्लोट भेजा, तो receive एक एकल एन्कोडेड स्ट्रिंग लौटाता है जो सभी फ़ील्ड को इस क्रम में जोड़ता है: .string_integer_float

उदाहरण के लिए, यदि दूसरा लिंक्ड EXP ब्रेन link.send(“string”, 1, 2.55)का उपयोग करता है, तो link.receive() का उपयोग करने पर .string_1_2.5500जैसी एन्कोडेड स्ट्रिंग प्राप्त होती है। आप इस एन्कोडेड स्ट्रिंग को विभाजित कर सकते हैं (नीचे दिए गए उदाहरण देखें) ताकि संदेश का नाम, पूर्णांक और फ्लोट मान निकाले जा सकें।

अगर आप मैन्युअल विभाजन/पार्सिंग से बचना चाहते हैं, तो किसी विशिष्ट संदेश नाम के लिए हैंडलर को पंजीकृत करने के लिए received का उपयोग करें; हैंडलर भेजे गए मानों को तर्क के रूप में प्राप्त करता है।

Usage:
receive(timeout)

पैरामीटर

विवरण

timeout

यह विकल्प वैकल्पिक है। यदि कतार खाली है तो ही नए संदेश के लिए receive मिलीसेकंड तक प्रतीक्षा की जाएगी। डिफ़ॉल्ट मान 300,000 (300 सेकंड) है।

रोबोट 1 का कोड

# Tell the other robot when the screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")

# Continuously send if the screen is being pressed
while True:
    if brain.screen.pressing():
        link.send("pressed")
    else:
        link.send("released")

    wait(50, MSEC)

रोबोट 2 के लिए कोड

# Display if the other robot's screen is being pressed

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

# Continuously check if Robot 1 has sent "pressed"
while True:
    brain.screen.clear_screen()
    brain.screen.set_cursor(1, 1)
    brain.screen.print("Robot 2 - Worker")
    brain.screen.next_row()

    if link.receive() == "pressed":
        brain.screen.new_line()
        brain.screen.print("Manager is being pressed!")

    wait(50, MSEC)

रोबोट 1 का कोड

# Send a math problem for the other Brain to solve

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")

"""
Change whether to "add" or "subtract",
then what numbers to use in the operation.
"""
link.send("add", 7, 2.5)

रोबोट 2 के लिए कोड

# Solve the math problem that the other Brain sends

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 2 - Worker")
brain.screen.next_row()

math_problem = link.receive()

if math_problem:

    # Split the encoded string by _
    parts = math_problem.split("_")

    if len(parts) == 3:
        # Remove the . from the beginning of the string
        operator = "".join([c for c in parts[0] if c.isalpha()])

        # Separate out the numbers for the operation
        a = int(parts[1])
        b = float(parts[2])

        # Use what operator was sent
        if operator == "add":
            result = a + b
        elif operator == "subtract":
            result = a - b
        # If neither add or subtract is sent, do nothing
        else:
            pass

brain.screen.print("Result = ", result)

received#

received एक फ़ंक्शन को पंजीकृत करता है जिसे EXP ब्रेन द्वारा भेजा गया संदेश प्राप्त होने पर कॉल किया जाएगा।

Usage:
link.received(message, arg)

पैरामीटर

विवरण

message

मिलान करने के लिए संदेश का नाम (स्ट्रिंग)। जब प्राप्त संदेश का नाम इस मान से मेल खाता है, तो callback फ़ंक्शन को कॉल किया जाता है।

callback

एक पूर्व-परिभाषित फ़ंक्शन जो तब चलता है जब EXP ब्रेन message से मेल खाने वाला संदेश प्राप्त करता है।

received को चार तर्कों के साथ कॉल किया जाता है:

कॉलबैक हस्ताक्षर:
callback(message, linkname, index, value)

तर्क

विवरण

message

प्राप्त संदेश का नाम (उदाहरण के लिए, “add”)।

linkname

जिस लिंक से संदेश प्राप्त हुआ था, उसका नाम।

index

संदेश के साथ भेजा गया पूर्णांक मान (यदि प्रदान किया गया हो)।

value

संदेश के साथ भेजा गया फ्लोट मान (यदि प्रदान किया गया हो)।

रोबोट 1 का कोड

# Send a math problem for the other Brain to solve

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.MANAGER)

# Do not run code UNTIL the Brains are linked
while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 1 - Manager")

"""
Change whether to "add" or "subtract",
then what numbers to use in the operation.
"""
link.send("add", 7, 2.5)

रोबोट 2 के लिए कोड

# Solve the math problem that the other Brain sends

# Create the link
link = MessageLink(Ports.PORT1, "VEXRoboticsLink123456789", VexlinkType.WORKER)

while not link.is_linked():
    wait(0.1, SECONDS)

brain.screen.print("Robot 2 - Worker")
brain.screen.next_row()

# add if "add" is received
def add_cmd(message, linkname, a, b):
    result = a + b
    brain.screen.print("Result = ", result)

# subtract if ""subtract" is received
def subtract_cmd(message, linkname, a, b):
    result = a - b
    brain.screen.print("Result = ", result)

# Create event handlers for "add" and "subtract"
link.received("add", add_cmd)
link.received("subtract", subtract_cmd)

पूर्ववर्ती

VEXlink

आगामी

सीरियललिंक

On this page
  • परिचय
  • एक लिंक बनाएं
  • उपलब्ध विधियाँ
    • is_linked
    • send
    • receive
    • received
Innovation First, International

VEX and VEX Robotics are trademarks or service marks of Innovation First, Inc. Copyright ©2026. All Rights Reserved. VEX Robotics, Inc. is a subsidiary of Innovation First International, Inc. All other product names / marks of others are the property of their respective owners. Patents and / or Patents Pending - innovationfirst.com/patents
Site Privacy Policy / Site Terms of Use / Cookie Policy / Software Privacy Policy

VEX रोबोटिक्स के फेसबुक पेज पर जाएं VEX रोबोटिक्स के ट्विटर पेज पर जाएं VEX रोबोटिक्स के इंस्टाग्राम पेज पर जाएं VEX रोबोटिक्स के YouTube पेज पर जाएं
VEX API प्रतिक्रिया प्रपत्र

हम आपकी प्रतिक्रिया को महत्व देते हैं! सुझाव देने, प्रशंसा करने या VEX API में त्रुटियों की रिपोर्ट करने के लिए इस फ़ॉर्म का उपयोग करें। आपका इनपुट हमें VEX API दस्तावेज़ीकरण को बेहतर बनाने में मदद करता है।

​

यदि आपको तकनीकी समस्याएँ आ रही हैं या ग्राहक सहायता की आवश्यकता है, तो कृपया support.vex.comपर जाएँ।

  • Send Happy Feedback
  • Send Sad Feedback

ध्यान दें: वर्तमान URL आपके संदेश के साथ साझा किया जाएगा।

अपना ईमेल पता शामिल करके, आप इस बात से सहमत होते हैं कि यदि हमें आपकी प्रतिक्रिया के बारे में कोई प्रश्न हो तो VEX आपको ईमेल भेज सकता है।
गोपनीयता नीति >
कृपया अपनी प्रतिक्रिया दें। प्रतिक्रिया सफलतापूर्वक सबमिट हो गई!
Choose Which VEX IQ Generation to View

VEX IQ (1st gen)

VEX IQ (2nd gen)