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

Re: [libertybasic] Re: non continuable protection violation ??

Expand Messages
  • laurie camion
    I made a lot of progress, but I m sure you can tell me how to improve it:   open com1:4800, n,8,1,ds0, cs0,rs for random as #comm [starthere] timer
    Message 1 of 28 , Aug 8, 2008
    • 0 Attachment
      I made a lot of progress, but I'm sure you can tell me how to improve it:
       
      open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
      [starthere]
      timer 100,[syncup]
      wait

      'loop looking for LF
      [syncup]
      t$ = input$(#comm, 1) 'Get com port data
      'start collecting data when LF detected
      if t$ = chr$(10) then [datastart]
      wait
       
      'collect the data
      [datastart]
      dd$ = ""
      timer 100,[getdata]
      wait
      [getdata]
      t$ = input$(#comm, 1) 'Get com port data
      'print data when CR detected
      if t$ = chr$(13) then [printit]
      dd$ = dd$ + t$
      wait
       
      'print the complete dataset
      [printit]
      t$ = time$()
      d$ = date$("mm/dd/yyyy")
      print mid$(d$,4,2);"/";left$(d$,2);right$(d$,5);",";left$(t$,5);",";dd$
      goto [starthere]


      --- On Thu, 8/7/08, rod_bird001 <rodbird@...> wrote:

      From: rod_bird001 <rodbird@...>
      Subject: [libertybasic] Re: non continuable protection violation ??
      To: libertybasic@yahoogroups.com
      Date: Thursday, August 7, 2008, 2:29 PM






      --- In libertybasic@ yahoogroups. com, laurie camion <lauriecam2006@ ...>
      wrote:
      >
      > Hmmm, my little compiled LB serial program works great on XP but
      gives a "non continuable protection violation" error on Server 2003 :-(

      I'm tired, it's late I think you have been asked to post your code
      about twenty times. I can describe how long a piece of string is but it
      gets boring. Post an example of your message and the code you are
      trying to use to capture it.


















      [Non-text portions of this message have been removed]
    • zoomkat
      You probably should reset the timer back to 0 each time you use it, otherwise it runs in the background and will fire every 100ms even if you are in the middle
      Message 2 of 28 , Aug 8, 2008
      • 0 Attachment
        You probably should reset the timer back to 0 each time you use it,
        otherwise it runs in the background and will fire every 100ms even if
        you are in the middle of collecting a string of data from the serial
        port.

        --- In libertybasic@yahoogroups.com, laurie camion
        <lauriecam2006@...> wrote:
        >
        > I made a lot of progress, but I'm sure you can tell me how to
        improve it:
        >  
        > open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
        > [starthere]
        > timer 100,[syncup]
        > wait
        >
        > 'loop looking for LF
        > [syncup]
        > t$ = input$(#comm, 1) 'Get com port data
        > 'start collecting data when LF detected
        > if t$ = chr$(10) then [datastart]
        > wait
        >  
        > 'collect the data
        > [datastart]
        > dd$ = ""
        > timer 100,[getdata]
        > wait
        > [getdata]
        > t$ = input$(#comm, 1) 'Get com port data
        > 'print data when CR detected
        > if t$ = chr$(13) then [printit]
        > dd$ = dd$ + t$
        > wait
        >  
        > 'print the complete dataset
        > [printit]
        > t$ = time$()
        > d$ = date$("mm/dd/yyyy")
        > print
        mid$(d$,4,2);"/";left$(d$,2);right$(d$,5);",";left$(t$,5);",";dd$
        > goto [starthere]
        >
        >
        > --- On Thu, 8/7/08, rod_bird001 <rodbird@...> wrote:
        >
        > From: rod_bird001 <rodbird@...>
        > Subject: [libertybasic] Re: non continuable protection violation ??
        > To: libertybasic@yahoogroups.com
        > Date: Thursday, August 7, 2008, 2:29 PM
        >
        >
        >
        >
        >
        >
        > --- In libertybasic@ yahoogroups. com, laurie camion
        <lauriecam2006@ ...>
        > wrote:
        > >
        > > Hmmm, my little compiled LB serial program works great on XP but
        > gives a "non continuable protection violation" error on Server
        2003 :-(
        >
        > I'm tired, it's late I think you have been asked to post your code
        > about twenty times. I can describe how long a piece of string is
        but it
        > gets boring. Post an example of your message and the code you are
        > trying to use to capture it.
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        >
        > [Non-text portions of this message have been removed]
        >
      • laurie camion
        Thanks for the tip. I am somewhat confused about the timer, I ll work on it. I tried using the pause code in the help instead but that burns CPU. ... From:
        Message 3 of 28 , Aug 8, 2008
        • 0 Attachment
          Thanks for the tip. I am somewhat confused about the timer, I'll work on it. I tried using the pause code in the help instead but that burns CPU.

          --- On Fri, 8/8/08, zoomkat <Zoomkat@...> wrote:

          From: zoomkat <Zoomkat@...>
          Subject: [libertybasic] Re: non continuable protection violation ??
          To: libertybasic@yahoogroups.com
          Date: Friday, August 8, 2008, 11:22 AM






          You probably should reset the timer back to 0 each time you use it,
          otherwise it runs in the background and will fire every 100ms even if
          you are in the middle of collecting a string of data from the serial
          port.

          --- In libertybasic@ yahoogroups. com, laurie camion
          <lauriecam2006@ ...> wrote:
          >
          > I made a lot of progress, but I'm sure you can tell me how to
          improve it:
          >  
          > open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
          > [starthere]
          > timer 100,[syncup]
          > wait
          >
          > 'loop looking for LF
          > [syncup]
          > t$ = input$(#comm, 1) 'Get com port data
          > 'start collecting data when LF detected
          > if t$ = chr$(10) then [datastart]
          > wait
          >  
          > 'collect the data
          > [datastart]
          > dd$ = ""
          > timer 100,[getdata]
          > wait
          > [getdata]
          > t$ = input$(#comm, 1) 'Get com port data
          > 'print data when CR detected
          > if t$ = chr$(13) then [printit]
          > dd$ = dd$ + t$
          > wait
          >  
          > 'print the complete dataset
          > [printit]
          > t$ = time$()
          > d$ = date$("mm/dd/ yyyy")
          > print
          mid$(d$,4,2) ;"/";left$ (d$,2);right$ (d$,5);", ";left$(t$ ,5);",";dd$
          > goto [starthere]
          >
          >
          > --- On Thu, 8/7/08, rod_bird001 <rodbird@... > wrote:
          >
          > From: rod_bird001 <rodbird@... >
          > Subject: [libertybasic] Re: non continuable protection violation ??
          > To: libertybasic@ yahoogroups. com
          > Date: Thursday, August 7, 2008, 2:29 PM
          >
          >
          >
          >
          >
          >
          > --- In libertybasic@ yahoogroups. com, laurie camion
          <lauriecam2006@ ...>
          > wrote:
          > >
          > > Hmmm, my little compiled LB serial program works great on XP but
          > gives a "non continuable protection violation" error on Server
          2003 :-(
          >
          > I'm tired, it's late I think you have been asked to post your code
          > about twenty times. I can describe how long a piece of string is
          but it
          > gets boring. Post an example of your message and the code you are
          > trying to use to capture it.
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >


















          [Non-text portions of this message have been removed]
        • rod_bird001
          Two approaches, one checks very 100ms the other more lazily checks every second. In both cases you will need to think about how you stop or leave the process.
          Message 4 of 28 , Aug 10, 2008
          • 0 Attachment
            Two approaches, one checks very 100ms the other more lazily checks
            every second. In both cases you will need to think about how you stop
            or leave the process. When you do remember to switch the timer off. I
            suspect that was all that was wrong with your first code though you
            were reading the buffer even if it was empty.

            open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
            [starthere]
            timer 100,[syncup]
            wait

            'loop looking for LF
            [syncup]
            if lof(#comm)>0 then t$ = input$(#comm, 1) 'Get com port data
            'start collecting data when LF detected
            if t$ = chr$(10) then [datastart]
            wait

            'collect the data
            [datastart]
            dd$ = ""
            timer 100,[getdata]
            wait
            [getdata]
            if lof(#comm)>0 then t$ = input$(#comm, 1) 'Get com port data
            'print data when CR detected
            if t$ = chr$(13) then [printit]
            dd$ = dd$ + t$
            wait

            'print the complete dataset
            [printit]
            timer 0
            t$ = time$()
            d$ = date$("mm/dd/yyyy")
            print
            mid$(d$,4,2);"/";left$(d$,2);right$(d$,5);",";left$(t$,5);",";dd$
            'start the syncup timer again
            timer 100,[syncup]
            wait








            open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
            delimit$=chr$(10)+chr$(13)
            [starthere]
            timer 1000,[getbuffercontents]
            wait

            'if there is something in the buffer add it to temp$
            [getbuffercontents]
            if lof(#comm)>0 then
            temp$=temp$+input$(#comm, lof(#comm))
            end if

            'now parse the temp$ string and split it if lfcr found
            [parseit]
            delimitpos=instr(temp$,delimit$,0)
            if delimitpos>0 then
            dd$=left$(temp$,delimitpos)
            temp$=right$(temp$,len(temp$)-delimitpos)

            'print the complete message
            [printit]
            t$ = time$()
            d$ = date$("mm/dd/yyyy")
            print
            mid$(d$,4,2);"/";left$(d$,2);right$(d$,5);",";left$(t$,5);",";dd$
            end if

            'now sit and wait for the next timer call to [getbuffercontents]
            wait
          • laurie camion
            Great, thanks for that, very helpful. Mine did actually work but I can see how your changes clean up/improve it :)   The second version would need some extra
            Message 5 of 28 , Aug 10, 2008
            • 0 Attachment
              Great, thanks for that, very helpful. Mine did actually work but I can see how your changes clean up/improve it :)
               
              The second version would need some extra work. There's no sync between the unit and the PC so it's possible to open the port in the middle of a data record, or get multiple records in the buffer. I tried something like that initially but went with the single character read instead.
               
              Cool. Onward to a simple gui now...

              --- On Sun, 8/10/08, rod_bird001 <rodbird@...> wrote:

              From: rod_bird001 <rodbird@...>
              Subject: [libertybasic] Re: non continuable protection violation ??
              To: libertybasic@yahoogroups.com
              Date: Sunday, August 10, 2008, 9:29 AM






              Two approaches, one checks very 100ms the other more lazily checks
              every second. In both cases you will need to think about how you stop
              or leave the process. When you do remember to switch the timer off. I
              suspect that was all that was wrong with your first code though you
              were reading the buffer even if it was empty.

              open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
              [starthere]
              timer 100,[syncup]
              wait

              'loop looking for LF
              [syncup]
              if lof(#comm)>0 then t$ = input$(#comm, 1) 'Get com port data
              'start collecting data when LF detected
              if t$ = chr$(10) then [datastart]
              wait

              'collect the data
              [datastart]
              dd$ = ""
              timer 100,[getdata]
              wait
              [getdata]
              if lof(#comm)>0 then t$ = input$(#comm, 1) 'Get com port data
              'print data when CR detected
              if t$ = chr$(13) then [printit]
              dd$ = dd$ + t$
              wait

              'print the complete dataset
              [printit]
              timer 0
              t$ = time$()
              d$ = date$("mm/dd/ yyyy")
              print
              mid$(d$,4,2) ;"/";left$ (d$,2);right$ (d$,5);", ";left$(t$ ,5);",";dd$
              'start the syncup timer again
              timer 100,[syncup]
              wait

              open "com1:4800, n,8,1,ds0, cs0,rs" for random as #comm
              delimit$=chr$ (10)+chr$ (13)
              [starthere]
              timer 1000,[getbuffercont ents]
              wait

              'if there is something in the buffer add it to temp$
              [getbuffercontents]
              if lof(#comm)>0 then
              temp$=temp$+ input$(#comm, lof(#comm))
              end if

              'now parse the temp$ string and split it if lfcr found
              [parseit]
              delimitpos=instr( temp$,delimit$ ,0)
              if delimitpos>0 then
              dd$=left$(temp$ ,delimitpos)
              temp$=right$ (temp$,len( temp$)-delimitpo s)

              'print the complete message
              [printit]
              t$ = time$()
              d$ = date$("mm/dd/ yyyy")
              print
              mid$(d$,4,2) ;"/";left$ (d$,2);right$ (d$,5);", ";left$(t$ ,5);",";dd$
              end if

              'now sit and wait for the next timer call to [getbuffercontents]
              wait


















              [Non-text portions of this message have been removed]
            • Ron Spruell
              Gordon, are you getting double posts? I have been and I think I asked one time if anyone else was but don t remember if I got a reply. Don t think I did but I
              Message 6 of 28 , Aug 10, 2008
              • 0 Attachment
                Gordon, are you getting double posts? I have been and I think I asked one
                time if anyone else was but don't remember if I got a reply. Don't think I
                did but I am subscribed to two different Liberty Basic forums so if they
                were combined, that's the problem. Just wondering because I try and save
                really good tips and I have to weed thru to delete the double post. Would be
                easier if I could get the double postings stopped.<BG>



                Ron Spruell Sr.



                From: libertybasic@yahoogroups.com [mailto:libertybasic@yahoogroups.com] On
                Behalf Of Gordon Sweet
                Sent: Wednesday, August 06, 2008 8:19 AM
                To: libertybasic@yahoogroups.com
                Subject: [libertybasic] Re: Serial Comm Examples



                Rod

                I have always wanted to send a file this way rather than a simple ASCII file
                or text from the keyboard.

                Gordon S.

                [Non-text portions of this message have been removed]





                [Non-text portions of this message have been removed]
              • Stefan Pendl
                ... You can use TXCOUNT(#ComPort) to receive the number of bytes in the buffer, if the buffer is empty, wait for a second and check again. You need to read the
                Message 7 of 28 , Aug 13, 2008
                • 0 Attachment
                  >
                  > OK, progress, modifying Rod's code below I can see the data :)
                  >  
                  > Next question. The device is sending a delimited, variable
                  > length, string terminated with a CRLF, at intervals of a few
                  > seconds to a few minutes. Can I get some suggestions of the
                  > best way to grab or accumulate whole data strings?
                  >  

                  You can use TXCOUNT(#ComPort) to receive the number of bytes in the buffer, if the buffer is empty, wait for a second and check
                  again.
                  You need to read the buffer and append the content to a variable until CRLF [chr$(13)+chr$(10)] is encountered.

                  '---code start (watch for line wraps)
                  CRLF$ = chr$(13) + chr$(10)

                  open "COM1:..." for random as #comport

                  [CheckBuffer]
                  timer 0

                  if txcount(#comport) > 0 then
                  content$ = content$ + input$(#comport, lof(#comport))

                  if instr(content$, CRLF$) > 0 then
                  'get data stream till first CRLF
                  datastream$ = word$(content$, 1, CRLF$)

                  'save remaining data to be processed the next time
                  content$ = mid$(content$, instr(content$, CRLF$) + len(CRLF$))

                  'process the data
                  end if
                  end if

                  timer 1000, [CheckBuffer]
                  wait
                  '---code end

                  ---
                  Stefan Pendl
                • Stefan Pendl
                  ... See the following demo for getting the current memory usage of the current process. For an explanation read the links include in the demo. ---code start
                  Message 8 of 28 , Aug 13, 2008
                  • 0 Attachment
                    >
                    > I know that LB has a limit of about 70 meg total RAM to
                    > allocate between
                    > program code and variables.
                    >
                    > Is there an API call or DLL invocation that will indicate either how
                    > much RAM is still available, or how much has been consumed?
                    >

                    See the following demo for getting the current memory usage of the current process.
                    For an explanation read the links include in the demo.

                    '---code start (watch for line wraps)
                    'get process memory size
                    '
                    'http://msdn.microsoft.com/en-us/library/ms684895(VS.85).aspx
                    'http://msdn.microsoft.com/en-us/library/ms683219(VS.85).aspx
                    'http://msdn.microsoft.com/en-us/library/ms684877(VS.85).aspx
                    'http://msdn.microsoft.com/en-us/library/ms683179(VS.85).aspx

                    struct ProcessMemoryCounters, _
                    cb as ulong,_
                    PageFaultCount as ulong,_
                    PeakWorkingSetSize as ulong,_
                    WorkingSetSize as ulong,_
                    QuotaPeakPagedPoolUsage as ulong,_
                    QuotaPagedPoolUsage as ulong,_
                    QuotaPeakNonPagedPoolUsage as ulong,_
                    QuotaNonPagedPoolUsage as ulong,_
                    PagefileUsage as ulong,_
                    PeakPagefileUsage as ulong

                    ProcessMemoryCounters.cb.struct = len(ProcessMemoryCounters.struct)

                    open "psapi.dll" for dll as #psapi

                    calldll #kernel32, "GetCurrentProcess",_
                    hProcess as ulong

                    cb = len(ProcessMemoryCounters.struct)

                    calldll #psapi, "GetProcessMemoryInfo",_
                    hProcess as ulong,_
                    ProcessMemoryCounters as struct,_
                    cb as ulong,_
                    result as long

                    if result then
                    print "PageFaultCount ............... "; _
                    using("###########", ProcessMemoryCounters.PageFaultCount.struct)
                    print "PeakWorkingSetSize ........... "; _
                    using("###########", ProcessMemoryCounters.PeakWorkingSetSize.struct); " bytes"
                    print "WorkingSetSize ............... "; _
                    using("###########", ProcessMemoryCounters.WorkingSetSize.struct); " bytes"
                    print "QuotaPeakPagedPoolUsage ...... "; _
                    using("###########", ProcessMemoryCounters.QuotaPeakPagedPoolUsage.struct); " bytes"
                    print "QuotaPagedPoolUsage .......... "; _
                    using("###########", ProcessMemoryCounters.QuotaPagedPoolUsage.struct); " bytes"
                    print "QuotaPeakNonPagedPoolUsage ... "; _
                    using("###########", ProcessMemoryCounters.QuotaPeakNonPagedPoolUsage.struct); " bytes"
                    print "QuotaNonPagedPoolUsage ....... "; _
                    using("###########", ProcessMemoryCounters.QuotaNonPagedPoolUsage.struct); " bytes"
                    print "PagefileUsage ................ "; _
                    using("###########", ProcessMemoryCounters.PagefileUsage.struct); " bytes"
                    print "PeakPagefileUsage ............ "; _
                    using("###########", ProcessMemoryCounters.PeakPagefileUsage.struct); " bytes"
                    else
                    call DisplayError
                    end if

                    close #psapi
                    end

                    sub DisplayError
                    calldll #kernel32, "GetLastError", _
                    ErrorCode as ulong

                    dwFlags = _FORMAT_MESSAGE_FROM_SYSTEM
                    nSize = 1024
                    lpBuffer$ = space$(nSize); chr$(0)
                    dwMessageID = ErrorCode

                    calldll #kernel32, "FormatMessageA", _
                    dwFlags as ulong, _
                    lpSource as ulong, _
                    dwMessageID as ulong, _
                    dwLanguageID as ulong, _
                    lpBuffer$ as ptr, _
                    nSize as ulong, _
                    Arguments as ulong, _
                    result as ulong

                    print "Error "; ErrorCode; ": "; left$(lpBuffer$, result)
                    end sub
                    '---code end

                    ---
                    Stefan Pendl
                  • Richard Russell
                    ... I thought TXCOUNT was about transmitting, not receiving. Are you sure you didn t mean LOF(#ComPort) ? Richard.
                    Message 9 of 28 , Aug 13, 2008
                    • 0 Attachment
                      --- In libertybasic@yahoogroups.com, "Stefan Pendl" wrote:
                      > You can use TXCOUNT(#ComPort) to receive the number of bytes in
                      > the buffer

                      I thought TXCOUNT was about transmitting, not receiving. Are you sure
                      you didn't mean LOF(#ComPort) ?

                      Richard.
                    • Stefan Pendl
                      ... Seems vacation washed away my last brain cells :-( Sure TXCOUNT() returns the number of bytes in the transmit queue. LOF() is the one that is needed. ...
                      Message 10 of 28 , Aug 13, 2008
                      • 0 Attachment
                        >
                        > --- In libertybasic@yahoogroups.com, "Stefan Pendl" wrote:
                        > > You can use TXCOUNT(#ComPort) to receive the number of bytes in
                        > > the buffer
                        >
                        > I thought TXCOUNT was about transmitting, not receiving. Are
                        > you sure you didn't mean LOF(#ComPort) ?
                        >

                        Seems vacation washed away my last brain cells :-(

                        Sure TXCOUNT() returns the number of bytes in the transmit queue.

                        LOF() is the one that is needed.

                        ---
                        Stefan Pendl
                      • rod_bird001
                        I m just amazed at how you pull these little gems out of the hat Stefan. Excellent.
                        Message 11 of 28 , Aug 13, 2008
                        • 0 Attachment
                          I'm just amazed at how you pull these little gems out of the hat
                          Stefan. Excellent.
                        • David Speck
                          Excellent, Stephan, Thank you very much. Just what I needed! Dave
                          Message 12 of 28 , Aug 13, 2008
                          • 0 Attachment
                            Excellent, Stephan,

                            Thank you very much. Just what I needed!

                            Dave

                            > See the following demo for getting the current memory usage of the current process.
                            > For an explanation read the links include in the demo.
                            >
                            >
                          • Stefan Pendl
                            ... It was more out of MSDN Library ;-) I knew that you can check the memory usage of a process, I just had to check MSDN Library for the API functions,
                            Message 13 of 28 , Aug 14, 2008
                            • 0 Attachment
                              >
                              > I'm just amazed at how you pull these little gems out of the hat
                              > Stefan. Excellent.
                              >

                              It was more "out of MSDN Library" ;-)

                              I knew that you can check the memory usage of a process, I just had to check MSDN Library for the API functions, that's all.

                              ---
                              Stefan Pendl
                            Your message has been successfully submitted and would be delivered to recipients shortly.