Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
Marat KhM

Marat Kh

@Marat Kh
About
Posts
5
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

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

    @hek
    Ok! Thnx so much!!!

    Development

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

    @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

    Development

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

    @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

    Development

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

    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;

    Development

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

    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!

    Development
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular