• 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
  • C++
    • ड्राइवट्रेन
    • मोटर और मोटर नियंत्रक
    • 3-तार वाले उपकरण
    • दिमाग
    • सांत्वना देना
    • नियंत्रक
    • तर्क
    • स्मार्ट पोर्ट डिवाइस
    • VEXlink
      • संदेश लिंक
      • सीरियल लिंक
    • सीटीई वर्कसेल
  • 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

सीरियल लिंक#

  • परिचय

  • क्लास कंस्ट्रक्टर

  • क्लास डिस्ट्रक्टर

  • पैरामीटर

  • नोट्स

  • उदाहरण

  • सदस्य कार्य

    • isLinked

    • भेजना

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

    • प्राप्त

परिचय#

serial_link क्लास रोबोटों के बीच रॉ बाइट्स की एक स्ट्रीम भेजने की अनुमति देती है। इसे रोबोट-टू-रोबोट संचार के लिए डिज़ाइन किया गया है, जहाँ भेजने वाला और प्राप्त करने वाला दोनों रोबोट डेटा स्ट्रीम की सामग्री को समझते हैं।

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

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

क्लास कंस्ट्रक्टर#

serial_link(
 int32_t index,
 const char *name,
 linkType type,
 bool isWired = false );

क्लास डिस्ट्रक्टर#

यह serial_link ऑब्जेक्ट को नष्ट करता है और उससे जुड़े संसाधनों को मुक्त करता है।

~serial_link();

पैरामीटर#

पैरामीटर

प्रकार

विवरण

index

int32_t

स्मार्ट पोर्ट जिससे संदेश लिंक जुड़ा है, उसे PORTxके रूप में लिखा जाता है, जहां x पोर्ट संख्या है (उदाहरण के लिए, PORT1)।

name

const char*

इस लिंक का नाम। यह सलाह दी जाती है कि यह विशिष्ट स्ट्रिंग इतनी लंबी हो कि वेक्सोस द्वारा हैश किए जाने पर एक विशिष्ट आईडी बन सके। “वेक्सलिंक” जैसा सामान्य लिंक नाम उपयुक्त नहीं होगा, क्योंकि इसका उपयोग किसी अन्य टीम द्वारा भी किया जा सकता है।

type

linkType

लिंक का प्रकार, या तो linkType::manager या linkType::workerइस जानकारी का उपयोग रेडियो को सही ढंग से कॉन्फ़िगर करने के लिए किया जाता है और साथ ही ट्रांसमिशन और रिसेप्शन के लिए उपलब्ध बैंडविड्थ को भी निर्धारित करता है। एक मैनेजर रोबोट के पास वर्कर रोबोट (520 बाइट्स/सेकंड) को जानकारी भेजने के लिए उपलब्ध बैंडविड्थ (1040 बाइट्स/सेकंड) से दोगुनी बैंडविड्थ होती है।

  • linkType::manager — सीरियल_लिंक ऑब्जेक्ट एक मैनेजर है
  • linkType::worker — सीरियल_लिंक ऑब्जेक्ट एक वर्कर है

isWired

bool

क्या serial_link ऑब्जेक्ट वायर्ड है (डिफ़ॉल्ट false):

  • false — serial_link ऑब्जेक्ट वायर्ड है
  • true — serial_link ऑब्जेक्ट वायरलेस है

नोट्स#

  • VEXlink वायरलेस और वायर्ड दोनों प्रकार के संचार का समर्थन करता है, और वायर्ड कनेक्शन के लिए बिजली आपूर्ति संबंधी समस्याओं से बचने के लिए एक संशोधित स्मार्ट केबल का उपयोग करने की सलाह दी जाती है।

  • वायरलेस संचार के लिए, प्रत्येक रोबोट को स्मार्ट पोर्ट से जुड़ा एक V5 रोबोट रेडियो चाहिए होता है।

  • VEXlink रेडियो का उपयोग EXP कंट्रोलर के VEXnet रेडियो के साथ किया जा सकता है, जिसे टकराव से बचने के लिए उच्चतम संख्या वाले स्मार्ट पोर्ट से जोड़ा जाना चाहिए।

  • VEXlink बनाने के लिए, दोनों EXP Brains को V5 रोबोट रेडियो से कनेक्ट होना चाहिए।

