Variable Table Append

118 views
Skip to first unread message

flyway38

unread,
Dec 2, 2022, 4:42:34 AM12/2/22
to jallib
Hello all,

Have searched for it but haven't found anything useful.
Need to know a good way of appending a variable table.
Starting from a MyVar[] = "", then just append data to it...
Also what happen to website: https://justanotherlanguage.org/ ?
Cannot connect to that website.
Thank you very much.

Kind regards,
Filipe Santos.

flyway38

unread,
Dec 2, 2022, 6:38:28 AM12/2/22
to jallib
Am trying to mimic a "Read_String" from serial port.
Any ideas?

Thank you.

Regards,
FS

Rob CJ

unread,
Dec 2, 2022, 1:06:56 PM12/2/22
to jal...@googlegroups.com
Hi Filipe,

You just read the data from a serial port, add that to your local variable buffer, increment an index pointer with each received character and read until you receive either a Carriage Return or a Line Feed (one of the will do). I normally also add a timeout to the read function so that it does not hang when nothing is received.

Kind regards,

rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens flyway38 <fsfo...@gmail.com>
Verzonden: vrijdag 2 december 2022 12:38
Aan: jallib <jal...@googlegroups.com>
Onderwerp: [jallib] Re: Variable Table Append
 
--
You received this message because you are subscribed to the Google Groups "jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallib+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/2251b524-7658-42f7-970b-a6817d6709e1n%40googlegroups.com.

flyway38

unread,
Dec 2, 2022, 1:23:09 PM12/2/22
to jallib
Hi Rob,

Thanks for your input.
Could you post some sample code please?
I think am missing some important details...
How can I define a variable buffer?
Because this seems not work: var byte received[]=""...

Am also struggling to read my modems relies to AT commands...
It seems my code is working correctly and after sending the AT command, the readings from serial port seems to point to characters from the sent command...
Getting crazy here while in battle with the code... :D
Thank you very much.

Best regards,
Filipe Santos

Rob CJ

unread,
Dec 2, 2022, 2:20:19 PM12/2/22
to jal...@googlegroups.com
Hi Filipe,

Some sample code. I did not test it (or compiled it) but I assume you get the idea.

const word MAX_TIMEOUT = 20_000
const byte MAX_BUFFER = 20
const byte CR = 0x0D
const byte LF = 0x0A

var word timer = 0
var byte my_buffer[MAX_BUFFER]
var byte index = 0
var byte character = 0

-- Read a string.
repeat
    if serial_hw_data_available() then
       character = serial_hw_data
       my_buffer[index] = character
       index = index + 1
   end if 
    timer = timer + 1
    _usec_delay(100)
until (index == MAX_BUFFER) | (character == CR) | (character == LF) | (timer == MAX_TIMEOUT)

The string is then in my_buffer (including a CR or LF). 

Kind regards,

Rob



Verzonden: vrijdag 2 december 2022 19:23
Aan: jallib <jal...@googlegroups.com>
Onderwerp: Re: [jallib] Re: Variable Table Append
 

Rob CJ

unread,
Dec 2, 2022, 2:21:46 PM12/2/22
to jal...@googlegroups.com
Hi Filipe,

One correction. if you get a timeout then there is no string (or only a partial string) so you have to check if the timer has reached the timeout after the repeat.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Rob CJ <rob...@hotmail.com>
Verzonden: vrijdag 2 december 2022 20:20
Aan: jal...@googlegroups.com <jal...@googlegroups.com>

flyway38

unread,
Dec 2, 2022, 2:25:03 PM12/2/22
to jallib
Hello Rob,

Thank you very much.
This will help alot.
Cheers.

FS

vsurducan

unread,
Dec 3, 2022, 1:18:47 AM12/3/22
to jal...@googlegroups.com
Fellipe, I'm curious if this will work fo you. I was never able to use the serial library (interrupts) as is without a slip of one char in received characters order.  I've counted chars to solvethe problem....
Depending on your GSM transciever, some delays may be needed between chars and some longer delays between AT commands and chars.

flyway38

unread,
Dec 3, 2022, 4:53:36 AM12/3/22
to jallib
Hello Vasile,

Am not using serial lib with interrupts.
Maybe I need to use that lib.
Current problem is GSM modem seems to acknowledge (ex: "OK") faster than my code can read it...
A simple "AT" seems to get the "OK" faster than I can read.
And I want to get all acknowledges... to not step to next AT command before having sure of "OK" response from the modem.
All my AT commands to send an SMS are working ok, if no checking for the acknowledges...
Big battle here under going. :D
Thank you for your input.

