Waiting for receiving whole data in data receive event of serila port

0down votefavorite
I want to migrate one VB6 project to C#. In VB6 project MSCOMM control is used for serial port communication. Instead of using same control in C# application I have used serial port class.
Initially I am sending 4 consecutive commands to serial port. When I tried to debug the code I found
DataReceive event is working in separate thread.
I need 15 bytes response for first command 17 bytes response to second command.
But as we know DataReceive event for one byte also.
I want to get whole 15 bytes response for first command and then want to send second command.
I have tried following code.
private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
if (serialPort1.ReceivedBytesThreshold > sent_command.Length)
string data = serialPort1.ReadExisting();
int bufferLengh = data.Length;
string output_str;
char[] array = data.ToCharArray();
string final = "";
foreach (var i in array)
string hex = String.Format("{0:X}", Convert.ToInt32(i));
final += hex.Insert(0, "") ;
final = final.TrimEnd();
output_str = final;
MessageBox.Show(output_str);
Using above code I am getting data filled with one or two bytes and rest data bytes as "0" but data byte length is correct. (for first command it is 15 and second command 17 bytes)
Or sometimes data = ""
My question is how to wait in data receive event to get whole response and then it will receive the response for second command.
In VB6 application one polling timer is used.
If I used a timer in C# application then in that timer event timeout exception get fired and data receive event does not get fired.
Please help me to resolve this.
Thanks in advance.

Perhaps the solution discussed in this thread will help:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/f263cd57-9e88-41dd-bc38-ddaf1bd963c0/how-to-wait-for-a-serialport-receive-data?forum=netfxcompact

