Menu

HserGetNum and HserGetString not work?

Help
2017-01-29
2017-02-01
  • Fábio Almeida

    Fábio Almeida - 2017-01-29

    My config: Windows 7 64, GCB 0.96

    #chip mega328p, 16
    
    #define USART_BAUD_RATE 9600
    #define USART_BLOCKING
    
    Dim myNum as Word
    
    Do forever
    HSerGetNum myNum
    HSerPrint myNum
    loop
    

    Serial not print myNum in terminal. In Arduino the LED TX not blink, only LED RX.

    Detail, in Windows XP and 7 32 the code worked, only not work in 64. this is normal?

     
  • Anobium

    Anobium - 2017-01-29

    No reason why this should not work.

    Can you check versions for me? You have installed Great Cow BASIC v.0.96 on the following:
    1. Windows 7 64 bit
    2. Windows XP
    3. Windows 7 32 bit

    All the same installs and the HEX generated by Great Cow BASIC v.0.96 only causes issues on the #1 above?

    Do this.
    1. Compare the ASM. Is this the same?
    2. Compare the HEX generated. Is this the same?

    I do not know what you are using to transit the HEX to the mega. Can you tell us?

    And, is this the same mega chip? is this three different mega chips? is this 3 different Ardunio's?

     
  • Anobium

    Anobium - 2017-01-29

    I Have just tested using Arduino on Win 7 on 32 and 64 bit. Configs #1 and #3 in the previous posting. No issues. All works as expected.

    I used AVRDUDE that is included in the Great Cow BASIC installation and I used Putty as my terminal.

    I enter a NUMBER and press enter and the number is returned. If I press enter (therefore without a number) I get 0 returned. This is same as the Win 7 32 & 64 bit computers.

     
  • Fábio Almeida

    Fábio Almeida - 2017-02-01

    The problem is terminal, with Putty the code work.
    Thanks.

     
  • Fábio Almeida

    Fábio Almeida - 2017-02-01

    The problem is with the terminal. Termina, Termite, RealTerm not work, only Putty and Hype.

    Detail: Terminals that do not work only have this problem if the code is written in GCB. When written in C (arduino) the problem does not appear in any terminal.

     
  • Anobium

    Anobium - 2017-02-01

    Are able get a hex dump for us? so, we can see the data stream. Are we missing a CR or LF?

     
  • William Roth

    William Roth - 2017-02-02

    I suspect that CR is not being sent after the "number" to the Arduino from the Terminal App.

    FYI. To send a "Number" from the Brays Terminal included with GCB, the CR box must be checked.
    See the screen shot.

    When Testing .. I noticed that if the Terminal (Brays in this case) does not send a CR, then HserGetNum will "hang" at that point and will never recover, no matter how may times the correct data is sent.

    To replicate the error. Uncheck the CR box. then send a "number", Then check the CR box and try sending a number again. Nothing .... I have found no way to recover. Just hangs there.

    William

    Test Code

    #chip mega328p, 16
    
    #define USART_BAUD_RATE 9600
    #define USART_BLOCKING
    
    'Variables
    Dim MyNum as Word
    Dim TestVar as Word
    
    HSerPrint "Arduino Uno R3 (Mega328P)"
    HSerPrintCRLF
    HserPrint "-----------------------------------"
    HSerPrintCRLF 2
    
    'Main routine
    Do
         HSerGetNum MyNum
         TestVar = MyNum    '// Make sure we are not seeing screen echo
         HSerprint (TestVar)
         HSerPrintCRLF 2
    loop
    
     
  • mmotte

    mmotte - 2017-02-03

    "This command will read a multi digit number received as ascii chars followed by a CR from an external serial source using a hardware serial module. The command checks that only numbers are input disregarding other characters while waiting for the ending <cr>. " from help.</cr>

    The buffer in HSerGetNum is only 7 long. It is expecting a numer 65535 or less because it is returning a number of type word. If no numbers are entered but a CR is sent then the initialization value of the return variable is 0. if other charaters than numbers are sent then they are disreagrded.

    the TEST
    "Uncheck the CR box. then send a "number", Then check the CR box and try sending a number again. Nothing .... I have found no way to recover. Just hangs there."

    When the CR box is unchecked then Bray's term sends just what is in the send window, in this case "444" . If you press send two more times then the buffer overflows and your program is stuck in oblivien.

    But if you send "444" with the CR box is unchecked then check the CR box and press "send" again, a strange number of 51228 will show up because the variable is only a word and you sent "444444".. But the HSerGetNum worked because the buffer of 7 chars did not over flow with 6 chars in it.

    But if you send "444" with the CR box is unchecked then delete the last '4' so you are sending "44" and check the CR box and press "send" again, you will get the correct number of "44444".

    It all goes back to sending a 5 digit or less number as ascii chars followed by a CR.

    FIX
    Limit the number of chars to 5.

    And do we need to limit the result to 65535? how do we alert the entry error to the operator? Send him a '0'? Alternate method? Make it a long?

    i will discuss with Evan.

    BR
    Mike

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.