Cheers,
FS

vsurducan

unread,
Dec 3, 2022, 5:05:25 AM12/3/22
to jal...@googlegroups.com
Oh, understood. Reading needs to have priority. Use interrupts then...or avoid using any delays in your actual code.
A sms has not an instant execution ( most of the time). So using low speed transmission/reception it might be a working solution.

Rob CJ

unread,
Dec 3, 2022, 8:43:23 AM12/3/22
to jal...@googlegroups.com
Hi Filipe, Vasile,

I would recommend using the serial libraries that work on an interrupt basis like serial_hw_int_cts.jal. Using this library with a big enough buffer will prevent that you miss any characters.

I used this - using AT commands - in the libraries bluetooth_hc05.jal and bluetooth_hc06.jal as to be able to check if an OK was received after an AT command.

Kind regards,

Rob




Van: jal...@googlegroups.com <jal...@googlegroups.com> namens vsurducan <vsur...@gmail.com>
Verzonden: zaterdag 3 december 2022 11:09

flyway38

unread,
Dec 3, 2022, 9:12:00 AM12/3/22
to jallib
Hi Rob,

Thank you for that info.
The OK answer from the modem, am already getting, but using "like brute force" serial readings...

function CheckComms_OK() return bit is
   timer = 0
   Received[0] = "X"
   Received[1] = "X"
   --
   while (Received[0]!="O" | Received[1]!="K") & timer < 60_000 loop
      fReturn = serial_hw_read(char)
      Received[0] = char
      fReturn = serial_hw_read(char)
      Received[1] = char
      --

      timer = timer + 1
   end loop
   --
   fReturn = FALSE
   --
   if (Received[0]=="O" & Received[1]=="K") then
      return TRUE
   else
      return FALSE
   end if
end function

But other answers from the modem are still a no go.
Example: "+CMGS" from an AT+CMGS="phone nr"....
Will need this because will need to also receive SMS with this PIC.

Will check that LIB you mentioned.
Thank you.

Cheers,
FS

Rob CJ

unread,
Dec 3, 2022, 9:22:04 AM12/3/22
to jal...@googlegroups.com
Hi Filipe,

In the bluetooth_hc_05.jal library I made a function that reads a string including OK but returns only the string (without the OK). The code is as follows:

-- Wait for data from the module and copy all data to the bluetooth receive
-- buffer until 'OK' is found. If 'OK' is found the function returns TRUE.
-- The number of bytes in the receive buffer is stored in the global variable
-- bluetooth_hc05_bytes_received and the read pointer is reset.
-- Note that 'OK' is not stored in bluetooth_hc05_bytes_received but the
-- carriage return and line feed are.
function _bluetooth_hc05_wait_and_get_data_ok() return bit is

   var dword timeout = 0
   var byte index = 0
   var byte character
   var bit found_o  = FALSE
   var bit found_ok = FALSE
   
   bluetooth_hc05_bytes_received = 0
   _bluetooth_hc05_read_pointer = 0
   while (index < BLUETOOTH_HC05_RECEIVE_BUFFER_SIZE) & !found_ok &
         (timeout < _bluetooth_hc05_wait_time) loop

      if _bluetooth_hc05_serial_read(character) then
         bluetooth_hc05_receive_buffer[index] = character
         index = index + 1
         timeout = 0
         if (character == "O") then
            found_o = TRUE
         elsif (character == "K") & found_o then
            found_ok = TRUE
            -- Bytes received is everything except for 'OK'.
            bluetooth_hc05_bytes_received = index - 2
        else
            -- It was not 'OK', reset.
            found_o  = FALSE
            found_ok = FALSE
         end if
      end if

      timeout = timeout + 1
      _usec_delay(100)
   end loop

   return found_ok

end function

Kind regards,

Rob

Verzonden: zaterdag 3 december 2022 15:11

flyway38

unread,
Dec 3, 2022, 11:48:16 AM12/3/22
to jallib
Hi Rob,

Thanks for that help.
But, right now am concerned about the other acknowledge messages... "OK" is now working good enough here.
And it seems serial_hw_int_cts LIB is not making any difference.
Maybe am not taking full advantages from it.
Cheers,

FS

flyway38

unread,
Dec 3, 2022, 12:23:53 PM12/3/22
to jallib
The oddest thing here, is it seems only my PIC doesn't pick up the answers from the modem, except the "OK" but even these fail sometimes to get picked up by the PIC.
I have a derived connection from that serial port using an FTDI cable connected to my computer, and can check what is going on using the Hyperterminal App or even the Termite App and these apps can see the answers from the modem.... crazy stuff going on here...

