Results 1 to 8 of 8

Thread: Cannot get COMM to receive

  1. #1
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    19

    Cannot get COMM to receive

    Folks;

    I have an application where I have to read data being sent by a gas turbine controller. It is at 4800 baud, 8N1 with no flow control. My main script is not working, so I tried something simpler, but it does not work either. I am hooked up for testing to another PC running Hyperterminal so I can send one character at a time from the keyboard - I just want to see my program echo, and it does not. Here is the code. (I put in an escape via the local keyboard.) The error code displayed is zero.

    [code=thinbasic]USES "CONSOLE"
    USES "COMM"

    DIM hcomm AS long
    DIM NBytes AS long
    DIM InBuff AS STRING

    '---Get Comms file number and assign

    hcomm = COMM_FREEFILE

    '---Set up all comms parameters

    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, 0 )
    COMM_SET( hcomm, %COMM_RXBUFFER, 64 )

    '---Open the port

    COMM_OPEN( 2, hcomm )

    console_printat("ERROR = " & err, 30, 6)
    DO
    NBytes = COMM_Get(hComm, %comm_RXQUE)
    COMM_recv(hComm, nBytes, InBuff)
    console_printat(InBuff, 20, 10)
    IF LEN( CONSOLE_INKEYB ) > 0 THEN 'Allow any key to abort
    CONSOLE_CLS
    CONSOLE_PRINTAT( "ABORTED", 37, 12 )
    CONSOLE_WAITKEY( 3 )
    COMM_CLOSE( hcomm )
    STOP
    ENDIF
    LOOP[/code]

    Thanks for any help. The debugger does not allow me to look at the RXBUFFER so I don't know how far it is getting, but Hyperterminal receives my sent data properly.

    Rick

  2. #2
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    19

    Re: Cannot get COMM to receive

    Sorry people - I just found it. Not really obvious from the help pages, but of course the com port has to say "COM2" rather than just 2.

    Rick

  3. #3
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Cannot get COMM to receive

    Exactly, I was just replying about that

    Change from
    [code=thinbasic]COMM_Open( 2, hcomm )[/code]
    to
    [code=thinbasic]COMM_Open( "COM2", hcomm )[/code]

    Also, possibly, if you have to post some thinBasic or other languages source code surround the source code wit code UBB code tag or better use the combobox just above the posting area called "Syntax highlight (geShi)" and it will insert code tags for you.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  4. #4
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Cannot get COMM to receive

    Can I also suggest you open the port then set the settings.

    replace FALSE with %FALSE.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Cannot get COMM to receive

    Michael,

    setting must be set before opening the port as stated in help file: COMM_Open
    This is a must.

    %FALSE and FALSE are in thinBasic synonymous. I'm too used to always type %FALSE but they are the same.

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  6. #6
    Member
    Join Date
    Jan 2010
    Location
    Montreal, Canada
    Posts
    40
    Rep Power
    19

    Re: Cannot get COMM to receive

    Hate to tell you guys, but even setting the parameters after opening the port, it still works. I will change it, however.

    Rick

  7. #7
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: Cannot get COMM to receive

    Eros in the PB help it doesnt state the parameters must be set before opening a port, it only states no comms is allowed.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: Cannot get COMM to receive

    Michael,

    you are right:
    "Set the parameters needed to communicate with a serial port. This must always be done before you can send and receive data through the port"
    I confused it with port opening.
    I will amend thinBasic help

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

Similar Threads

  1. can't opening comm
    By hendryawan in forum COMM (Serial communication)
    Replies: 15
    Last Post: 11-12-2012, 02:38
  2. COMM Module?
    By Lee Allen in forum COMM (Serial communication)
    Replies: 5
    Last Post: 24-03-2007, 19:21

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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