Announcement

Collapse
No announcement yet.

newline "n| isn't a 0x0A

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • newline "n| isn't a 0x0A

    I just ran into a problem because "\n" isn't a newline char. (0x0A)
    I don't know what it is, but it's not the same as every other compiler I use.
    I had to go through all my code that was talking with another system via the serial port, and replace all the occurrences of "\n" with 0x0A.


  • #2


    Oh, and another issue.
    When I used serout("B"), the other equipment received a "@".
    I had to change the "B" to 0x42, then it worked.

    Comment


    • #3
      Can you please explain a bit further what you mean?

      func main()

      var x;

      x := '\n';

      print(x);

      repeat forever

      endfunc
      Regards,
      Dave

      Comment


      • #4


        When I used serout("B"), the other equipment received a "@".
        thats because you are passing a string to serout, which only accepts a constant.

        try serout ('B');

        fair enough - it would be nice if the compiler warns you about things like this - it will one day...

        (to note, its actually sending the low byte of the pointer to the string with "B")
        Regards,
        Dave

        Comment


        • #5
          The code was watching for a message from another device.
          var ch := serin();
          if (ch == "\n") dosomething(); // THIS FAILED
          if (ch == 0x0A) dosomething(); // THIS WORKED

          Same thing with serout();
          using "serout("\n");" - the other device didn't receive a 0x0A. (No, I don't have a convenient way to find out just what it did receive.)
          using serout( 0x0A); worked just fine.



          Comment


          • #6


            as mentioned in the previous post, you are passing a string as an agument instead of a character constant, therefore, you are passing the low byte of the address of the string
            Regards,
            Dave

            Comment


            • #7


              Arrgh, again.
              Sure would be nice if the compiler could actually find blatant compile time errors. (Like every other language compiler does.)

              Comment

              Working...
              X