vsurducan

unread,
Dec 3, 2022, 1:41:30 PM12/3/22
to jal...@googlegroups.com
I'm not sure if this is your case, but if you need to identify the AT during a string reception, but prior to store the string in any buffer, I think the library will not work as is...

flyway38

unread,
Dec 3, 2022, 1:58:35 PM12/3/22
to jallib
Hi Vasile,

I want to read the answers from modem just like Hyperterminal or Termite does.
As example:
This the AT command to question modem for new SMS received:
AT+CMGL="ALL"
In my case I know theres a SMS in memory, so modem answers to that command:
+CMGL: 1,"REC READ","+351000MyNrHere000",,"2022/12/03,18:10:22+00"
Test

OK
Can see all this in Hyperterminal happening, but PIC doesn't get that answer from modem...
I need to read this answer from modem, and then extract the message "Test" part of modem answer
It would be enough to read the "+GMGL: 1" from the modem's answer.... but no luck so far.
Thanks anyway for the input.

Regards,
Filipe Santos

Rob CJ

unread,
Dec 3, 2022, 2:51:27 PM12/3/22
to jal...@googlegroups.com
Hi Filipe ,

I think the message is too long before OK is received since the whole message should be stored. For a PIC16 the buffer can at most be 80 bytes. You can use the large array library if you need a larger buffer.

Met vriendelijke groet,
Rob Jansen

From: jal...@googlegroups.com <jal...@googlegroups.com> on behalf of flyway38 <fsfo...@gmail.com>
Sent: Saturday, December 3, 2022 7:58:35 PM
To: jallib <jal...@googlegroups.com>
Subject: Re: [jallib] Re: Variable Table Append
 

flyway38

unread,
Dec 3, 2022, 3:00:23 PM12/3/22
to jallib
Hi Rob,

As said, It would be enough to get a small part; "+CMGL" then it will be another battle to reach the message part of the SMS.
For now am finally successfully, again using "brute force" on reading serial port:

var byte Received[50]

function CheckComms_CMGL() return bit is
   Index = 0
   --
   while Index < 50 loop
      fReturn = serial_hw_read(char)
      Received[Index] = char
      Index=Index+1
   end loop
   --
   fRtn=FALSE
   --
   for 45 using Index loop
      if (Received[Index]=="+"
         & Received[Index+1]=="C"
         & Received[Index+2]=="M"
         & Received[Index+3]=="G"
         & Received[Index+4]=="L") then
         fRtn=TRUE
      end if
   end loop
   return fRtn
end function

Anyways, am starting to get the hang of this "battle"
I think that will manage to get the message ("Test") part of this SMS answer from the modem.
If not, will back here... :D

Thank you all for the help.
You guys are great.
Cheers,

Filipe Santos.

vsurducan

unread,
Dec 4, 2022, 1:11:22 AM12/4/22
to jal...@googlegroups.com
Well, I think we are on the right path now: do you need the whole message between  +cmgl and ok? It seems to me you don't since it contains data you already know (your sim number) You can filter at reception time the info you need  (except for the sms body itself, but even that is possible) without storing everything previously in a buffer. You need interrupts for this. But will not work with the serial_hw_read procedure in the serial_hw_int_cts library as is. You have to filter for +cmgl in the _serial_receive_interrupt_handler
Can +CMGL appear without OK? 



Rob CJ

unread,
Dec 4, 2022, 3:24:49 AM12/4/22
to jallib
Hi Filipe,

Nice that this works. 

As said earllier you can have a look at the bluetooth_hc05.jal library. Some procedures and functions there perform the actions you are tryiing to achieve.

Kind regards,

Rob



Verzonden: zaterdag 3 december 2022 21:00

flyway38

unread,
Dec 4, 2022, 9:59:08 AM12/4/22
to jallib
Hey Vasile and Rob,

@Vasile,
Yes, +CMGL appear in my Received[50] buffer. But not the "Test" and "OK" parts... yet.
Am currently working on that. Will check that" _serial_receive_interrupt_handler" to see if am able to use it (if not too complex... some usage samples would be nice).
Thank you for your input.

@Rob, 
Have checked those LIBs, but too complex for me.
Don't have much time to interpret all that code and adapt to my code.
Any samples of usage easier to adapt?
Thank you anyways.

Cheers,
Filipe Santos.

