Loading ...
Sorry, an error occurred while loading the content.

Input data containing carriage returns

Expand Messages
  • revffwplay
    Hi, I m trying to communicate to a electronics board using a USB interface. The board is supposed to send me a line with four pieces of data separated by some
    Message 1 of 8 , Feb 2, 2006
    • 0 Attachment
      Hi,

      I'm trying to communicate to a electronics board using a USB
      interface. The board is supposed to send me a line with four pieces
      of data separated by some carriage returns and an asterix between the
      data. The problem I'm having is to get all the data out in one
      string. I can get all the data out, character by character (not what
      I really want to do in the end) by using a for/next loop. Or, if I
      put a 0.5 second time loop in the for loop, I can get the first piece
      of data out in one string, but I don't get any of the other data. I
      was wondering if anyone had any suggestions.

      Thanks.
    • Arthur Yee
      Are you inputing the data via a file ? revffwplay wrote: Hi, I m trying to communicate to a electronics board using a USB interface.
      Message 2 of 8 , Feb 4, 2006
      • 0 Attachment
        Are you inputing the data via a file ?

        revffwplay <revffwplay@...> wrote: Hi,

        I'm trying to communicate to a electronics board using a USB
        interface. The board is supposed to send me a line with four pieces
        of data separated by some carriage returns and an asterix between the
        data. The problem I'm having is to get all the data out in one
        string. I can get all the data out, character by character (not what
        I really want to do in the end) by using a for/next loop. Or, if I
        put a 0.5 second time loop in the for loop, I can get the first piece
        of data out in one string, but I don't get any of the other data. I
        was wondering if anyone had any suggestions.

        Thanks.





        ---------------------------------
        YAHOO! GROUPS LINKS


        Visit your group "chipmunkbasicforum" on the web.

        To unsubscribe from this group, send an email to:
        chipmunkbasicforum-unsubscribe@yahoogroups.com

        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


        ---------------------------------





        ---------------------------------
        Brings words and photos together (easily) with
        PhotoMail - it's free and works with Yahoo! Mail.

        [Non-text portions of this message have been removed]
      • Daniel LeMay
        No, I have an electronics board that is sending back a signal that contains carriage returns and an asterix before each of the data in the signal. ...
        Message 3 of 8 , Feb 4, 2006
        • 0 Attachment
          No, I have an electronics board that is sending back a
          signal that contains carriage returns and an asterix
          before each of the data in the signal.

          --- Arthur Yee <yeefam48@...> wrote:

          > Are you inputing the data via a file ?
          >
          > revffwplay <revffwplay@...> wrote: Hi,
          >
          > I'm trying to communicate to a electronics board
          > using a USB
          > interface. The board is supposed to send me a line
          > with four pieces
          > of data separated by some carriage returns and an
          > asterix between the
          > data. The problem I'm having is to get all the
          > data out in one
          > string. I can get all the data out, character by
          > character (not what
          > I really want to do in the end) by using a for/next
          > loop. Or, if I
          > put a 0.5 second time loop in the for loop, I can
          > get the first piece
          > of data out in one string, but I don't get any of
          > the other data. I
          > was wondering if anyone had any suggestions.
          >
          > Thanks.
          >
          >
          >
          >
          >
          > ---------------------------------
          > YAHOO! GROUPS LINKS
          >
          >
          > Visit your group "chipmunkbasicforum" on the
          > web.
          >
          > To unsubscribe from this group, send an email
          > to:
          > chipmunkbasicforum-unsubscribe@yahoogroups.com
          >
          > Your use of Yahoo! Groups is subject to the
          > Yahoo! Terms of Service.
          >
          >
          > ---------------------------------
          >
          >
          >
          >
          >
          > ---------------------------------
          > Brings words and photos together (easily) with
          > PhotoMail - it's free and works with Yahoo! Mail.
          >
          > [Non-text portions of this message have been
          > removed]
          >
          >


          __________________________________________________
          Do You Yahoo!?
          Tired of spam? Yahoo! Mail has the best spam protection around
          http://mail.yahoo.com
        • revffwplay
          No, I have an electronics board that is sending back a signal when prompted. It also sends back carriage returns and an asterix along with each of the four
          Message 4 of 8 , Feb 4, 2006
          • 0 Attachment
            No, I have an electronics board that is sending back a signal when
            prompted. It also sends back carriage returns and an asterix along
            with each of the four pieces of data in the signal. I found I can use
            a for-loop to extract all the data in pieces, and then sum them up
            into a new string like so:

            110 for i = 1 to 80 : REM Enough loops to obtain all the data
            reproducibly
            150 input #2, b$
            161 for h = 1 to 1000000 : REM For loop is to account for needed time
            163 next h : REM delay to get all the data out.
            170 d$ = d$ + b$
            270 next i


            but I'm wondering if there's an easier, less processor-sensitive,
            more eligant, way to do this.


            --- In chipmunkbasicforum@yahoogroups.com, Arthur Yee <yeefam48@...>
            wrote:
            >
            > Are you inputing the data via a file ?
            >
            > revffwplay <revffwplay@...> wrote: Hi,
            >
            > I'm trying to communicate to a electronics board using a USB
            > interface. The board is supposed to send me a line with four pieces
            > of data separated by some carriage returns and an asterix between the
            > data. The problem I'm having is to get all the data out in one
            > string. I can get all the data out, character by character (not what
            > I really want to do in the end) by using a for/next loop. Or, if I
            > put a 0.5 second time loop in the for loop, I can get the first piece
            > of data out in one string, but I don't get any of the other data. I
            > was wondering if anyone had any suggestions.
            >
            > Thanks.
            >
            >
            >
            >
            >
            > ---------------------------------
            > YAHOO! GROUPS LINKS
            >
            >
            > Visit your group "chipmunkbasicforum" on the web.
            >
            > To unsubscribe from this group, send an email to:
            > chipmunkbasicforum-unsubscribe@yahoogroups.com
            >
            > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
            Service.
            >
            >
            > ---------------------------------
            >
            >
            >
            >
            >
            > ---------------------------------
            > Brings words and photos together (easily) with
            > PhotoMail - it's free and works with Yahoo! Mail.
            >
            > [Non-text portions of this message have been removed]
            >
          • Jeff Avery
            ... Your method certainly is not elegant but it does not seem to be processor-sensitive. If, perhaps, you really meant processor-intensive, the loop method of
            Message 5 of 8 , Feb 4, 2006
            • 0 Attachment
              --- In chipmunkbasicforum@yahoogroups.com, "revffwplay"
              <revffwplay@...> wrote:

              > but I'm wondering if there's an easier, less processor-sensitive,
              > more elegant, way to do this.

              Your method certainly is not elegant but it does not seem to be
              processor-sensitive. If, perhaps, you really meant
              processor-intensive, the loop method of generating a wait is the
              problem in that it uses 100% CPU.

              I use Chipmunk BASIC on a Macintosh and for generating a wait,
              Chipmunk offers the command:

              x = macfunction("wait", n) :' waits for n seconds

              This accomplishes the same wait but without the CPU usage. If this is
              useful to you, perhaps there is a similar command for your platform.

              ....Jeff
            • Arthur Yee
              My thoughts: Because each data is terminated by a carriage return, I think that would require a seperate input. My only thought is the delay, maybe another way
              Message 6 of 8 , Feb 5, 2006
              • 0 Attachment
                My thoughts:
                Because each data is terminated by a carriage return, I think that would require a seperate input.

                My only thought is the delay, maybe another way to determine when the next piece of data is ready?

                example:
                for i = 1 to 80
                loop until data-ready

                input #2, b$
                d$ = d$ + b$
                next i

                What do you get in b$ if the delay is not long enough?
                revffwplay <revffwplay@...> wrote: No, I have an electronics board that is sending back a signal when
                prompted. It also sends back carriage returns and an asterix along
                with each of the four pieces of data in the signal. I found I can use
                a for-loop to extract all the data in pieces, and then sum them up
                into a new string like so:

                110 for i = 1 to 80 : REM Enough loops to obtain all the data
                reproducibly
                150 input #2, b$
                161 for h = 1 to 1000000 : REM For loop is to account for needed time
                163 next h : REM delay to get all the data out.
                170 d$ = d$ + b$
                270 next i


                but I'm wondering if there's an easier, less processor-sensitive,
                more eligant, way to do this.


                --- In chipmunkbasicforum@yahoogroups.com, Arthur Yee <yeefam48@...>
                wrote:
                >
                > Are you inputing the data via a file ?
                >
                > revffwplay <revffwplay@...> wrote: Hi,
                >
                > I'm trying to communicate to a electronics board using a USB
                > interface. The board is supposed to send me a line with four pieces
                > of data separated by some carriage returns and an asterix between the
                > data. The problem I'm having is to get all the data out in one
                > string. I can get all the data out, character by character (not what
                > I really want to do in the end) by using a for/next loop. Or, if I
                > put a 0.5 second time loop in the for loop, I can get the first piece
                > of data out in one string, but I don't get any of the other data. I
                > was wondering if anyone had any suggestions.
                >
                > Thanks.
                >
                >
                >
                >
                >
                > ---------------------------------
                > YAHOO! GROUPS LINKS
                >
                >
                > Visit your group "chipmunkbasicforum" on the web.
                >
                > To unsubscribe from this group, send an email to:
                > chipmunkbasicforum-unsubscribe@yahoogroups.com
                >
                > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
                Service.
                >
                >
                > ---------------------------------
                >
                >
                >
                >
                >
                > ---------------------------------
                > Brings words and photos together (easily) with
                > PhotoMail - it's free and works with Yahoo! Mail.
                >
                > [Non-text portions of this message have been removed]
                >






                SPONSORED LINKS
                Basic programming language C programming language Computer programming languages The c programming language C programming language List of programming languages

                ---------------------------------
                YAHOO! GROUPS LINKS


                Visit your group "chipmunkbasicforum" on the web.

                To unsubscribe from this group, send an email to:
                chipmunkbasicforum-unsubscribe@yahoogroups.com

                Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


                ---------------------------------





                ---------------------------------
                Brings words and photos together (easily) with
                PhotoMail - it's free and works with Yahoo! Mail.

                [Non-text portions of this message have been removed]
              • revffwplay
                I ve tried using separate inputs like: macfunction( wait , 0.3) :REM Necessary intial delay input #2, b$, c$, d$, e$ but when I print them all: print b$, c$,
                Message 7 of 8 , Feb 7, 2006
                • 0 Attachment
                  I've tried using separate inputs like:

                  macfunction( "wait", 0.3) :REM Necessary intial delay
                  input #2, b$, c$, d$, e$

                  but when I print them all:

                  print b$, c$, d$, e$

                  I get:

                  ?? ?? ?? 0000.00

                  If I don't delay the input statement long enough, by data gets
                  truncated. Instead of "0000.00", I get "0000." or even less.


                  I figured out to use the asterix to determine the data is ready.
                  So, all I have to do is run the following few commands for times, with
                  different input strings:

                  110 while
                  120 input #2, b$
                  130 wend b$ = "*" :REM Data's ready.
                  140 macfunction( "wait", 0.3)
                  150 input #2, d$

                  Which is what I wanted. Thanks to everyone for helping.


                  --- In chipmunkbasicforum@yahoogroups.com, Arthur Yee <yeefam48@...>
                  wrote:
                  >
                  > My thoughts:
                  > Because each data is terminated by a carriage return, I think that
                  would require a seperate input.
                  >
                  > My only thought is the delay, maybe another way to determine when
                  the next piece of data is ready?
                  >
                  > example:
                  > for i = 1 to 80
                  > loop until data-ready
                  >
                  > input #2, b$
                  > d$ = d$ + b$
                  > next i
                  >
                  > What do you get in b$ if the delay is not long enough?
                  > revffwplay <revffwplay@...> wrote: No, I have an electronics
                  board that is sending back a signal when
                  > prompted. It also sends back carriage returns and an asterix along
                  > with each of the four pieces of data in the signal. I found I can use
                  > a for-loop to extract all the data in pieces, and then sum them up
                  > into a new string like so:
                  >
                  > 110 for i = 1 to 80 : REM Enough loops to obtain all the data
                  > reproducibly
                  > 150 input #2, b$
                  > 161 for h = 1 to 1000000 : REM For loop is to account for needed time
                  > 163 next h : REM delay to get all the data out.
                  > 170 d$ = d$ + b$
                  > 270 next i
                  >
                  >
                  > but I'm wondering if there's an easier, less processor-sensitive,
                  > more eligant, way to do this.
                  >
                  >
                  > --- In chipmunkbasicforum@yahoogroups.com, Arthur Yee <yeefam48@>
                  > wrote:
                  > >
                  > > Are you inputing the data via a file ?
                  > >
                  > > revffwplay <revffwplay@> wrote: Hi,
                  > >
                  > > I'm trying to communicate to a electronics board using a USB
                  > > interface. The board is supposed to send me a line with four pieces
                  > > of data separated by some carriage returns and an asterix
                  between the
                  > > data. The problem I'm having is to get all the data out in one
                  > > string. I can get all the data out, character by character (not
                  what
                  > > I really want to do in the end) by using a for/next loop. Or, if I
                  > > put a 0.5 second time loop in the for loop, I can get the first
                  piece
                  > > of data out in one string, but I don't get any of the other data. I
                  > > was wondering if anyone had any suggestions.
                  > >
                  > > Thanks.
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > ---------------------------------
                  > > YAHOO! GROUPS LINKS
                  > >
                  > >
                  > > Visit your group "chipmunkbasicforum" on the web.
                  > >
                  > > To unsubscribe from this group, send an email to:
                  > > chipmunkbasicforum-unsubscribe@yahoogroups.com
                  > >
                  > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
                  > Service.
                  > >
                  > >
                  > > ---------------------------------
                  > >
                  > >
                  > >
                  > >
                  > >
                  > > ---------------------------------
                  > > Brings words and photos together (easily) with
                  > > PhotoMail - it's free and works with Yahoo! Mail.
                  > >
                  > > [Non-text portions of this message have been removed]
                  > >
                  >
                  >
                  >
                  >
                  >
                  >
                  > SPONSORED LINKS
                  > Basic
                  programming language C
                  programming language Computer
                  programming languages
                  The c programming language
                  C programming language
                  List of programming languages

                  >
                  > ---------------------------------
                  > YAHOO! GROUPS LINKS
                  >
                  >
                  > Visit your group "chipmunkbasicforum" on the web.
                  >
                  > To unsubscribe from this group, send an email to:
                  > chipmunkbasicforum-unsubscribe@yahoogroups.com
                  >
                  > Your use of Yahoo! Groups is subject to the Yahoo! Terms of
                  Service.
                  >
                  >
                  > ---------------------------------
                  >
                  >
                  >
                  >
                  >
                  > ---------------------------------
                  > Brings words and photos together (easily) with
                  > PhotoMail - it's free and works with Yahoo! Mail.
                  >
                  > [Non-text portions of this message have been removed]
                  >
                • rhnlogic
                  The only reliable way to input string data from an async serial port is to poll for the starting and ending character and build the string manually. Delay
                  Message 8 of 8 , Feb 7, 2006
                  • 0 Attachment
                    The only reliable way to input string data from an async serial
                    port is to poll for the starting and ending character and build
                    the string manually. Delay loops or waits will not work reliably
                    in all situations. Try something like this:

                    x = fgetbyte(f)
                    while (x <> startcharcode)
                    rem throw away data byte x
                    x = fgetbyte(f)
                    wend
                    a$ = "" : rem start with empty string
                    x = fgetbyte(f)
                    while (x <> endingcharcode)
                    a$ = a$ + chr$(x)
                    x = fgetbyte(f)
                    wend

                    rem - you now have your input string a$
                    rem - you can use field$(a$, n) to obtain your 4 subfields

                    --- In chipmunkbasicforum@yahoogroups.com, "revffwplay"
                    <revffwplay@...> wrote:
                    > I'm trying to communicate to a electronics board using a USB
                    > interface. The board is supposed to send me a line with four pieces
                    > of data separated by some carriage returns and an asterix between the
                    > data. The problem I'm having is to get all the data out in one
                    > string. I can get all the data out, character by character (not what
                    > I really want to do in the end) by using a for/next loop. Or, if I
                    > put a 0.5 second time loop in the for loop, I can get the first piece
                    > of data out in one string, but I don't get any of the other data. I
                    > was wondering if anyone had any suggestions.
                  Your message has been successfully submitted and would be delivered to recipients shortly.