उदाहरण#

रोबोट 1 का कोड

// Create a wireless link in Port 1
serial_link link = serial_link(
  PORT1, // index
  "VEXRoboticsLink123456789", // name
  linkType::manager, // type
  true); // isWired

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

// Create a wireless link in Port 1
serial_link link = serial_link(
  PORT1, // index
  "VEXRoboticsLink123456789", // name
  linkType::worker, // type
  true); // isWired

सदस्य कार्य#

serial_link क्लास में निम्नलिखित सदस्य फ़ंक्शन शामिल हैं:

  • isLinked — जाँच करता है कि क्या EXP ब्रेन इस लिंक पर युग्मित और संचार कर रहे हैं।

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

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

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

किसी भी serial_link सदस्य फ़ंक्शन को कॉल करने से पहले, एक serial_link इंस्टेंस बनाना आवश्यक है, जैसा कि नीचे दिखाया गया है:

रोबोट 1 का कोड

// Create a wireless link in Port 1
serial_link link = serial_link(
  PORT1, // index
  "VEXRoboticsLink123456789", // name
  linkType::manager, // type
  true); // isWired

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

// Create a wireless link in Port 1
serial_link link = serial_link(
  PORT1, // index
  "VEXRoboticsLink123456789", // name
  linkType::worker, // type
  true); // isWired

isLinked#

यह बताता है कि सीरियल लिंक पर मौजूद EXP ब्रेन एक दूसरे के साथ युग्मित हैं या नहीं।

Available Functions
bool isLinked();

Parameters

इस फ़ंक्शन में कोई पैरामीटर नहीं है।

Return Values

यह एक बूलियन मान लौटाता है जो यह दर्शाता है कि EXP ब्रेन आपस में जुड़े हुए हैं या नहीं:

  • true — The two EXP Brains are paired and communicating on this link.
  • false — The two EXP Brains are not paired on this link.
Notes
  • किसी भी प्रोजेक्ट को शुरू करने से पहले, आगे कोई भी कोड चलाने से पहले, यह सुनिश्चित करने के लिए हमेशा जांच करना एक अच्छी प्रथा है कि EXP Brains लिंक किए गए हैं।

Examples

रोबोट 1 का कोड

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::manager, true);

  // Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.print("Robot 1 - Manager");
  Brain.Screen.newLine();
  Brain.Screen.print("Sending message...");

  // Message to send
  const char* message = "Hello Robot 2";

  // Send the message
  link.send((uint8_t*)message, strlen(message));

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

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::worker, true);

  // Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }
  
  Brain.Screen.print("Robot 2 - Worker");
  Brain.Screen.newLine();
  Brain.Screen.print("Waiting...");

  // Buffer to store incoming bytes
  uint8_t buffer[32] = {0};

  int32_t n = link.receive(buffer, sizeof(buffer) - 1);

  // Null-terminate
  if (n > 0) {
    buffer[n] = 0;

    // Display the message that was sent
    Brain.Screen.clearScreen();
    Brain.Screen.setCursor(1, 1);
    Brain.Screen.print("Robot 2 - Worker");
    Brain.Screen.newLine();
    Brain.Screen.print((char*)buffer);
  }
  else {
    Brain.Screen.newLine();
    Brain.Screen.print("No message received");
  }

send#

यह संबंधित मस्तिष्क को एक संदेश भेजता है।

Available Functions

1 — बाइट बफर का उपयोग करके संदेश भेजता है।

int32_t send( 
  uint8_t *buffer, 
  int32_t  length );

2 — कैरेक्टर बफर का उपयोग करके संदेश भेजता है।

int32_t send( 
  const char *buffer, 
  int32_t     length );

Parameters

पैरामीटर

प्रकार

विवरण

buffer

uint8_t* or const char*

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

length

int32_t

भेजने के लिए बफर की लंबाई।

Return Values

भेजे गए बाइट्स की संख्या को दर्शाते हुए int32_t लौटाता है।