Similar Messages

  • TS1702 Tried installing application still says waiting for a whole day now

    Tried installing application still says waiting for a whole day now

    Reset iPad and try again.
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • I had to replace the hard drive on my computer.  I am now trying to download Adobe Photoshop CS6, previously purchased.  I get an error that files are missing after waiting for the whole download.  I have Windows7

    I had to replace the hard drive on my computer.  I am now trying to download Adobe Photoshop CS6, previously purchased.  I get an error that files are missing after waiting for the whole download.  I have Windows7

    The error msg said that the file archive part of Adobe photoshop CS6 is missing and that I need all parts in the same folder.

  • My sync won't start. It stays on step 1. waiting for sync to start, then i receive a notification that it cant

    My sync won't work, it can't start past step 1

    I've been having the same problem. It would either get stuck at "Waiting for changes to be applied" or "Waiting for items to copy". My last successful sync was on 10/15. Tried a number of times either via wifi or direct connect.
    Solved it in the following fashion:
    Connected the phone to the computer via Lightning cable.
    My phone was set to back-up to iCloud. Changed that setting to back up to the computer.
    Unchecked the "Sync Music" option under the music tab.
    Hit apply.
    After a wait - the back-up completed and all the music was removed from my phone.
    Once it was done, re-checked "Sync Music" - it got past "Waiting for Changes to be Applied" at this point.

  • Signed up for Firefox Sync but haven't received verification email

    I'm returning to Firefox after becoming thoroughly frustrated with Google Chrome. I logged into the last version of Firefox i had used (Nightly 29), synced my old stuff to the most recent version of Nightly (37a1), unlinked that device from the old Sync, restarted Firefox, created a New Sync login with my email address ([email protected]), and waited for the verification email. None received. Reequested that i be resent three times. Still nothing. No emails from Mozilla/Firefox in junk email or Office 365 spam filter for my domain.
    I see others have experienced issues with creating a new Sync account as well. Please advise how I can resolve this issue and return to Firefox on all my devices asap!
    Thanks,
    Jim

    Have you tried to request a verification email again recently?
    Just checked in with the Firefox Accounts team and they did say there were some email failures recently - but should be working now.
    Thanks for your patience

  • Stopping program without waiting for trigger

    Hi everybody
    I have a problem that I just can't get my head around. I have a program that I use to aquire data. The program goes through the motions of waiting for the trigger, aquiring the data on the appropriate channel, displaying it, and loops back to waiting for the trigger. The problem is That when I want to stop my program while it is waiting for a trigger I must wait for it to recieve a trigger before it will stop excution.
    Is there a way for my program to stop the trigger vi when I select to end the program?
    Thanks
    Beaton
    - there is always an easy way, but it is always the hardest to find

    Hi Beaton,
    you have to split the 'wait for trigger time' into shorter sub-steps.
    Let's say you wait 10sec for trigger signal. Make a loop instead waiting 1 second for 10 times! After each iteration you can check for: 'break the loop (end program)' or 'trigger received' or 'any other error occured'. This way you can stop your program very easily - you can also make your own error state saying 'Error number 123456: stopped by user'...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • I have signed in using my Apple ID to use iMessage and FaceTime, but it's still waiting for activation?

    If anyone could please help me, that would be much appreciated :)
    I have a full wifi connection and my Apple ID signs into the App Store so I know everything's working, but I don't know why it isn't activating my FaceTime and iMessage  

    ACTIVATING FACETIME AND IMESSAGES
    Activating Facetime and Imessages on your phone requires the ability to send SMS messages and depending upon where you are that might be an international SMS.  Check with your carrier to see if your plan supports sending of international SMS messages.  If you are having trouble activating Facetime or Imessages turn them both off on your device and reset the device (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for device to restart (no data will be lost)).  Wait for the device to restart and wait a minute and turn Facetime and imessage back on and wait for activation.  If that does not fix things read the following articles:
    http://support.apple.com/kb/TS4268
    http://support.apple.com/kb/ts3367

  • HT3529 Why cant i use imessage its stuck on waiting for activation

    Please help

    Turn imessage off and restart the phone (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for phone to restart (no data will be lost)).  Wait a few minutes after the phone restarts and turn imessage on again and see if it activates  Also read http://support.apple.com/kb/ts4268

  • Waiting for Authorization

    Hi, I am new to mac and know nothing about it. I just signed up for a jabber account and added my friends from my msn list. But they always shows "waiting for authoriztion". They didn't receive anything from me. How can I fix this? Thanks

    Ho Emily,
    Welcome to Apple Discussions
    You have posted in iChat 2.x with a question about iChat 3.
    No biggie.
    There are several people who post here regularly who offer themselves as iChat testers.
    One, Gil Taylor knows a bit more about the Jabber side than the rest of use.
    Contact him on iChat from this list in table 2
    http://www.ralphjohnsuk.dsl.pipex.com/ContactTesters.html
    As he does not get to these Discussions as often as some of us.
    Ralph

  • I lost my "update binary" link :( now only "Waiting for Upload"

    I have a update binary link eariler today when I checked at work. So I clicked on the link to see what the procedure is like. But of course I was not able to update my binary as I was at the office not at home. Later today, when I go back to itunesconnect, the link is gone! The app's status becomes "Waiting for Upload" and there's nothing I can do. Help!!

    i can also confirm this
    like you i had the same problem some weeks ago
    but although application loader seemed to process everything i could not get out of the waiting for upload state
    next day i received email saying there were issues with the bundle id
    the problem is that application loader does not give you the error messages you get when you upload thru itunes conect web interface
    as soon as i corrected the problem and reuploaded with AL my app went into in review state

  • IMessages ain't working on my phone :( says waiting for activation.. Really disappointed

    iMessages ain't working on my phone :( just says one thing over there that WAITING FOR ACTIVATION xx
    Need help to sort it out

    Turn off imessage. Restart the phone (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for phone to restart (no data will be lost). 
    Wait a few minutes and then turn imessage back on.

  • TS4268 underneath my imessages when i go to settings says " waiting for activation" how do i fix this

    underneath my imessages when i go to settings says " waiting for activation" how do i fix this

    ACTIVATING FACETIME AND IMESSAGES
    Activating Facetime and Imessages on your phone requires the ability to send SMS messages and depending upon where you are that might be an international SMS.  Check with your carrier to see if your plan supports sending of international SMS messages.  If you are having trouble activating Facetime or Imessages turn them both off on your device and reset the device (Hold down the Sleep/Wake button and the home button together until the apple logo appears (ignore the ON/OFF slider) then let both buttons go and wait for device to restart (no data will be lost)).  Wait for the device to restart and wait a minute and turn Facetime and imessage back on and wait for activation.  If that does not fix things read the following articles:
    http://support.apple.com/kb/TS4268
    http://support.apple.com/kb/ts3367

  • How to wait for a digital input to go high?

    I bet the following question is explained somewhere but I don't know how to find it.
    Is there an optimal way to wait for a digital input to transition from 0 to 1? I mean, other than creating a loop that continously polls the input line is there a better way to wait for the transition? With all the "event driven" capability of CVI I suspect there's a slick way to do this but I don't know how to find it. I'm willing to RTFM if I know where to look.
    thanks

    Hi,
    I have never done this, but it looks like it is possible to use the DAQmxRegisterSignalEvent function to assign a function that will be called when a "change detection event" occurs.
    It works on a task basis, so if I'm not mistaken, you need to put the digital to be tracked into a separate task. 
    It is not stated if all NI hardware is compatible with this functionality, so try and see if it works for you.
    Hope this helps,
    Edit: It looks like you have already found the solution by yourself
    S. Eren BALCI
    www.aselsan.com.tr

  • STREAMS apply coord waiting for slave message?

    1- Oracle version 9.2.0.1
    2-I have 3 database (bd1,bd2 in th same machine, bd3 in an other machine)
    3- I have configured streams in order to have bd1--->bd2 and bd1--->bd3 streams replication
    4- The streams between bd1--->bd2 is ok.
    5-The propagation between bd1--->bbd3 doesn't work.
    6- i have asked yhe view v$session_wait in :
    into bd1 :
    SID SEQ# EVENT
    15 1359 STREAMS apply coord waiting for slave message
    20 622 STREAMS apply slave waiting for coord message
    into bd3 :
    SID SEQ# EVENT
    17 11399 STREAMS apply coord waiting for slave message
    19 5698 STREAMS apply slave waiting for coord message
    What have i to do to fix it and my propagation will work.
    Thank you a lot dear memebers

    The events: STREAMS apply coord waiting for slave message" and "STREAMS apply slave waiting for coord message" are IDLE events - they indicate that the apply process is waiting for work.

  • Receivable Aging Report for India based on Invoice Date

    We have a reporting/legal need for our India location to report the aging of their receivables based on the invoice date of the documents rather than the net due date.  Is there an existing report available that already does this?
    Currently when you use FBL5N and related aging reports RFDOPO10 etc. it calculates the arrears from the net due date.  They need to calculate the arrears from the document date.

    The report S_ALR_87012168 still does not allow me to choose that I want to calculate the arrears from the document date rather than the net due date:
    I guess what they really need to know is how old the receivables are based on the date they were created.
    As in the example below, current aging reports use the Net Due to calculate a days in arrears of 6 days (based on current date of 2008/11/05).
    Ty Doc. Date  Pstng Date Bline Date Net due dt Arrea
    RV 2008.09.30 2008.09.30 2008.09.30 2008.10.30     6
    What they need is the number of days in arrears based on the document date (2008.09.30) which would increase the numer of days the receivable has been open to 36.

Maybe you are looking for

  • Preserve a single space at the end of line using spool command

    Hi, Can you please help me to write the result of an sql query into a file with the last column of the row ending with a single space? For example: COL1DATA|COL2DATA|COL3DATA<space1> As mentioned in the example the col3 value in the file should end w

  • Mac Mail can't resolve Office 365 address adding account

    I'm just putting this out there, I'm sure it will be addressed soon. Just loaded up a VM or Yosemite on my Macbook Pro so I can start testing it for our network environment.  First major glitch - Mac Mail will not resolve an Office 365 email address

  • Alternative to "javafx.io.Resource" and "javafx.io.Storage" in JavaFX 2.2?

    Silverlight has a sandboxed file storage location as well as a facility to store key/value pairs. It looks like JavaFX had some similar tools in 1.x, but they appear to be gone in 2.2. Can anyone point me toward an alternative for both services? Than

  • Problem in executing a procedure ?

    Hello , I have this procedure : CREATE OR REPLACE procedure FUNDINFO.clonestockpos2 is v_tab number; begin select count(*) into v_tab from tab where TNAME = 'STOCKPOS2_TEMP'; if v_tab > 0 then EXECUTE IMMEDIATE ' drop table STOCKPOS2_TEMP '; EXECUTE

  • Restore from Time Machine from a MacBook running 10.4

    Ok, So long story short. I cannot remember how I upgraded all my computers to 10.5. It was forever ago, but I had a problem with my Macbook and decided to reinstall with the original Macbook Install discs. Problem is, they were 10.4. So now all those