Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Time Delay In Serial Port Using Vb6.0


    
    I want to use time delay in serial port for data transmission and data recieve using mscomm control in visual basic 6.0.
pls help me




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Serial Port Delay
Hi ,
In a data acquisition system 16 microcontroller based instruments are being queried from the application software by a single ascii character.The windows XP based application sends out single ascii characters e.g "a","b","c"...etc. against which a every instrument answers back with a 4-digit numerical string containing the real time data.I have written the application in VB6 using MScomm.

After sending every character the application is waiting for the instrument to respond with the numerical string for a particular timeout period.I have found this period to be optimally 200msec at 9600baud.I am enabling a timer from the instant of setting the mscomm.output property & subsequently disabling the timer depending on the condition of a boolean set by the mscomm input event.In case of a timer overrun event a messagebox"communication error" is being popped.

Now my question is why is this delay varying substantially & that too in the same PC?Sometimes 50msec is enough & sometimes I need more than 250msec.Is it a basic windows problem?It is not the case of background applications as ,apart from visual studio ,nothing else is running in my PC.
__________________
shantanu

Bluetooth Serial Port Delay
Environment: Windows XP, VB6, MScomm control, Bluetooth SPP

Symptom: If the application I wrote is closed and then immediately reopened, it takes about 3 seconds for the MScomm.PortOpen control to complete. If instead from within the program, the MSComm port is closed and then reopened, it takes 18 to 30 seconds to complete.

So somehow, different resources are released when the program is closed compared to when just the serial port is closed.

I'd like to get the 3 second delay without having to close the program.

Any ideas?
(Note: also posted in Microsoft forum)

Long Term Periodic Serial Port Communications In VB6 Consumes CPU Time
Can VB6 poll the serial port say every hour without sucking up 40 to 50% of the CPU time looping continuously waiting for a 60 minute timer interval to occur? For example, is there a way for a VB6 routine to run in "sleep mode" more efficiently until it is time to do a short data transfer via serial port, and go back to sleep until the next one?

Also having a problem that the PC power management sleeps or hibernates while VB6 is running (looping) waiting to poll the serial port once per hour. Can VB6 prevent PC power management or hibernation while a routine is running? The routine (which communicats via serial port and writes data to a file) works just fine (other than the CPU usage above) if polling is done every 5 minutes.

Thanks,
Mike

Problem With Reading Data From Com Port(serial Port)
hi

I am developing a vb program to read data from MSR (Magnetic Stripe Reader). I have connected the MSR in com port. i want to get the data(member id) from the magnetic member card when the member swipes it on the MSR. I am using the follwoing cods to initialize and read the data



i'm initializing the device MSR in form load



Code:
form_load()



MSComm1.CommPort = 3
MSComm1.Settings = "19200,n,8,1"
MSComm1.RThreshold = 12
MSComm1.InputMode = comInputModeText
MSComm1.InputLen = 0
MSComm1.PortOpen = True



Private Sub MSComm1_OnComm()
Dim aaa As String
If MSComm1.CommEvent = comEvReceive Then
aaa = MSComm1.Input
Text1.Text = aaa

End If
End If
End Sub




My problem is, for some cards the above mentioned code is working fine. ie, i can get the data and i am checking the member id with teh table. fine. but sometimes i am not getting anything from MSR when the member swipes the card. I don;t know what is the problem in my code.

The length of the Member id will variy from member to member, for example

the format %99999-123? - length is 11 characters

%99999/01-1123? -length is 15 characters

%99997-1? - length is 9 characters



Pls suggest me what is the problem in my code. and y ii cannot get any data from some of the cards. that cards are working in another machines without any problem



Thanks in advance

reagrds

Prem

Read Data From Serial Port Or COM Port
Anyone got code to read data from Serial Port of Com port?
Can you send me a copy?

Any help appreciated

Morith

Serial Port Emulator / Virtual Com Port
Hi,

i'm trying to write a serial port emulator:

if my pc has 2 serial ports (com1 & com2) i should get a (software) com3.

In this way i can talk trough some hyperterminal-like app. to my programm.....

Has anyone a hint?

How To Get Data From Serial Port /parallel Port
How do you capture data sent through the
serial/parallel port coming from another machine(lets
say from a pabx machine sending strings of data).