Rob CJ

unread,
Dec 4, 2022, 10:53:30 AM12/4/22
to jal...@googlegroups.com
Hi Vasile,

If you want to use the serial library with interrupt just check the sample files that are created for it. I have used the library quite often without any problems.

Kind regards,

Roib


Verzonden: zondag 4 december 2022 15:59

flyway38

unread,
Dec 12, 2022, 12:59:14 PM12/12/22
to jallib
Hey all,

Am back on this subject.
My project had some halts but is back on track.

Right now am back to SMS receiving subject.
Have already reached the conclusion that I can receive more parts of message if make RX buffer bigger...

Here's the relevant part of serial_hw_int_cts LIB;
if (defined(SERIAL_RCVBUFSIZE) == FALSE) then
   const   SERIAL_RCVBUFSIZE  = 80  -- 64 is the default size of receive buffer
end if

Problem is 80 is the maximum I can use in this code (PIC16F19176).
How can I get more of the received data?

Here's the data I should read:
+CMGL: 1,"REC READ","+351000000000",,"2022/12/08,17:10:12+00"
GA6-B MODEM SMS
TEST, ADC= 2.757V
+CMGL: 2,"REC READ","+351....

The green part is what I can get using RX buffer at 80.
My goal is to get the full line:
GA6-B MODEM SMS TEST, ADC= 2.757V

Any help will be appreciated.
Thank you very much.

Kind regards,
Filipe Santos.

vsurducan

unread,
Dec 12, 2022, 1:37:50 PM12/12/22
to jal...@googlegroups.com
1.The length of your message is always the same?
2. From the whole message, receiving the part GA6...2.757V would be sufficient?



Rob CJ

unread,
Dec 12, 2022, 1:48:31 PM12/12/22
to jal...@googlegroups.com
Hi Filipe,

You should use the large array library and copy the data from the buffer (which can then be smaller) to the large array. 

Met vriendelijke groet,
Rob Jansen

From: jal...@googlegroups.com <jal...@googlegroups.com> on behalf of vsurducan <vsur...@gmail.com>
Sent: Monday, December 12, 2022 7:37:34 PM
To: jal...@googlegroups.com <jal...@googlegroups.com>

flyway38

unread,
Dec 12, 2022, 2:29:34 PM12/12/22
to jallib
Hello Vasile and Rob,

Thank you for your feedback.

@Vasile;
1 - No. It will depend on the number of SMS received by the modem. But only need the 2nd line of each SMS. This answers your #2.
2 - Yes. But this is still a test information received as an SMS. Later on, it will be different and much probably bigger in nr of chars...

@Rob
Am not sure on how to use that and copy the data from the buffer to a large array library.
Maybe some sample code would help.
Heres my receiving code, anyways:

   for 50 using Index loop
      fRtn = serial_hw_read(char)
      if fRtn then
         Received[Index] = char
      end if

   end loop
   --
   fRtn=FALSE
   --
   for 74 using Index loop

      if (Received[Index]=="+"
         & Received[Index+1]=="C"
         & Received[Index+2]=="M"
         & Received[Index+3]=="G"
         & Received[Index+4]=="L"
         & Received[Index+5]==":") then

         fRtn=TRUE
      end if
   end loop

Thank you guys for your help.
Cheers,

FS

flyway38

unread,
Dec 12, 2022, 2:34:55 PM12/12/22
to jallib
Correction in my code.
Was trying another option and had changed first For Loop counter...
Am using this array var; var byte Received[80], here also cannot make it any bigger.
Here the correct code i should have post above:

   for 80 using Index loop

      fRtn = serial_hw_read(char)
      if fRtn then
         Received[Index] = char
      end if
   end loop
   --
   fRtn=FALSE
   --
   for 74 using Index loop
      if (Received[Index]=="+"
         & Received[Index+1]=="C"
         & Received[Index+2]=="M"
         & Received[Index+3]=="G"
         & Received[Index+4]=="L"
         & Received[Index+5]==":") then
         fRtn=TRUE
      end if
   end loop

Thank you,
FS

vsurducan

unread,
Dec 13, 2022, 12:53:04 AM12/13/22
to jal...@googlegroups.com
Assuming from received garbage you need only this: S_GA6-B_MODEM_SMS_TEST, ADC= 2.757V_E, where S=start char, E=end char,
meaning 35 characters of interest including start and end
you have to:
1. make  a copy of your serial_hv_int_cts.jal library and rename it serial_hv_int_cts_modified.jal
2. in the serial_hv_int_cts_modified.jal modify the  _serial_receive_interrupt_handler() with the one below

