• Hi all,

    I'm working on a project involving communication via RS485. I use a MAX485 board to convert it all and it works fine up to a certain point.

    A while ago, I installed one of @DrAzzy 's builds to get more RAM, since we needed that in the project. The thing is, since the new firmware install, the serial communication seems to have stopped working.

    The code below works on the newest 'normal' firmware, but somehow the value of reply is still 0 when we run the code on one of Drazzy's builds.

    digitalWrite(B8, 0);
    Serial1.setup(9600, {tx:B6,rx:B7,bytesize:8,parity:'none',stopbits:1});
    var reply = 0;
    
    function sSend(command){
      reply = 0;
      print("Command: "+command);
      digitalWrite(B8, 1); 
      setTimeout(function(){Serial1.print(command);}, 5);
      setTimeout(function(){digitalWrite(B8, 0);}, command.length/0.96+6.53);
      setTimeout(function(){
        reply = Serial1.read();
        print("Reply: "+reply);
        if(reply === ""){
          setTimeout(function(){sSend(command);},1000);
        }
      }, 50);
    }
    
    

    sSend("@01EO=1\r") is the command we send to turn on the power for one of our connected devices and it should return "#01OK". If there is no reply (when the supply power is turned off for example), Serial1.read() should return "".
    However, I noticed that when I run the code under Drazzy's firmware, Serial1.read() indeed returns "", but the actual value of reply is still 0, so sSend isn't called for a second time. It seems as if the code just stops there.

    I have a feeling it either has to do something with timing (although I tried a lot of different timings supported by my oscilloscope), or with the firmware not working well with Serial1.

    Any thoughts and advices are welcome :)

About

Avatar for user49360 @user49360 started