Is it possible to save the data to a txt/csv file for
processing? how?

Get Info From Serial Port (mouse Port)
hi dears

can you tell me how can i receive information from serial port
i have tv tuner remote control with its sensor i insert its sensor in serail port (mouse port) and i want to get message one when i press 1 and and two when i press two
how is it possible

Is There Any Controls Of USB Port? Like MSComm To Serial Port.
Microsoft provides MSComm for controlling communication through serial port. Is there any similar controlling tool for USB?
Where can I find relevent info?

Thanks in advance!

USB And Serial Port ?
The new laptops do not have a serial port,DB-9. Many of the device I connect to do not have a usb port. Clearly there are some converters <Belken and others> But what are they converting. I have a lot of the legacy Serial port devices in use. The device baud rate is limited to 9600. Is there any other route to take to avoid another cable thing and associated software?

Serial Port
Hi! I'm new in this forum.
I am finding code or samples to solve this kind of problem:
1. monitoring a serial port, waiting a stream
2. decoding it and display a string, saving it in a db

I know how to solve the second part, but I'm in trouble about the first....
Can anyone help me?

Thank you in advance!!

LP

Serial (com-) Port Again
i'm runnin' win2k and i want to have something like

button on a box connected to 9pin serial is pressed, VB tells me which one it was

i have searched lvr.com and i read much about INPOUT32.DLL but i have no clue how to implement it

Serial Port - IO Box
hey,

i tried to make a program in vb, used the MScomm stuff.

theres a main card whit an atmel chip.
on the main card is an other card connected this one have address 1 at this card there is a 3th card connected. this card have 8 relays and 8 in-ports.
i could add multiple card to the main card so i have got more relays and in-ports

schema;

maincard - 2ndcard adres1 - 3th card relays

when i add an other card i get :

Code:
maincard - 2ndcard adres1 - 3th card relays..
--------- - 3ndcard adres2 - 3th card relays..
"-" = fill up :p
when i want to switch a relay i need to give the address (for card 2ndcard or 3ndcard)in the string i.e.:


Code:
mscomm1.output = chr(1) <- address one
mscomm1.output = chr(1) < relay no. 1 & chr(10) & chr(13)
when i use this two lines, relay 1 on address card 1 is switching.

when i want to READ port1 i need to do :

Code:
mscomm1.output = chr(1)
var = mscomm1.input
i need to set the output this is for address 1 otherwise i dont receive data

is there an other way to do this ? to select address 1 to READ port 1 ?
because when i re-read a port MSComm1.Output = Chr(1) is stil in it and there comes an other MSComm1.Output = Chr(1) so relay1 is always on


Code:
Private Sub Command1_Click()
'this turns relay 1 one address card 1 on
MSComm1.Output = Chr(1)
MSComm1.Output = Chr(1) & Chr(13) & Chr(10)

End Sub

Private Sub Form_Load()
MSComm1.CommPort = 2
MSComm1.Settings = "9600,N,8,1"
MSComm1.SThreshold = 1
MSComm1.PortOpen = True
End Sub

Private Sub MSComm1_OnComm()
Dim sdata As String
MSComm1.Output = Chr(1)
'MsgBox sdata

sdata = MSComm1.Input
'MsgBox "evreceive " & sdata
Text1.Text = sdata



If MSComm1.CommEvent = comEvReceive Then
sdata = MSComm1.Input
'MsgBox "evreceive " & sdata
Text1.Text = sdata
End If
End Sub

Serial Port
I'm a novice in serial port programming. Can anyone help me how to retrieve and display the data after the port is open?

Serial Port
Hi all,

I am seek help. Hope my problem is not a big problem. What we all know that if we are using the parallel port in VB6 we have to use portout 888, &hFF and we have to import the I/O.

Then the serial port is it written in the same way as the parallel port? Or is there other thing I need to take note. Thank you for your help in advance



Regards

Serial Port
Hello!!!

I'm trying to receive an input signal through the serial port, at the moment I'm able to check if there is something at the port. What I'm doing at the moment is receiving an square wave generated by a signal generator; if the signal generator is turned off, the program displays a message saying that there is no signal, and when the device is inmediatly turned on the program displays the messag saying that there is a signal (or something at the com1).