3. in the main program include the modified library and:

var bit datapresent = false
var byte chars_ok = 0
var byte chars_sent = 35
include serial_hw_int_cts_modified
serial_hw_init()

forever loop
 if datapresent then
 ; read _serial_rcvbuf [i]  for i = 0 to 35 and print your relevant string
 end if
end loop

This should work if you will be careful with the position in the buffer ( not tested for your string, but tested in the past for other stuff).
It might work without counting chars as well, but it needs to detect the end char E instead of counting chars ( even if counting is more safe).


procedure  _serial_receive_interrupt_handler() is; to be replaced in serial_hv_int_cts_modified.jal
---------------------------------------------------------------------
   pragma interrupt

   var  byte  x

   if  (PIR1_RCIF == TRUE)  then                -- UART receive interrupt
     
      if ((RCSTA_OERR == TRUE) | (RCSTA_FERR == TRUE)) then  -- frame/overr error
         x = RCREG                              -- flush hardware buffer
         while RCSTA_OERR == TRUE loop          -- overrun state
            RCSTA_CREN = FALSE                  -- disable UART
            RCSTA_CREN = TRUE                   -- re-enable UART
            x = RCREG                           -- \  flush hardware buffers
            x = RCREG                           -- /
         end loop                               -- until no more overrun
         _serial_offsetrcvtail = 0              -- \  flush circular buffer
         _serial_offsetrcvhead = 0              -- /
         serial_ctsinv = FALSE                  -- ensure CTS true

      else
         x = RCREG                                      -- data without errors

         if (! datapresent) then
          _serial_rcvbuf[_serial_offsetrcvhead] = x
          if x == "S" then ; relevant char found
;         if chars_ok == 0 then
           _serial_offsetrcvhead = 1
            chars_ok = 1
            else
           if (chars_ok > 0) then
              _serial_offsetrcvhead = _serial_offsetrcvhead + 1
              chars_ok = chars_ok + 1        
                  if (chars_ok == chars_sent) then
              datapresent = true
              chars_ok = 0
              _serial_offsetrcvhead = 0
                  end if
                end if
             end if
          end if -- datapresent
      end if
   end if

end procedure

Rob CJ

unread,
Dec 13, 2022, 2:56:25 AM12/13/22
to jal...@googlegroups.com
Hi Filipe,

In the past I made a library for the ESP8266 that works with AT commands. I used the large array for that since the string could be big.

Here are some code snippets from that library (it is also present in the Jallib release) called esp8266.jal. If more than 80 bytes are needed the library uses a large array. Due to the use of aliases the rest of the library does not 'know' if a regular array or a large array is used. The last procedure reads the data until a CR is received. After that you can check the contents of the buffer. 

-- We need to check the array size to determine if we need a larger array than
-- the one that normally fits in one bank. If so we include a library to handle
-- larger arrays.
if (ESP8266_MAX_RECEIVE_BUFFER <= 80) then
   var byte esp8266_receive_buffer[ESP8266_MAX_RECEIVE_BUFFER]
else
   const word LARGE_ARRAY_1_SIZE = ESP8266_MAX_RECEIVE_BUFFER        
   const word LARGE_ARRAY_1_VARIABLE_SIZE = 1 -- Array of bytes.
   include large_array_1  
   alias esp8266_receive_buffer is large_array_1
end if

-- Global variable that indicates how many bytes are in the global ESP8266
-- receive buffer.
var word esp8266_bytes_received

-- Control ESP8266 via first USART.
include serial_hw_int_cts  



-- Wait a certain time for a character to be receives and return TRUE when a
-- character was received and return the character. Note that once read,
-- from the serial buffer the character is gone.
function _esp8266_get_character(byte out character) return bit is
   var dword waittime = _ESP8266_RESPONSE_TIMEOUT_10_US
   var bit character_received = FALSE
   
   while !character_received & (waittime > 0) loop
      if serial_hw_read(character) then
         character_received = TRUE
      end if
      _usec_delay(10) -- Do not wait too long since bitrate is high.
      waittime = waittime - 1
   end loop
   return character_received
end function