Examples

रोबोट 1 का कोड

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::manager, true);

  // Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Robot 1 - Manager");

  // Track last sent state
  uint8_t lastState = 255;  // impossible initial value

 // Tell Robot 2 when the screen is being pressed
  while (true) {
    uint8_t state = Brain.Screen.pressing() ? 1 : 0;

    // Only send if state changed
    if (state != lastState) {
      link.send(&state, 1);
      lastState = state;
    }

    wait(0.02, seconds);
  }

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

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::worker, true);

  // Do not run code UNTIL the Brains are linked
   while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Robot 2 - Worker");
  Brain.Screen.newLine();
  Brain.Screen.print("Waiting...");

  // Track the last state
  uint8_t lastShown = 255;

  while (true) {
    // Variable stores 1 - pressed, 0 - not pressed 
    uint8_t state = 0;
    int32_t n = link.receive(&state, 1, 200);

    // Only update screen if state changes
    if (n == 1 && state != lastShown) {
      Brain.Screen.clearScreen();
      Brain.Screen.setCursor(1, 1);
      Brain.Screen.print("Robot 2 - Worker");
      Brain.Screen.newLine();

      // Display text if Robot 1's screen is being pressed
      if (state == 1) {
        Brain.Screen.print("Manager IS being pressed!");
      } else {
        Brain.Screen.print("Manager is NOT being pressed");
      }

      lastShown = state;
    }
    wait(0.02, seconds);
  }

receive#

अगले आने वाले संदेश की प्रतीक्षा करता है और उसे वापस भेजता है।

Available Functions

1 — वैकल्पिक टाइमआउट के साथ एक कैरेक्टर बफर में एक संदेश प्राप्त करता है।

int32_t receive( 
  char    *buffer, 
  int32_t  length, 
  int32_t  timeoutMs = 500);

Parameters

पैरामीटर

प्रकार

विवरण

buffer

char*

प्राप्त संदेश को संग्रहित करने के लिए बफर।

length

int32_t

बफर की लंबाई।

timeoutMs

int32_t

मिलीसेकंड में कितना समय लगेगा? receive केवल तभी नए संदेश की प्रतीक्षा करेगा जब कतार खाली हो (डिफ़ॉल्ट रूप से 500 मिलीसेकंड)।

Return Values

प्राप्त बाइट्स की संख्या को दर्शाते हुए int32_t लौटाता है।

Notes
  • receive अन्य लिंक किए गए EXP ब्रेन से अगला कतारबद्ध संदेश लौटाता है।

  • संदेशों को FIFO क्रम में पढ़ा जाता है (सबसे पुराना अपठित संदेश पहले)।

  • यदि receive कॉल करते समय कतार खाली है, तो यह एक नए संदेश के लिए निर्दिष्ट timeoutMs तक प्रतीक्षा करता है।

  • यदि उस समयावधि में कोई संदेश नहीं आता है, receive 0लौटाता है, और उसके बाद भेजा गया कोई भी संदेश अगली बार receive का उपयोग किए जाने पर पढ़ने के लिए कतार में रहता है।

Examples

रोबोट 1 का कोड

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::manager, true);

  // Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Robot 1 - Manager");

  // Track last sent state
  uint8_t lastState = 255;  // impossible initial value

 // Tell Robot 2 when the screen is being pressed
  while (true) {
    uint8_t state = Brain.Screen.pressing() ? 1 : 0;

    // Only send if state changed
    if (state != lastState) {
      link.send(&state, 1);
      lastState = state;
    }

    wait(0.02, seconds);
  }

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

// Create the link
  serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::worker, true);

  // Do not run code UNTIL the Brains are linked
   while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1, 1);
  Brain.Screen.print("Robot 2 - Worker");
  Brain.Screen.newLine();
  Brain.Screen.print("Waiting...");

  // Track the last state
  uint8_t lastShown = 255;

  while (true) {
    // Variable stores 1 - pressed, 0 - not pressed 
    uint8_t state = 0;
    int32_t n = link.receive(&state, 1, 200);

    // Only update screen if state changes
    if (n == 1 && state != lastShown) {
      Brain.Screen.clearScreen();
      Brain.Screen.setCursor(1, 1);
      Brain.Screen.print("Robot 2 - Worker");
      Brain.Screen.newLine();

      // Display text if Robot 1's screen is being pressed
      if (state == 1) {
        Brain.Screen.print("Manager IS being pressed!");
      } else {
        Brain.Screen.print("Manager is NOT being pressed");
      }

      lastShown = state;
    }
    wait(0.02, seconds);
  }