What I want to do is that if I turned the signal off at any moment when the program is still running, is display a message or an action saying that the signal has been lost, and when turning the signal on again a message saying that it is back on.

In simple words I want to constantly monitor the serial port to check if there is or not any signal while the program is running.

thank you

Serial Port Through TCP/IP
Hi Everyone, this is my first post, and i hope you can help me with this
I know VB, C, and Java Programming Languages.
It Is been months that i am not coding in vb, but i think i will get back on training soon.
I need to develop a program that redirects serial port to a TCP port like:

192.168.1.1:234 --> (is really) COM 2 of 192.168.1.1 machine.

Can i do that with VB6 ?

thanks

Serial Port Help
Forgive my ignorance. I am trying to teach myself Visual Basic and have stumbled into a problem. I work for a TV station that broadcasts major league baseball games. We are getting data from a radar gun that sends pitch speeds over a serial port. I am curious about the settings I need to get it to work. The data is a constant pulse meaning data is continuously coming over the serial port. When I plug the gun data into hyperterminal..it works fine. But I need to get it to work with my program. Right now, all I get is jibberish. I need to see numbers pop up in a text box that I have on my form.

here's my code...what else do I need?

MSComm2.CommPort = 4 ' set the port
MSComm2.Settings = "1200,n,8,1" ' set the settings
MSComm2.RThreshold = 3 ' how many characters received per onComm event
MSComm2.InBufferSize = 3
MSComm2.PortOpen = True ' open the port
MSComm2.RTSEnable = True
MSComm2.Handshaking = comXOnXoff
MSComm2.InputMode = comInputModeText


Private Sub MSComm2_OnComm()
Select Case MSComm2.CommEvent
Case comEvReceive
RADARX.Text = MSComm2.Input
End Select

End Sub


Any help is much appreciated. I am wondering if it is a terminal emulation issue. (VT100 or ANSI works when I use hyperterminal)

Thanks

Need To Know All About Serial Port
hello everybody,
this is my first topic here
i'm very happy to know such an excellent forum and such professional members
i want you to help me in this please:
i want to know all about dealing with serial port using visual basic 6.0
i'm sure you'll give me info. more than i want
it'll be good too if you told me about a free e-book to download or a site that explains an detail how to deal with serial port by VB6

THANKS FOR CONSUMING YOUR TIME READING MY TOPIC

Serial Port
I wrote this code to run a kit, connected to the serial port:

Private Sub Command_Click()

MSComm1.PortOpen = True
MSComm1.Output =chr$(156) & chr$(8)
Do
A = Doevents ()
Loop Until MSComm1.InBufferCount = 2
Print MSComm1.Input

End Sub

At the end, the code print two characters on the form.
But the two characters are only for code check.
How do I convert both of them to obtain a decimal value
from 0 to 65536 (16 bit) by VB code ?
Thank you
Frank

Serial Port
How do I translate this GWbasic code to Visual Basic code ?