-- Copy the EPS8266 data from the serial buffer to the global EPS8266 receive
-- buffer until a carriage return is received. The number of copied bytes is
-- returned in the global variable esp8266_bytes_received
procedure _esp8266_copy_response() is
   var byte character
   var bit stop
   
   stop = FALSE
   esp8266_bytes_received = 0
   while !stop & (esp8266_bytes_received < ESP8266_MAX_RECEIVE_BUFFER) loop
      -- Getting the character is a one time read so stop as soon as it is over.
      if _esp8266_get_character(character) then
         if (character == _ESP8266_CARRIAGE_RETURN) then
            stop = TRUE
         else
            esp8266_receive_buffer[esp8266_bytes_received] = character
            esp8266_bytes_received = esp8266_bytes_received + 1
         end if
      else
         stop = TRUE
      end if
   end loop
end procedure

Kind regards,

Rob

Verzonden: dinsdag 13 december 2022 06:45

flyway38

unread,
Dec 13, 2022, 2:58:21 AM12/13/22
to jallib
Hello Vasile,

Thank you very much for your help.
Will test your code later on today.

Have found already that the problem seems to be related to that 80byte limit in array vars.
Particularly speaking about the RX buffer;
if (defined(SERIAL_RCVBUFSIZE) == FALSE) then
   const   SERIAL_RCVBUFSIZE  = 80  -- 64 is the default size of receive buffer
end if
So, maybe your code will overcome this issue.
Thank you.

Cheers,
FS

flyway38

unread,
Dec 13, 2022, 3:02:14 AM12/13/22
to jallib
Hello Rob,

Thank you very much for your input.
Will check your snippet code later on today.
Then will back here with the outcome.

Thank you,

Cheers,
Filipe Santos

flyway38

unread,
Dec 13, 2022, 3:31:47 AM12/13/22
to jallib
Summing up this issue is;

This is what Modem answers to my AT command to read SMSs received:
(As obvious, first line is SMS identifier and second line is information data in this SMS)
+CMGL: 1,"REC READ","+351000000000",,"2022/12/08,17:10:12+00"
GA6-B MODEM SMS TEST, ADC= 2.757
...
This part is enough to read from modem's answer, since my code will delete all received SMSs after reading the first one.
It has currently 93 chars but can change. From this will only need 2nd line part "GA6-B MODEM SMS TEST, ADC= 2.757" and this will also (very soon) change for sure.
So, I need to read the whole Modem answer (always bigger than 80 chars/bytes) and then extract the useful data part of it.

Cheers,
FS

Oliver Seitz

unread,
Dec 13, 2022, 4:02:22 AM12/13/22
to jal...@googlegroups.com
Hi Filipe,

"So, I need to read the whole Modem answer (always bigger than 80 chars/bytes) and then extract the useful data part of it."

This is only partly true. Yes, you have to read it. But, to read it, you don't really have to store it. You can e.g. use a state machine which checks for the chars "+","C","M","G","L"... in that order, advancing the state each time the right char comes in. Only when the state reaches the value that indicates the start of the payload, you can start copying incoming chars to your buffer (if that is really needed). 

The 80-byte array limit is pic dependent: on PIC18F, arrays can be up to 256 bytes. To be sure, if you want to store the whole message, better use large_array anyway.

About the modified library: Can be done, but I wouldn't do it that way. Mixing global variables between the main program and a library makes code maintenance hard. And, with such specific alterations, I wouldn't call it a library anymore. If I was going that way, I'd copy the library code to the main program and do the modifications there. 

Good luck :-)

Greets,
Kiste

Am Dienstag, 13. Dezember 2022, 09:31:49 MEZ hat flyway38 <fsfo...@gmail.com> Folgendes geschrieben:


flyway38

unread,
Dec 13, 2022, 5:44:20 AM12/13/22
to jallib
Hello Kiste,

Yes, you are right.
I don't need to store whole answer from the modem.
Even the "payload" also only need to check and make a return var with according information.
Anyways, not sure about how to code a "state machine"... heres what I have for now:

   for 80 using Index loop

      fRtn = serial_hw_read(char)
      if fRtn then
         Received[Index] = char
      end if
   end loop
   --
   fRtn=FALSE
   --
   for 74 using Index loop
      if (Received[Index]=="+"
         & Received[Index+1]=="C"
         & Received[Index+2]=="M"
         & Received[Index+3]=="G"
         & Received[Index+4]=="L"
         & Received[Index+5]==":") then
         fRtn=TRUE
      end if
   end loop

This fRtn boolean will make the code read the Payload (it has confirmed that received an SMS).
Then it will check the payload and return a byte which will identify what payload received, although for now (for testing purposes) it is returning the "payload" itself...

Thank you for your help.

Cheers,
FS
Reply all
Reply to author
Forward
0 new messages