I got a problem with serial port read which I use like this:
sp.Read (byteBuffer, 0, 100);
but the problem is that it returns before it has read the 100 bytes - is
there a way to set up the port in a syncronious state so that it wont return
before it has finished? And no - I can't use the work around to smaple until
I got all 100 bytes read because I use the timeout option in my app.
Thanks
Ole 3 6065
Ole,
Why not use the workaround? You can perform the read, and keep track of
how much time has elapsed. Then, on the next read, you could decrement the
amount of time that you are willing to wait by the next amount of time left.
So, for example, if your timeout is initially 10 seconds, and you are
reading 100 bytes, then what you need to do is store the time before you
start the read.
If the first read returns 10 bytes, and it takes 2 seconds, then you
issue the second read for 90 bytes, and set the timeout to 8 seconds.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ole" <ol*@blabla.com> wrote in message
news:uS**************@TK2MSFTNGP04.phx.gbl... I got a problem with serial port read which I use like this:
sp.Read (byteBuffer, 0, 100);
but the problem is that it returns before it has read the 100 bytes - is there a way to set up the port in a syncronious state so that it wont return before it has finished? And no - I can't use the work around to smaple until I got all 100 bytes read because I use the timeout option in my app.
Thanks Ole
Thanks - but it won't work in my application - trust me (it's to complicated
to explain why). If syncronious mode aren't possible can anybody explain why
on earth it is possible to set the sp.ReadTimeOut parameter and what it is
used for????
Thanks
Ole
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:eL**************@TK2MSFTNGP05.phx.gbl... Ole,
Why not use the workaround? You can perform the read, and keep track of how much time has elapsed. Then, on the next read, you could decrement the amount of time that you are willing to wait by the next amount of time left.
So, for example, if your timeout is initially 10 seconds, and you are reading 100 bytes, then what you need to do is store the time before you start the read.
If the first read returns 10 bytes, and it takes 2 seconds, then you issue the second read for 90 bytes, and set the timeout to 8 seconds.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Ole" <ol*@blabla.com> wrote in message news:uS**************@TK2MSFTNGP04.phx.gbl...I got a problem with serial port read which I use like this:
sp.Read (byteBuffer, 0, 100);
but the problem is that it returns before it has read the 100 bytes - is there a way to set up the port in a syncronious state so that it wont return before it has finished? And no - I can't use the work around to smaple until I got all 100 bytes read because I use the timeout option in my app.
Thanks Ole
Why not try us on the "too complicated part". You might be surprized.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Ole" <ol*@blabla.com> wrote in message
news:uH**************@TK2MSFTNGP05.phx.gbl... Thanks - but it won't work in my application - trust me (it's to complicated to explain why). If syncronious mode aren't possible can anybody explain why on earth it is possible to set the sp.ReadTimeOut parameter and what it is used for????
Thanks Ole
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in message news:eL**************@TK2MSFTNGP05.phx.gbl... Ole,
Why not use the workaround? You can perform the read, and keep track of how much time has elapsed. Then, on the next read, you could decrement the amount of time that you are willing to wait by the next amount of time left.
So, for example, if your timeout is initially 10 seconds, and you are reading 100 bytes, then what you need to do is store the time before you start the read.
If the first read returns 10 bytes, and it takes 2 seconds, then you issue the second read for 90 bytes, and set the timeout to 8 seconds.
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Ole" <ol*@blabla.com> wrote in message news:uS**************@TK2MSFTNGP04.phx.gbl...I got a problem with serial port read which I use like this:
sp.Read (byteBuffer, 0, 100);
but the problem is that it returns before it has read the 100 bytes - is there a way to set up the port in a syncronious state so that it wont return before it has finished? And no - I can't use the work around to smaple until I got all 100 bytes read because I use the timeout option in my app.
Thanks Ole
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: collinm |
last post by:
hi
i send a command to a led display, the led display is suppose to return
me some character
i write a string on a serial port
void ledDisplayExist()
{
char msg={'\0', '\0', '\0', '\0',...
|
by: ORC |
last post by:
Hi,
I'm looking for a way to implement a simple functionality in my serial port
C# wrapper. I'm making a program that must run on both a Pocket PC and a
"normal" PC. The application is quite...
|
by: shayke via DotNetMonster.com |
last post by:
Hello,
I am trying to write asynchronous serial port.
meaning, read and write operations are made via async cllbacks.
so far so good.
I open my port in continues state:
1)Set the BytesToRead...
|
by: Lonifasiko |
last post by:
Hi,
I've been able to communicate using HyperTerminal with my device via
serial port COM1. I just send a command and device switches on. I just
need that to start playing with it. This way, I...
|
by: Mircea |
last post by:
Hi everybody,
I have a big problem. I am trying to use serial communication in C# 2. The
problem is that the event DataReceived is never fired. I have tried on two
computers and it does not...
|
by: H J van Rooyen |
last post by:
Hi All,
I am writing a polling controller for an RS-485 line that has
several addressable devices connected.
It is a small access control system.
All is well- the code runs for anything from...
|
by: Rob |
last post by:
Hi all,
I am fairly new to python, but not programming and embedded. I am
having an issue which I believe is related to the hardware, triggered
by the software read I am doing in pySerial. I...
|
by: cmdolcet69 |
last post by:
This code below write a serial command to the com port then read the
results and disaplays it into the label1.text property when
button1_click event is triggered. I think what is going on is that...
|
by: terry |
last post by:
Hi,
I am trying to send a character to '/dev/ttyS0' and expect the same
character and upon receipt I want to send another character. I tired
with Pyserial but in vain.
Test Set up:
1. Send...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |