Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: can't opening comm

  1. #11
    Junior Member
    Join Date
    Jan 2011
    Posts
    26
    Rep Power
    16
    Thankyou Eros,
    I am sure that my communication port is COMM1.
    About the ERR code seem no effect, the value always 0. I check with opening program in the same time with accesing comm1, the thin basic return ERR number still 0.
    Would you like give me the sample of program?
    The spec of program only read data (count = xxx + lfcr) that I send from my device, no need command request.
    thank you verymuch

    regard

    hendryawan

  2. #12
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    160
    I think you need to open the port before setting the parameters

    try this it will loop and print any data received until you press a key.

    Uses "COMM"
    Uses "CONSOLE"
    Dim hcomm As Long
    Dim sBuffer   As String
    Dim nBytes    As Long
    Dim errnumbr  As Long
    
    '---Get Comms file number and assign 
      hcomm = COMM_FreeFile
    
    '---Open the port
      COMM_Open( "COM1", hcomm )
      If Err <> 0 Then 
        PrintL "Open Comms error: " + Err
      Else
    '---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 )
    
        Do
          If COMM_Get( hcomm, %COMM_RXQUE ) <> 0 Then ' Get size of incoming data
            NBytes = COMM_Get(hComm, %COMM_RXQUE)
            COMM_Recv(hComm, NBytes, sBuffer)
            Console_WriteLine(sBuffer)
          End If
        Loop While Console_WaitKey = ""   ' Anykey to quit
        
      End If
    
    'closing comm
      COMM_Close( hcomm )
      Console_WriteLine("end testing")
      Sleep (3000)
    
    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

  3. #13
    Junior Member
    Join Date
    Jan 2011
    Posts
    26
    Rep Power
    16
    Thankyou Mike,
    I has been test your script, but the result is only blank console windows.
    I also check with my first action that running the other application with communication, the result is still same. I check with my first program working normaly.
    regard

    hendryawan

  4. #14
    Junior Member
    Join Date
    Jan 2011
    Posts
    26
    Rep Power
    16

    baudrate can't change

    Dear all,
    It's long time to followup my project.
    Now I found ubnormality with thinbasic. Normaly I run the application using comm port. In thinbasic after I run the application (still can't work) then after I close the program, I try to use dos command mode com1
    capt1.JPG

    The baudrate still in 1200 eventhought I set baudrate in thinbasic application is 4800. For the other application (not thinbasic) the baudrate in 'dos cmd mode com1' is same as I set in the application.
    Please help me.
    best regards

    hendryawan

  5. #15
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    160
    I am not sure if I understand correctly but are you asking if the baudrate for com1 should stay at 4800 after you have closed the TB script? If that is your question I would expect it to return to the default setting for that com port not what you set in your program.
    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

  6. #16
    Junior Member
    Join Date
    Jan 2011
    Posts
    26
    Rep Power
    16

    Try with serial communication application

    Thank for reply,
    I just try the communication program with COM1 like hyperterminal or everything application with com. I has been try to change value of baudrate then open and close the program and check with command "mode com1" in dos, the result is the last value that I set. Not like in thinbasic eventhought I change the value of baudrate its no effect in mode com1 command.
    Any suggestion?
    Thank and best regards

    Hendryawan

Page 2 of 2 FirstFirst 12

Similar Threads

  1. opening 2 forms
    By hendryawan in forum UI (User Interface)
    Replies: 6
    Last Post: 15-02-2011, 11:19
  2. Cannot get COMM to receive
    By fgasoi in forum COMM (Serial communication)
    Replies: 7
    Last Post: 18-02-2010, 08:51
  3. 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
  •