Main Menu
Counter
This page today ...
total: 0
unique: 0

This page ever ...
total: 215
unique: 146

Site ...
total: 3756
unique: 2056
Online
  • Guests: 2
  • Members: 0
  • Newest Member: ole
  • Most ever online: 47
    Guests: 47, Members: 0 on Wednesday 21 February 2018 - 23:52:15
Chatbox
You must be logged in to post comments on this site - please either log in from the Login box or from here.If you are not registered click here to signup.


bullet Kim
1 year ago
test
Royalsystems blog

MCS Electronics Forum

  • BASCOM-AVR : overlay - MWS : REPLY



    [quote:2a4c555e15]you suggest using waitkey rather than inkey but I don't understand the difference in this context [/quote:2a4c555e15]
    iskey first doest a check to see if any data is waiting. while waiting simply wait till data arrives. it uses less cycles/code when you know the data must be there since ischarwaiting is basically the same as inkey with the difference that it does not empty the buffer.

  • BASCOM-AVR : overlay - MWS : REPLY



    [code:1:5c0dcd311c] While Ischarwaiting(#3) <> 0
    rxbyte = waitkey(#3)
    Select Case A
    Case 10:
    Case 13:
    Case 32:
    Case "E":
    Case "M":
    Case Else:
    If Index < 251 Then
    bArray(Index) = rxbyte
    incr index
    End If
    End Select
    Wend
    bArray(index) = &H0[/code:1:5c0dcd311c]

  • BASCOM-AVR : overlay - MWS : REPLY



    [quote:b085bca43b="njepsen"]I am doing what you advised against - is this what you had in mind?[/quote:b085bca43b]
    Yes, this is leaner, as it uses a dedicated pointer to the next char, while the concat '+' always needs to seek the end of string first.
    [quote:b085bca43b]I know you hate people posting code that won't complile but this function is hardware dependent and is 8000 lines long.[/quote:b085bca43b]
    I don't need the book, if everything's available in a chapter. If code is easy to read and it doesn't need to be simulated, I'm fine with that.
    Some minor suggestions:
    [code:1:b085bca43b]' sTemp = "" <-- can be left out, if the following is applied
    '...
    ' bArray(index) = &H0 <-- saves also some cycles to move it from here
    Wend
    bArray(index) = &H0 ' <-- to there[/code:1:b085bca43b]

  • BASCOM-AVR : overlay - MWS : REPLY



    You are a happy men. You have plenty of time for your code cheesey
    I appreciate this cheesey

  • BASCOM-AVR : overlay - MWS : REPLY



    Why dont select them when they arrive? It it tudious job to search for the delchar function. I dont get it.
    Seriously?

  • BASCOM-AVR : overlay - MWS : REPLY



    Thanks for the comments chaps. This was an edited version of what i have running, and I do have a 2 sec timeout in the do loop in case nothing arrives, but you are correct - the LF does get added to the string and I remove it and spaces after the loop with delchars.
    Mark you suggest using waitkey rather than inkey but I don't understand the difference in this context - don't they effectively give the same result after the ischarwaiting?
    You make a good point if 'continuous' spurious data arrives and i had not though of that, but the timeout would exit after 2 secs.

    I have this running at present.[code:1:435e0f0b6d]
    '*************************************************************************************
    Function Getmeterresponse(byval metercommandstr As String) As String


    'meter response looks like E<space>57.9<cr><lf>
    'Note that return to SU0 is 155 bytes long.
    'note - if inner loop gets stuck, AIU watchdogs or times out.

    '
    #if isnoise=1
    Local Timedelay As Long
    local Index as byte
    Index = 1 'arrays are 1 based
    Tempstr2 = ""

    Clear Serialin 'clear ser buffer
    Print #3 , "" 'clear meter buffer
    Print #3 , metercommandstr ' CRLF is added automatically

    Timedelay = Local_secl + 2

    Do


    While Ischarwaiting(#3) <> 0
    rxbyte = inkey(#3)
    bArray(Index) = rxbyte 'save the byte overtop of the string
    incr index
    bArray(index) = &H0 'write new string terminator
    if rxbyte = 85 or rxbyte = 10 then exit do

    Wend

    Loop Until Local_secl >= Timedelay

    Delchars tempstr2 , 10 'LF
    Delchars tempstr2 , 13 'CR
    delchars tempstr2 , 32 'spaces
    delchars tempstr2 , "E" 'valid response
    delchars tempstr2 , "M" 'overload
    print #1,">> meter said ";tempstr2
    Getmeterresponse = Tempstr2
    #endif
    End Function

    [/code:1:435e0f0b6d]

  • BASCOM-AVR : overlay - MWS : REPLY



    you also need to check that you do not keep writing in case of spurious data arrives.
    and instead of inkey() use waitkey() since you already checked that there is data with ischarwaiting()

  • BASCOM-AVR : overlay - MWS : REPLY



    Maybe slightly more efficient cheesey

    [code:1:7d1ef55826]While Ischarwaiting(#3) <> 0
    rxbyte = inkey(3)
    bArray(Index) = rxbyte 'save the byte overtop of the string
    incr index
    Wend
    bArray(index) = &H0 'write new string terminator
    [/code:1:7d1ef55826]

  • BASCOM-AVR : overlay - MWS : REPLY



    I did this with the webserver code I created a 250 character string and overlaid the bytes as you have done,
    I needed to pull bytes from the wiznet chip , once the bytes were put into the overlay I could then
    use string functions to search the bytes (HTTP requests/posts). Note the MEGA1284p was good for this with its 16k of ram.
    Regards Paul

  • BASCOM-AVR : overlay - MWS : NEWTOPIC



    MWS,
    some time ago you commented in another post about the follies of building a string with string = String + newcharacter, for reasons that make really good sense, and you advised overlaying an array over the string.
    I am doing what you advised against - is this what you had in mind?
    I know you hate people posting code that won't complile but this function is hardware dependent and is 8000 lines long.

    [code:1:0369e31da6]Function Getmeterresponse(byval metercommandstr As String) As String

    dim sTemp as string * 250
    dim bArray(250) as byte at sTemp overlay 'overlay the array at the string address
    local Index as byte
    local rxbyte as byte
    Index = 0
    sTemp = ""
    Print #3 , "" 'clear meter buffer
    Print #3 , metercommandstr 'command to meter
    Do

    waitms 100 'allow meter time to respond
    While Ischarwaiting(#3) <> 0
    rxbyte = inkey(3)
    bArray(Index) = rxbyte 'save the byte overtop of the string
    bArray(index+1) = &H0 'write new string terminator
    incr index

    Wend

    Loop Until Rxbyte = 10 '10 = LF from Nor140
    Getmeterresponse = sTemp

    End Function
    [/code:1:0369e31da6]

    [b:0369e31da6][color=red:0369e31da6](BASCOM-AVR version : 2082 , Latest : 2.0.8.4 )[/b:0369e31da6][/color:0369e31da6]

| Date published: not known
Back to newsfeed list
Welcome
Username or Email:

Password:




[ ]
[ ]
Headlines

»BASCOM-AVR : overlay - MWS : REPLY
[quote:2a4c555e15]you suggest using waitkey rather than inkey but I don't understand the difference in this context [/quote:2a4c55...
»BASCOM-AVR : overlay - MWS : REPLY
[code:1:5c0dcd311c] While Ischarwaiting(#3) <> 0 rxbyte = waitkey(#3) Select Case A Ca...
»BASCOM-AVR : overlay - MWS : REPLY
[quote:b085bca43b="njepsen"]I am doing what you advised against - is this what you had in mind?[/quote:b085bca43b] Yes, this is l...
»BASCOM-AVR : overlay - MWS : REPLY
You are a happy men. You have plenty of time for your code :D I appreciate this :D
»BASCOM-AVR : overlay - MWS : REPLY
Why dont select them when they arrive? It it tudious job to search for the delchar function. I dont get it. Seriously? ...
»BASCOM-AVR : overlay - MWS : REPLY
Thanks for the comments chaps. This was an edited version of what i have running, and I do have a 2 sec timeout in the do loop in...
»BASCOM-AVR : overlay - MWS : REPLY
you also need to check that you do not keep writing in case of spurious data arrives. and instead of inkey() use waitkey() since ...
»BASCOM-AVR : overlay - MWS : REPLY
Maybe slightly more efficient :D [code:1:7d1ef55826]While Ischarwaiting(#3) <> 0 rxbyte = inkey(3) bArray(I...
»BASCOM-AVR : overlay - MWS : REPLY
I did this with the webserver code I created a 250 character string and overlaid the bytes as you have done, I needed to pull by...
»BASCOM-AVR : overlay - MWS : NEWTOPIC
MWS, some time ago you commented in another post about the follies of building a string with string = String + newch...


Date published: not known
Details

»GPS Uhr
Hier mal meine kleine Bastelei mit GPS(Uhr) und Max7219(4x8x8LED) Vielleicht kann ja jemand was brauchen
»Befehl Pulsein unklar
Hallo, ich habe mir mit einem ATTiny24 einen doppelten RC-Schalter gebaut (2 Kanäle als Eingang und 8 + 1 Schaltausgänge). Funktioniert soweit. Nur...
»Atmega328p Zeitintervall passt nicht
Gruß in die Runde. Meine Zeitintervalle passen einfach nicht und ich seh nicht woran das liegen könnte. Ich nutze den Atmega328p 28DIP, von Haus a...
»MCS Bootloader aus Beispiel mit ATMEGA644PA
Liebe Forumsmitglieder, ich versuche gerade meinem Bootloader um die Speicherlogic aus den Bascom-Beispielen zu erweitern. Ich benutzte einen ATME...
»rgb ws2812 2 Streifen an verschiedenen Ports in Tiny
Hallo Ich stehe mal wieder auf dem Schlauch... Ich habe einen RGB-STreifen mit den ws-2812 mit einem Ausgang an einem 4513 zum laufen bekommen. Nun...
»CO2 Sensor MH-Z19B auslesen klappt nicht
Hallo, ich versuche den Sensor auszulesen, aber es kommt einfach keine Rückmeldung. Die erste Zeile in der ISR habe ich nur temporär eingefügt, um...


Date published: Sun, 26 Sep 2021 06:23:44 +0000
Details

»93c46 editor programmer bascom &amp; vb93c46 editor programmer bascom &amp; vb
»93c46 Bascom &amp; VB693c46 Bascom &amp; VB6
»Analog clock on SSD1289 3.2" 240x320 lcdAnalog clock on SSD1289 3.2" 240x320 lcd
»Nextion HMI lcd with KaraDio the best webradio esp8266Nextion HMI lcd with KaraDio the best webradio esp8266
»Adding 240x320 lcd to the WifiWebRadioAdding 240x320 lcd to the WifiWebRadio
»IV-17 Nixie clock GPS set time &amp; date at power onIV-17 Nixie clock GPS set time &amp; date at power on


Date published: not known
Details

»Bascom Can Bus Sniffer
»R.I.P Ben Zijlstra
Remembering Ben Zijlstra We hope that people who love Ben will remember and celebrate his life. more info at MCS www.mcselec.com/index2.ph...
»KaRadio webradio ESP8266
The Dimitris board is available at https://github.com/dsaltas/WiFi-WebRadio  This is a hardware project for Ka-Radio
»93C46
small tool to edit 93C46 eeprom written in BascomAVR & VB  Bascom control the 93C46 so we sent data via comport from VB code will be added later ...
»nRF24L01+ RC Controller
This is a RC controller TX & RX unit with nRF24L01+ nRF24L01+ / with PA and LNA for longer range facts: TX 1 x potmeter for servo ...
»RAW lcd
Connecting RAW lcd to atmega8 the lcd is 6 digit + time glass LCD Hour Meter for  tractor ,air compressor, ect the lcd have 4 com pins  & 14...


Date published: not known
Details


Proudly powered by e107 which is released under the terms of the GNU GPL License.