Thread: Terminate a data stream

  1. #1
    Registered User
    Join Date
    Dec 2012
    Posts
    37

    Terminate a data stream

    Hi everyone.

    I have a situation where i need to terminate a data stream after it has detected a long press (pressing a button for more than 1 second continuously without release).

    Breaking down the process, it should be something like this:

    Detect long press --> execute long press function --> terminate data --> wait until release (here, it basically doesnt do anything at all, but wait till its released and pressed again)

    Does anyone know how I can do this?

  2. #2
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    Is this on the PIC again?
    Fact - Beethoven wrote his first symphony in C

  3. #3
    Registered User
    Join Date
    Dec 2012
    Posts
    37
    Quote Originally Posted by Click_here View Post
    Is this on the PIC again?
    as a matter of fact, yes. its actually done. just wanted to make it perfect.

  4. #4
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    It would really depend on how you were sending the stream

    Are you sending it all at once, or one byte at a time?
    Fact - Beethoven wrote his first symphony in C

  5. #5
    Registered User
    Join Date
    Dec 2012
    Posts
    37
    Quote Originally Posted by Click_here View Post
    It would really depend on how you were sending the stream

    Are you sending it all at once, or one byte at a time?

    Im sending by byte. on the oscilloscope, it would appear as if its transmitted the whole 32 bits. I have an issue where if i continuously press the button, it keeps on turning ON and OFF continuously until I let it go. I need it to just turn ON, then turn OFF then wait till i release then detect the button all over again.

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    ASCII has some old values that were used to indicate the end of text, and another to indicate end of transmission, etc. Sounds like you could use those kind of sentinel values, in your data stream, to good effect.

  7. #7
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,907
    It sounds like you are not waiting for the user to let go of the button before doing anything else

    With states, you usually have a state after you have finished your processing to wait for the user to let go of the button

    Code:
    //Using switch based states...
    
      case wait_for_release:
        if (button == released)
        {
          state = first_state;
        }
        break;
    Fact - Beethoven wrote his first symphony in C

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiple process access to data stream
    By doia in forum C Programming
    Replies: 1
    Last Post: 04-14-2010, 01:01 PM
  2. Discard wrong data from stream
    By mesmer in forum C Programming
    Replies: 7
    Last Post: 11-16-2008, 02:30 AM
  3. Sockets: send/receive continuous stream of data?
    By diddy02 in forum Networking/Device Communication
    Replies: 1
    Last Post: 08-09-2008, 12:52 AM
  4. Determining if stdin stream holds data
    By Stack Overflow in forum C Programming
    Replies: 3
    Last Post: 01-28-2005, 02:52 PM
  5. pipe stream data I/O
    By vector7 in forum Linux Programming
    Replies: 1
    Last Post: 03-11-2003, 06:46 PM

Tags for this Thread