[2005] serial port write buffer - timing issue -
Hello,
I'm trying to communicate with an rs485 device, and was having trouble with the timing.
The device uses "stick parity". The protocol defines this as setting the first byte of a packet to mark parity (this is the byte corresponding to the address of the device), and the remainder of the packet is set to space parity.
The problem I am having is that it will not always accept my packets, and every once and a while, will stop responding completely until I power cycle the device
So, I set up my packet transmission like this
example packet Code:
Private Sub purge()
'//******************************8
' This packet sends a command to the cpu to activate a purge
Dim TX(10) As Byte
sp.Parity = IO.Ports.Parity.None
TX(0) = CURRENT_CPU ' ADDRESS OF THE CPU
TX(1) = 9 ' NUMBER OF BYTES TO FOLLOW
TX(2) = PURGE_BARS
TX(3) = PURGE_CONTROL_BYTE ' DETERMINES WHICH BARS TO PURGE
TX(4) = PURGE_TIME_BAR1
TX(5) = PURGE_TIME_BAR2
TX(6) = PURGE_TIME_BAR3
TX(7) = PURGE_TIME_BAR4
TX(8) = PURGE_TIME_BAR5
TX(9) = PURGE_TIME_BAR6
TX(10) = CByte(get_checksum(TX, 10)) 'TWO'S COMPLEMENT OF THE SUM OF THE PACKET
sp.Parity = IO.Ports.Parity.Mark ' SEND THE FIRST BYTE OUT WITH THE PARITY BIT SET TO ONE, TO INDICATE THE START OF THE PACKET
sp.Write(TX, 0, 1)
sp.Parity = IO.Ports.Parity.Space ' THE REMAINDER OF THE PACKET HAS ITS PARITY BIT SET TO ZERO
sp.Write(TX, 1, 10)
While (sp.BytesToWrite > 0) ' WAIT UNTIL THE TX BUFFER IS CLEAR
End While
End Sub
In this code, I define the packet in a byte array, and set the parity to mark. I write the address byte to the buffer, then switch parities to space, and then write the remainder of the packet to the buffer.
This works intermittently.
Looking on an oscilloscope, I can see that there is about a 4ms delay between the address byte and the remainder of the packet, and I think this may be the cause of my communications problem.
Is there anyway I eliminate this delay?
Thanks,
ioll
[2008] SerialPort DataRCV Handler and WriteTimeout -
Assume you have serial port WriteTimeout set to -1. If you issue a write to the serial port, and it gets blocked for whatever reason, does the Serial Port DataReceive event continue to fire, or is it blocked also???
how to read(decode) serial data -
I am hoping to find a bit of help on a task that i would like to complete.
I have a sports timing system that is connected to a scoreboard, unfortunately the scoreboard is now obsolete and no more parts are available. So, once my supply of spare parts is gone I would have to buy a
Timing in serial communication -
I have got a timing problem on the serial communication line. I have to switch the RS232 transmit line to low and high, both for a specified time. After that some bytes have to be sent (with 10400 Baud, I like that). The whole operation has to be programmed in VB6.
Both tasks are qu
Continuous serial port polling. Need your idea. -
This might be simple but I think I need some help on it as I have been away from coding for a long time. This is what I am trying to do. Poll a device from serial port and pass it to somewhere, let’s say a memory buffer. This should run in the background. Then another program, specif
[2005] Serial Port To Usb Adapter -
I have a device to which I communicate via a serial port. If I were to use a serial port to USB adapter, how would I achieve this without having to recode? For example, is there some way of setting up a virtual serial port? That is, although my device is connected to a USB port, I want
How to clear the receive buffer of serial communication port -
Hi,
I write a vB program to communicate with AT89C51 microcontroller via serial communication port. When I run the program first time, the communication between the VB program and the AT89C51 works as expected. However, when I exit the program and then execute it again (after few se
Timing -
Has anybody used timing in there programs? My problem is I need to have a procedure executed every second. The procedure will not take more than a second to execute. Does anybody know any functions that will guarantee to at least start the procedure evey second? My problem is I need to
MSCOM32 and Input Buffer -
I never use a string to read data from the serial port. I always read it into a buffer (Array of Bytes/Structure).
Now that I have to use VB6, the serial port component (MSCOMM32) can only read data from the serial port into a string.
How do I go about reading from the serial port in
Using printf and puts to write to serial port -
I am having trouble figuring out how to transfer data from a microcontroller UART to my PC. I am using printf and puts. I can get the data to show up in a HyperTerminal window, but I can't get my Visual C++ code to read the data from the PC's serial port buffer. I'm pretty sure (but no
[2005] Reading from serial port -
Im currently working on serial port RS232 communication, im able to set configurations thru serial port to my device, but having problems reading from the port. Ive been advised that there're two ways of doing it, which include write the program so that the incoming data is stored insi
Control Serial Port -
Is there a way to control the serial receive port.
What i mean is that let's said i will just want to receive 500 data and wait for 5 secs then receive the next 500 data.
I tried to do that using a timer but it does not help.
For example.
I need to receive a 26k bytes of data
[2005] Activating Individual Pins on a serial port. -
I am looking to activate a electronic relay by wiring it to an individual pin on a serial port.
I need to write a peice of code in either .net or vb6 (i'll post this same post in the vb6 thread as well) that will activate an individual pin of my choice and then deactivate when i tog
Serial Port Timing -
I am writing a program which sends a text file to to a microcontroller via the serial port with the MSComm control.
I need to put a 10ms delay after each character and a 50ms delay after each line.
Can anyone give me some help?
[2005] serial port write buffer - timing issue -
Hello,
I'm trying to communicate with an rs485 device, and was having trouble with the timing.
The device uses "stick parity". The protocol defines this as setting the first byte of a packet to mark parity (this is the byte corresponding to the address of the device), a
mscomm using usb to serial (rs232) adapter -
Hi, i'm builing an application to capture some data from an external device, my program works fine when i plug it to the serial port of my test computer. The problem arises when i try to use it in a laptop that has no serial port, i'm using an USB to serial adapter but my program can't
Serial Port, Part Deaux -
Update.
We bought a system that tracks machines and sends the data to the serial port on a server. The application that interprets the data received is written in VB6, so I know it can be done.
We purchased the application, but can't get the source code. So, short term, we will
[2005] Serial Port Issue -
I am reading data from a serial port. The following sequence of data is coming in every 2 milliseconds. The data starts with a two and ends with a 3.
After about 4 seconds the sequence gets out of order. I guess the buffer is filling up. Is there a technique to correct this? Than
Autocross Timing System -
I would like to make some new timing software for my local sports car club. We have a timing light system that just triggers the serial port whenever the car drives through the light. My main question is would the standard VB timer control be the best way to keep time?? Or could wou
[2005] simple question on Serial communication -
Hi guys, i have a simple question on serial port communication
I am using VS2005 currently. In any application project, the serial port component can be found on the toolbox. So I can use it by just dragging the serial port icon on my application panel.
But what if i want to use
Comm Control 6.0 and Serial Printer -
Hi,
I have a situtation where I have two programs using the same serial port. Usually COM1. We have a hardware device that handles which device receives the communication.
The two things are: 1) Serial printer 2) My VB Program. Neither of these can change.
The issue: It
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?
Serial port listener -
I have a piece of hardware that takes pulses from various machines (up to 48) and sends them to the serial port on a server. I want to write an application that does something with that data. What I need is something that can "listen" to the serial port and save what it hears
[2005] Weird Serial behavior -
This is going to be a fairly bizarre question, as it isn't necessarily a PC problem, so there will have to be a bit of background.
I'm writing a program to control a robot. The robot can communicate over a serial port in two ways. One could be called "normal", while the ot
[2005]sniffing serial port! -
HI Guys,
This is my first post on the forums. I really have positive impression of this forums. lot of involvement!
any ways... have any one played around with serial port in VB?
I have One application running and transmitting the data through serial port and I want to design
Required source code to make USB Port as Serial port. -
Hi anybody out here,
Do anyone know how to write the source code to convert the USB to Serial Port and used it as serial com port to communicate.
Please advice
Thank You
Using serial port to connect to Sensor circuitry -
Hello. I'm doing a project that require a sensor to be connect to my VB application. I've decided to use serial port as it intermediate. so how to write the programming for serial port and how to set it baud rate ? Thanx
com buffer -
hey guys
i just need to know
if i can read the outbuffercount , does this mean the data are definately sent over the serial port? in other words if data sent got to the output buffer does it mean that they are totally sent through the serial cable plugged for example?
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 t
serial port communication using multithreading -
hello,i want to require vb.net code for reading stream of data asynchronously from serial port using multithreading as a background thread.so that is required,if more than one RFID tag read by serial port at a time.so how i can store all the tag read by serial port.
MSComm timing problem -
I'm reading an Avtron foot counter from the serial port via MSComm. I'm doing it through a timer, so that I can continually read the port. My problem is that the counter sends a "canned" message. I only need the last value of the message. However, the timing is not always
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
reading data from serial port (rs232) Vb.net 2005 -
Hi, I have a device with a RS232 output which can be connected to the serail port of the computer. I need to read the data using Vb.net 2005 . I tried dragging & droping the serial port component on to my form, but i stil cant get to readf the data. Anyhekp wil be really helpful. D
Serial Port Class -
Does Any one had this Problem?
If I use ReadLine without limiting th buffer, then Is like hunging Up.
If I put a limit, then the Result sometimes overlapping the previous one even I clear the buffer.
If I use ReadTo then It ok.
I would like to know why?
Note: I use tim
Data from telnet to serial port -
Hi,
Does anyone know how you can get incoming data from a telnet connection and send that data out of a serial port. A little bit like NAT.
I want to be able to connect to a port on my machine and all keystrokes i send to that telnet port are relayed out to a serial port.
I w
How to change COM port number -
I need to write a program in VB6 to list all of the available COM ports on a
computer and allow the operator to change the COM port number. I can get the list of available COM ports using the WMI but how to I change the COM port number?
I have to support a legacy program that looks
[resolved] to use 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 Question -
Hey
i want to find a way to listen to the serial port via vb5
i need to check every bit that goes threw there.
another thing : if i have a remote control connected to the serial port , do i need to initiliaze it ? or it will send data even if i am just using windows ?
1
Emulate Left Mouse Button -
This is for a school project. I'm building a program that receives a number from the serial port. If that number is number 4, for example, it simulates the left mouse button. So, if the mouse is over a command button, and the serial port receives the number 4, the command button will
serial port power -
Hey there!!
I have wired an alarm to the serial port.. Exept when its pluged in it is always on. Is there a way to shut down the power of a serial port by using code?? I have files that can only be read with my software. if someone tries to access these files I would like to turn o
Serial Port Redirection via Terminal Services -
First off, I’m not a proficient VB programmer but I’ve inherited a bit of VB code that is giving me some problems. Basically a PC has a Weighing Scale attached to a serial port, a bit of VB code monitors this serial port and when it receives the weight of an item transfers this to