Results 1 to 4 of 4

Thread: MSComm Firing Too Much!! Why?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Post

    Hello, I have built an external device that transmits ASCII characters 0,1,2,3,4,5,6,7,8,9, and * via a serial connection. Using hyperterminal, I can connect to my device and indeed my device is transfering the characters correctly. I need MSComm to fire EACH time one character has been recieved.

    Now, I have a MSComm Control, here is the settings I have used:


    With comKeypad
    .CommPort = CInt(sSetting)
    .Settings = "9600N,8,1"
    .InputLen = 1
    .DTREnable =False
    .EOFEnable = False
    .RTSEnable = False
    .Handshaking = comNone
    .RThreshold = 1
    .SThreshold = 0
    End With


    Now, since my device used NO handshaking signals, OnCOMM should fire everytime one single character is recived. Inside of OnCOMM(), I'm incrementing a variable and printing it to the debug window so I can keep track of how many times OnCOMM fires. Unfortunately, OnCOMM is firing 4-7 times per character. It correctly sends the one character to, say a text box, but still, the event fired way too many times. This is a big problem for me. I need to have it either fire only once, or fire a consistant number of times for each character.

    So what could be the deal? Or maybe did I set the connection up wrong?

  2. #2
    Junior Member
    Join Date
    May 1999
    Location
    Nepean,Ontario,Canada
    Posts
    16

    Post

    Hello Philip,

    I need more info about your project.

    1- Do you know the amount of byte send between your external device and the computer.

    2- Does all byte sent through the COM port are ASCII.

    3- Does the software request a command to the external device or is in the waiting state. (like embedded system)

    On my side I only use the on_comm_event to detect error in the communication.
    I use a subroutine, it's faster about 5 times faster. This only depends on speed issue for your project.

    Let me know,

    Regards,
    Sebastian

    [email protected]


  3. #3
    Junior Member
    Join Date
    May 1999
    Location
    Nepean,Ontario,Canada
    Posts
    16

    Post

    There 2 ways to solve that problem.

    If you still want to use the on_comm_event
    there a property on the mscomm1 that is call inputlen. Set it to 1 and it will can the on_comm_event everytime one character is in the input buffer of the COM port. This should work.

    The input mode has to be in ascii also.
    (I guest you know about this, it's just because you did not mention it)


    They other way you can do it, is to loop the software.
    Something like:

    Sub InBuffer()
    Do
    Doevents
    loop until mscomm1.inputbuffer >= 1

    data = mscomm1.input
    Call YourSubroutine(data) 'For calculation or conversion
    Exit sub

    You can use a timer to call that function or do something similar.

    Hope that help,

    I you want, you can send me the code and I will have a look.

    [email protected]

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    Dallas,TX
    Posts
    170

    Post

    Thanks Sabastian:

    Yes my design is an embedded project, using a 8051 to transmit ASCII bytes to the PC. I really need to be able to count exactly how many bytes have been transfered. I tried the incrementing an integer thing, but as I noted, that isn't accurate at all.

    I do not know how many bytes will be sent between my device and the PC. Think of it as a keypad interfaced to the 8051. Everytime a user presses a key, it sends one byte to the PC. The software IS in a waiting state. I'm not "getting" the data from the device. The device sends it and I need to be able to detect it. Have any suggestions?

    I really appreciate you taking any time you can in helping me out. This is part of our senior project and very fundamental to our project. I did not anticipate the problems with MSComm.

    Thanks!!

Posting Permissions

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



Click Here to Expand Forum to Full Width