Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Marat Kh
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Marat Kh

    • RE: Gateway serial port commands in one message. How can the recive and send it?

      @hek
      Ok! Thnx so much!!!

      posted in Development
      Marat Kh
      Marat Kh
    • RE: Gateway serial port commands in one message. How can the recive and send it?

      @hek Thnx.

      But can you explane how can i use this now in my code (from example):

      void loop()  
      { 
        gw.process();
      
        checkButtonTriggeredInclusion();
        checkInclusionFinished();
        
        if (commandComplete) {
          // A command wass issued from serial interface
          // We will now try to send it to the actuator
          parseAndSend(gw, inputString);
          commandComplete = false;  
          inputPos = 0;
        }
      }
      
      
      /*
        SerialEvent occurs whenever a new data comes in the
       hardware serial RX.  This routine is run between each
       time loop() runs, so using delay inside loop can delay
       response.  Multiple bytes of data may be available.
       */
      void serialEvent() {
        while (Serial.available()) {
          // get the new byte:
          char inChar = (char)Serial.read(); 
          // if the incoming character is a newline, set a flag
          // so the main loop can do something about it:
          if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) { 
            if (inChar == '\n') {
              inputString[inputPos] = 0;
              commandComplete = true;
            } else {
              // add it to the inputString:
              inputString[inputPos] = inChar;
              inputPos++;
            }
          } else {
             // Incoming message too long. Throw away 
              inputPos = 0;
          }
        }
      

      I mean function serialEvent in one package can see only first command, from 0 possition to \n.

      Thnx so much

      posted in Development
      Marat Kh
      Marat Kh
    • RE: Gateway serial port commands in one message. How can the recive and send it?

      @hek This is \n i think in the logger look like
      ->1;11;1;0;2;1#0A1;10;1;0;2;1#0A1;9;1;0;2;1#0A1;8;1;0;2;1#0A1;7;1;0;2;1#0A1;6;1;0;2;1#0A1;5;1;0;2;1#0A1;4;1;0;2;1#0A

      I don't khew why C# code sent multiple command in 1 line,
      i wrote once commande:
      _serialPort.WriteLine(GateCommand);

      GateCommand - It one command lke 1;16;1;0;2;1\n

      Bit in one tread in one time moment

      posted in Development
      Marat Kh
      Marat Kh
    • RE: Gateway serial port commands in one message. How can the recive and send it?

      This is \n
      _serialPort.WriteLine(GateCommand);

      string command = "" + nodename + ";" + neonnumber + ";1;0;2;" + powerstatus;
      // NODE_NAME, NUMBER_NEON, 1(set), 0 - без доставки, 2 - V_STATUS, VALUE (1- on, 2 - off);
      return command;

      posted in Development
      Marat Kh
      Marat Kh
    • Gateway serial port commands in one message. How can the recive and send it?

      Hi!
      I need to send 16 commands from gateway to nodes.
      When i send in com port Gateway command like:
      ->1;2;1;0;2;1\n1;11;1;0;2;1\n1;1;1;0;2;0\n1;2;1;0;2;0\n1;14;1;0;2;0\n1;16;1;0;2;1\n

      the gateway recive only first command in line 1;2;1;0;2;1\n
      i think becouse:
      examples/SerialGateway/SerialGateway.ino
      void serialEvent() {
      while (Serial.available()) {
      // get the new byte:
      char inChar = (char)Serial.read();
      // if the incoming character is a newline, set a flag
      // so the main loop can do something about it:
      if (inputPos<MAX_RECEIVE_LENGTH-1 && !commandComplete) {
      if (inChar == '\n') {
      inputString[inputPos] = 0;
      commandComplete = true;
      } else {
      // add it to the inputString:
      inputString[inputPos] = inChar;
      inputPos++;
      }
      } else {
      // Incoming message too long. Throw away
      inputPos = 0;
      }
      }

      But after this, the gate send command to node by NRF24 module.

      How can i recive and send multiple commands in one message?

      THNX!

      posted in Development
      Marat Kh
      Marat Kh