received#

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

Available Functions

1 — प्रत्येक प्राप्त संदेश के लिए एक कॉलबैक फ़ंक्शन पंजीकृत करता है।

void received( 
  void (* callback)(const char *, const char *, double) );

2 — प्रत्येक प्राप्त संदेश के लिए एक कॉलबैक को पंजीकृत करता है जिसमें एक अतिरिक्त int32_t फ़ील्ड शामिल होता है।

void received( 
  void (* callback)(const char *, const char *, int32_t, double) );

3 — केवल प्राप्त संदेशों के लिए कॉलबैक पंजीकृत करता है जिनका नाम संदेश से मेल खाता है।

void received( 
  const char *message, void (* callback)(const char *, const char *, double) );

4 — केवल प्राप्त संदेशों के लिए कॉलबैक पंजीकृत करता है जिनका नाम संदेश से मेल खाता है, जहां संदेश पेलोड में एक अतिरिक्त int32_t फ़ील्ड शामिल है।

void received( 
  const char *message, void (* callback)(const char *, const char *, int32_t, double) );

Parameters

पैरामीटर

प्रकार

विवरण

message

const char*

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

callback

function

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

Return Values

इस कार्य पर कीमत के लिहाज से कुछ भी रिटर्न नहीं मिलता है।

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

Callback Signature

callback(message, linkname, index, value)

तर्क

विवरण

message

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

linkname

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

index

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

value

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

Examples

रोबोट 1 का कोड

// Send left or right when pressed
void screen_pressed() {
  if (Brain.Screen.xPosition() < 240) {
    link.send((uint8_t*)"left", 4);
  } else {
    link.send((uint8_t*)"right", 5);
  }
}

int main() {
  /* vexcodeInit() is only required when using VEXcode.
  Remove vexcodeInit() if compiling in VS Code. */
  vexcodeInit();

// Create the link
serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::manager, true);

// Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  Brain.Screen.print("Robot 1 - Manager");


  Brain.Screen.pressed(screen_pressed);
}

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

// Called when message received
void received_callback(uint8_t *buffer, int32_t length) {
  char msg[32];

  // Copy safely and null terminate
  int n = (length < 31) ? length : 31;
  memcpy(msg, buffer, n);
  msg[n] = '\0';

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1,1);
  Brain.Screen.print("Robot 2 - Worker");
  Brain.Screen.newLine();

  // Display if Robot 1's screen is pressed on left or right
  if (strcmp(msg, "left") == 0) {
    Brain.Screen.print("Manager pressed LEFT");
  }
  else if (strcmp(msg, "right") == 0) {
    Brain.Screen.print("Manager pressed RIGHT");
  }
}

int main() {
  /* vexcodeInit() is only required when using VEXcode.
  Remove vexcodeInit() if compiling in VS Code. */
  vexcodeInit();

// Create the link
serial_link link(PORT1, "VEXRoboticsLink123456789", linkType::worker, true);

// Do not run code UNTIL the Brains are linked
  while (!link.isLinked()) {
    wait(0.1, seconds);
  }

  link.received(received_callback);

  Brain.Screen.clearScreen();
  Brain.Screen.setCursor(1,1);
  Brain.Screen.print("Robot 2 - Worker");
  Brain.Screen.newLine();
  Brain.Screen.print("Waiting...");
}

पूर्ववर्ती

संदेश लिंक

आगामी

सीटीई वर्कसेल

On this page
  • परिचय
  • क्लास कंस्ट्रक्टर
  • क्लास डिस्ट्रक्टर
  • पैरामीटर
  • नोट्स
  • उदाहरण
  • सदस्य कार्य
    • isLinked
    • 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)