OPEN"com1:1200,n,8,1"AS#1
OUT &H3FB, &H1B
PRINT#1,CHR$(191);CHR$(70) 'Transmit 2 bytes
A$=INPUT$(1,#1) 'Receive
B$=INPUT$(1,#1) 'two bytes from port 1
PRINT ASC(A$) ; ASC(B$) 'Print the two received bytes
END on the screen

This code transmit and receive two bytes to and from a device
connected to the serial port COM1.

Thank you

About Serial Port.
CAN U tell me that how can I Increase the spped of the serial port using MSCommunications control without any modem Any other devices.

Serial Port
Hiya,

I've had a search, and can't find anything that covers what I need to do..

I've seen some referenes to MSComm but cant quite get it to work how I want..

I need to be able to control individual pins on a Serial Port, so for instance I would click a button and it would switch on Pin2 with a constant flow.. is this possible?

Much appreciated..

Serial Port
Hi Folks
I am working on a project which i need to switch a relay on for 1-2 secs via the computer. Surfing on the web I have been able to gather that VB can control the serial port. So heres the question can anyone devise the code that will turn the DTR pin4 on the serial port on for 1 sec everytime I run the code(I need it in .exe format but should be able to compile it myself). If this can be done easyish then I will be more interested in getting to grips with VB myself.
Many Thanks
Paul

Serial Port
I have two computers connected to each other through the serial port with an RS232 cable. I tried with some snippets I found out there, but I cannot make anything going out of the port to the other computer (MSComm1.OutBufferCount is always 0 regardless what I wrote on its Output property). Does anybody have any example I can try? TIA,

Serial Port
Is there a way to know if the serial port is broken with the MSComm Control ?

Serial Port
I have an application where i am communicating with upto 16 serial devices, currently i am having problem with my code where if one the serial devices is not communicating properly the entire application hangs. Can someone recommend a best to program this so if one device goes out the program can still run. Thanks for the help in adavnce.

Using The Serial Port
Hello ppl

Can anyone tell me how to use serial port using vb?
To start with I want to be able to connect a small light buls [or LED] to a serial port and turn it on or off with VB.

Any ideas?
Thanks in advance

Serial Port Help
Hi everyone

I could use some pointer on serial port programming. I havenít done any hardware type programming as of yet. I have a Heidenhain Length gauge. It uses photoelectric linear encoders. This instrument has a digital readout with a RS232 output line. Iím looking to get the Value off the digital readout and bring it into my program.

I have put a mscomm32.ocx onto my application. Iíve been reading up on serial port stuff.

I have the input mode set to text because when it is set to binary i get nothing!

Code
Private Sub cmdHeidenhain_Click()
' Open the serial port
MSComm1.CommPort = 1

MSComm1.Settings = "9600,N,7,2"

MSComm1.PortOpen = True

' Tell the control to read entire buffer when Input is used.
MSComm1.InputLen = 0


If MSComm1.PortOpen Then
' Send the keystroke to the port.

' Now " Ctrl + B" to Buffer

MSComm1.Output = Chr$(2)
aaa = MSComm1.Input
Text1.Text = aaa


' I get a value here in the MSComm1.Input of
' -.37184 and three square boxes
' but i cannot assign it to my variable Text1
' This is my text box


' Unless Echo is on, there is no need to
' let the text control display the key.
' A modem usually echos back a character
If Not Echo Then
' Place position at end of terminal
txtTerm.SelStart = Len(txtTerm)
End If
End If

MSComm1.PortOpen = False
End Sub



Thanks for any help

reston

VB Serial Port
Hey Guys,

I want to program an interface which could receive and send SMS with a cellphone connected to my Serial Port. Any ideas?

Serial Port Help
Hi everyone

I could use some pointer on serial port programming. I havenít done any hardware type programming as of yet. I have a Heidenhain Length gauge. It uses photoelectric linear encoders. This instrument has a digital readout with a RS232 output line. Iím looking to get the Value off the digital readout and bring it into my program.

I have put a mscomm32.ocx onto my application. Iíve been reading up on serial port stuff. Iím getting an error on the readout.

Code
Private Sub cmdHeidenhain_Click()

Dim Buffer As Variant
Dim Arr() As Byte

' Set and open port
MSComm1.CommPort = 1
MSComm1.PortOpen = True

' Set InputMode to read binary data
MSComm1.InputMode = comInputModeBinary

' Wait until 10 bytes are in the input buffer
Do Until MSComm1.InBufferCount < 10
DoEvents
Loop

' Store binary data in buffer
Buffer = MSComm1.Input

' Assign to byte array for processing
Arr = Buffer

End Sub

This is the code that I found in the help file.

Iím not sure what to do with the Variable Arr ?? My plan is to input data and put it into a text box so my app. can use it in my equation.

Thanks for any help

Reston

Serial Port.. How To Use It?
Hi,

I am working on a project that requires my computer to communicate with the device through the serial port.

I have never done it before. All I basically need is to upload a HEX file into a device through the serial port.

Are there any components (libraries) in the VB that I can use for this puprose? Like the Winsock component for Internet connection for example.

I would aprecciate any information.

Thanks,
- Andrew

Serial Port
To ensure that we Americans never offend anyone, particularly fanatics intent on killing us, airport screeners will not be allowed to profile people. They will continue random searches of 80-year-old women, little kids, airline pilots with proper identification, Secret Service agents who are members of the President's security detail, 85-year old Congressmen with metal hips and Medal of Honor winning former Governors.



Let's pause a moment and take the following test.



In 1972 at the Munich Olympics, athletes were kidnapped and massacred by:

a. Olga Korbutt

b. Sitting Bull

c. Arnold Schwartzeneger

d. Muslim male extremists mostly between the ages of 17 and 40



In 1979, the U.S. embassy in Iran was taken over by:

a. Lost Norwegians

b. Elvis

c. A tour bus full of 80-year-old women

d. Muslim male extremists mostly between the ages of 17 and 40



During the 1980's a number of Americans were kidnapped in Lebanon by:

a. John Dillinger

b. The King of Sweden

c. The Boy Scouts

d. Muslim male extremists mostly between the ages of 17 and 40



In 1983, the U.S. Marine barracks in Beirut was blown up by:

a. A pizza delivery boy

b. Pee Wee Herman

c. Geraldo Rivera making up for a slow news day

d. Muslim male extremists mostly between the ages of 17 and 40.



In 1985 the cruise ship Achille Lauro was hijacked and a 70 year old American passenger was murdered and thrown overboard by:

a. The Smurfs

b. Davy Jones

c. The Little Mermaid

d. Muslim male extremists mostly between the ages of 17 and 40.



In 1985 TWA flight 847 was hijacked at Athens, and a U.S. Navy diver was murdered by:

a. Captain Kid

b. Charles Lindberg

c. Mother Teresa

d. Muslim male extremists mostly between the ages of 17 and 40



In 1988, Pan Am Flight 103 was bombed by:

a. Scooby Doo

b. The Tooth Fairy

c. Butch Cassidy & The Sundance Kid who had a few sticks of dynamite left over from the train job

d. Muslim male extremists mostly between the ages of 17 and 40



In 1993 the World Trade Center was bombed the first time by:

a. Richard Simmons

b. Grandma Moses

c. Michael Jordan

d. Muslim male extremists mostly between the ages of 17 and 40



In 1998, the U.S. embassies in Kenya and Tanzania were bombed by:

a. Mr. Rogers

b. Hillary, to distract attention from Wild Bill's women problems

c. The World Wrestling Federation to promote its next villain: "Mustapha the Merciless"

d. Muslim male extremists mostly between the ages of 17 and 40



On 9/11/01, four airliners were hijacked and destroyed and thousands of people were killed by:

a. Bugs Bunny, Wiley E. Coyote, Daffy Duck and Elmer Fudd

b. The Supreme Court of Florida

c. Mr. Bean

d. Muslim male extremists mostly between the ages of 17 and 40



In 2002 the United States fought a war in Afghanistan against:

a. Enron

b. The Lutheran Church

c. The NFL

d. Muslim male extremists mostly between the ages of 17 and 40



In 2002 reporter Daniel Pearl was kidnapped and murdered by:

a. Bonny and Clyde

b. Captain Kangaroo

c. Billy Graham

d. Muslim male extremists mostly between the ages of 17 and 40





Nope, No patterns anywhere to justify profiling!

Serial COM Port Help
Hey, I am in charge of programming a Dashboard Viewer for a robot for a small competition. It will allow us to see joystick position, current speed, etc. on a laptop while we drive it. The only problem is, I don't know how to do (Serial) COM ports in VB. And since they are requiring me to use it, I was wondering if you could tell me how to create a COM port or any other info (like about how to show Joystick position) would be appreciated.

Serial Port
Hi, i want to read data from the serial port with a blocking function.

It seems that the function input on the mscomm control is not blocking, so I need to loop to check it often, but that makes the program use 100% of the cpu and this is very bad since I want to keep this program in the background when doing other things.

also, the OnComm event doesn't seem to work either, it never triggers...

I want the function to trigger as soon as someting new is in the port buffer, not 2 seconds after...

any idea about how to do that?

thanks

Krushstone

Serial Port ?.
Does anyone know how I could transfer an Access/SQL view to a data display sign? Currently we are getting data from an Access query and porting it through Wonderware via ODBC an Wonderware is sending it to an app called Omniserver which sends it on a serial cable to a data display sign. All that I need is to take the Access query and send it to a data display sign. I know this can be done with vb but I have never done any communications stuff so I'm at a lose as where to start. (It has to pull data every 15 min or so and then update the sign.)

Serial Port
Hi,
My VB application uses a label printer through a serial port.
(I use the Com control)

Some PCs use Com1 and some use Com2.

Is it possible to check a serial port through VB to see if a printer is connected ?

It's ok if the PC only has one serial port enabled. But when two are enabled...

Serial Port
In the property window of the serial port COM 1 / COM 2, I can set the port speed to 921600(!) bits/sec. but in all program languages (that I know) I can only set the speed max. to 115200 bps. So can I speed up the COM Port to a higher value than 115200 bps?
Thanks for any help.

Serial Port
Anyone have sample code on how to send a file from one computer to another through a serial port ?

WEb And Serial Port
Hello,
I am a student working on VB for some time now.
Problem:

Over my PC terminal i want files with specific extensions coming in from web to be sent to a serial port.
i.e for example,
lets say some .txt files are coming in .I want to send it to serial port.

PLease let me know how i can do it ,
both recieving from web and sending it over to serial port.Also please tell me a way i can make this a standard program so that i can install iin every PC in the network.

Any help will be highly appreciated.

Hari

Serial Port
Hi ,
I am working on VB for sometime now.
How can I read data from a serial port in VB.Any help in this matter will be highly appreciated.

Thanking You,
Hari

Serial Port
Hi


How I send "texts" and "commands" to serial port ?

thank you in advance

Serial Port...
hi guys/gals?

is there an api call equivalent to the mscomm control? if there is, what is it and how can i use it?

thanks in advance...

Serial Port
I have two PC using a little application in VB6 with the mscomm serial control.In each PC Ii can type any text in a textbox and in the other pc I can see the sametext. Works fine.But if..- I use the following printer.print "hello2" printer.enddocAnd the printer port is a com1 the text in the other side is garbage,also,if i type in dos command in any side, ( stoping the program): type any.txt > com1 dont workorStopping the program in any side and use print any file (with notepad) using th same port, print garbage in the text box in the other side.Pleas any help

Serial Port
I want my program to show the number and name of the serial ports on my
computer in the same style at e.g. Hyperterminal. Like,,,if the computer has
2 serial ports there will only be 2 serial ports on the list,,,or 10 if the
computer has 10.

Any suggestions on how this can be done ?

Usb To Serial Port
HI, iwant to send data from usb to serial port in vb6 how can do it i am using mscomm control to send data t0 serial port but know i want to send data through via usb.

Serial Port
I have realized a program that must manage the seriale door in order to receive given from moden a GSM and have used the following code:

Private Sub Comm1_OnComm()
Dim posizione As Integer
Dim j As Integer
Dim Buffer As Variant

On Error Resume Next

Select Case Comm1.CommEvent

Case comEvReceive
    
    If (FrmMain.Comm1.InBufferCount > 0) And (FrmMain.Comm1.PortOpen = True) Then
        
        InputData = ""
        FrmMain.Comm1.InputLen = 0
        While FrmMain.Comm1.InBufferCount > 0
            Buffer = FrmMain.Comm1.Input

                For j = 0 To UBound(Buffer)
                     InputData = InputData & Chr(CByte(Buffer(j)))
                Next j
        Wend

       
        FrmMain.Comm1.InBufferCount = 0
        'Chiamata alla funzione di decodifica
        If InputData <> "" Then decodifica_com InputData
    End If

End Select

Sometimes appears one of these two errors :
Error 92 For Loop not initialized
Or
 Out of string space

I do not succeed to understand to what can be due....

Serial Port Help
I need a little help. I've got an old win 3.11 program that talks via the serial port to a CNC machine. The problem is that I do not have the source code to this program, and I need to know the settings (baud rate, parity, etc.) that this program uses when talking to the CNC machine.

Is there anything I can run or write to determine what parameters are in use by the serial port? or what parameters are being passed by the program?

Thanks.

Serial Port
Iam trying to read data from a serial touchpad device in VB..How do i open and read it and where can i display it!

Thanxx

Copyright © 2005-08 www.BigResource.com, All rights reserved