Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Not receiving expected result from Comm_RECV

  1. #1
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4

    Not receiving expected result from Comm_RECV

    Hello,

    New to thinBasic so please excuse the newbie question. I'm attempting to modify an existing sample script to send/receive commands to an Amateur Radio Transceiver. I'm sending a simple command to read the frequency as instructed in the manual (the "FA;" command, see attached). It is returning 3 bytes, instead of 12, and it appears to be binary instead of plain ASCII text (also attached). The COMM parameters are correct, as the radio is talking okay to various other software.

    Here's the script template I used. Can anyone assist? I don't see much traffic in the COMM subforum. Thank you!

    Uses "COMM"
    Uses "CONSOLE"
    Dim hcomm as Long
    Dim sBuffer as string
    Dim nBytes as Long
    Dim errnumbr as Long

    hcomm = COMM_FreeFile

    COMM_Set(hcomm, %COMM_BAUD, 4800)
    COMM_Set(hcomm, %COMM_BYTE, 8)
    COMM_Set(hcomm, %COMM_NULL, False)
    COMM_Set(hcomm, %COMM_PARITY, False)
    COMM_SET(hcomm, %COMM_PARITYTYPE, 0)
    COMM_Set(hcomm, %COMM_STOP, 2)
    COMM_Set(hcomm, %COMM_RXBUFFER, 128)

    '---Open the port
    COMM_Open("COM4", hcomm)
    If Err<>0 Then MsgBox 0, "Error opening comm port"
    Comm_SEND(hcomm,"FA;")
    Sleep 200
    nBytes = COMM_GET(hcomm, %COMM_RXQUE) ' Get size of incoming data
    Console_writeline(nBytes)
    Comm_recv(hComm, nBytes, sBuffer)
    Console_WriteLine(sBuffer)
    Sleep 1000
    'closing comm
    COMM_Close(hcomm)
    Console_WaitKey
    Attached Images Attached Images

  2. #2
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4
    After experimenting a bit, I found that after setting the RTS on the radio to "enable", the results were different (albeit still incorrect). The only settings available on the radio are RATE (set to 4800 baud), TIME OUT (10m sec), and RTS. So, I wonder if there are some flow control things I need to change in thinBasic?

  3. #3
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Ray,

    thanks for trying thinBASIC. May I kindly ask for the following information?:
    - which version of thinBASIC do You run?
    - could You please add the following lines at the end of Your program? It will allow You to view the binary data byte values:
    dim byteValues(nBytes) as byte at strptr(sBuffer)
    printl join$(byteValues, ", ")
    
    - is there a manual available for Your ART?
    - what does the thinBasic\SampleScripts\COMM\COMM_ListDevices.tbasic return for Your device?


    Petr
    Last edited by Petr Schreiber; 28-09-2020 at 20:48.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #4
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4
    Hello Petr,

    Thank you for the reply, and sorry for the delay in getting back to you.

    I am running version 1.10.7.0 (that's what thinAir is reporting in the "about" dialog).

    I added the two lines of code and three bytes are displayed as: 254, 120, 126

    It appears that no matter what command is sent, the radio returns the same 3 bytes. So, it's probably something simple, like mismatched baud rate? or number of stop bits? As I mentioned earlier, several communication software programs are talking to the radio without any problems.

    Regards,
    Ray

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Ray,

    thank you for your reply. Could you please try a bit fresher version 1.11.6.0?
    https://www.thinbasic.biz/projects/t...c_1.11.6.0.zip

    Let us know if the issue persists. Thanks a lot.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4
    Hello again Petr,

    Thank you for your patience.

    I installed the latest version 1.11.6.0 after grappling with firewall and false virus warnings and tried again.

    This time... I'm receiving a "Process - Runtime Error" (see attached). When using debug mode, the script posts the error immediately.

    --Ray
    Attached Images Attached Images

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Ray,

    what I see on screenshot is not a sign of error - it is an automatic script CPU and Memory profiling, new feature in 1.11.x.x series. You will get this for any script launched from thinAIR.

    Should you produce run time error, you would see the Run time tab active, here I see Process tab active, which is fine.

    What does the console of your program display? Does it show anything this time?


    Thank you,
    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  8. #8
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4
    Quote Originally Posted by Petr Schreiber View Post
    Hi Ray,

    what I see on screenshot is not a sign of error - it is an automatic script CPU and Memory profiling, new feature in 1.11.x.x series. You will get this for any script launched from thinAIR.

    Should you produce run time error, you would see the Run time tab active, here I see Process tab active, which is fine.

    What does the console of your program display? Does it show anything this time?


    Thank you,
    Petr
    Hi Petr,

    The console consistently displays "0", no matter what I try. The nBytes variable contains zero. Nothing is being returned.

    Thanks,
    Ray

    EDIT: I set the baud rate down to 4800 in the script and on the device, and I did get something returned. Still not the correct data, however.

    EDIT2: After trying all baud rates... it works! at 38400. Curious that it doesn't work at slower rates.
    Attached Images Attached Images
    Last edited by Ray; 03-10-2020 at 21:18.

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Ray,

    I am happy to hear it worked . I do remember Eros refactored the COMM module recently, so good to hear 1.11.6.0 works.

    As for why it works with higher baud rate... 38400 is 8x4800. That seems very suspiciously equivalent to relationship between bits and bytes. Could it be a clue? I am sadly not experienced with serial communication.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  10. #10
    Junior Member
    Join Date
    Sep 2020
    Location
    Dunedin, FL, USA
    Posts
    6
    Rep Power
    4
    Quote Originally Posted by Petr Schreiber View Post
    Hi Ray,

    I am happy to hear it worked . I do remember Eros refactored the COMM module recently, so good to hear 1.11.6.0 works.

    As for why it works with higher baud rate... 38400 is 8x4800. That seems very suspiciously equivalent to relationship between bits and bytes. Could it be a clue? I am sadly not experienced with serial communication.


    Petr
    Hey Petr,

    Yes, I was happy too! However, I also got the program to run at 9600 baud after stepping through all the possible baud rates on both the radio and thinBasic. But now, the 38400 baud rate doesn't work again. Strange!

    But, if can get one baud rate to stick, then I will continue with thinBasic for further development of my project.

    Again, thank you for all the attention you have given this issue.

    Regards,
    Ray

Page 1 of 2 12 LastLast

Similar Threads

  1. Comm Module Comm_Recv
    By GKeely in forum COMM (Serial communication)
    Replies: 13
    Last Post: 13-03-2008, 19:01
  2. Comm_Recv causes thinBasic to crash
    By Bevan in forum COMM (Serial communication)
    Replies: 23
    Last Post: 08-08-2007, 10:59
  3. NEO speed test result
    By kryton9 in forum thinBasic General
    Replies: 9
    Last Post: 02-05-2007, 20:44

Members who have read this thread: 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •