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 On Saturday, December 3, 2022 at 2:22:04 PM UTC [email protected] wrote: > 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 > ------------------------------ > *Van:* [email protected] <[email protected]> namens flyway38 < > [email protected]> > *Verzonden:* zaterdag 3 december 2022 15:11 > > *Aan:* jallib <[email protected]> > *Onderwerp:* Re: [jallib] Re: Variable Table Append > 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 > > On Saturday, December 3, 2022 at 1:43:23 PM UTC [email protected] wrote: > > 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:* [email protected] <[email protected]> namens vsurducan > <[email protected]> > *Verzonden:* zaterdag 3 december 2022 11:09 > > *Aan:* [email protected] <[email protected]> > *Onderwerp:* Re: [jallib] Re: Variable Table Append > 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. > > On Sat, Dec 3, 2022 at 11:53 AM flyway38 <[email protected]> wrote: > > 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 > > On Saturday, December 3, 2022 at 6:18:47 AM UTC vasile wrote: > > 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. > > On Fri 2 Dec 2022, 9:25 PM flyway38 <[email protected] wrote: > > Hello Rob, > > Thank you very much. > This will help alot. > Cheers. > > FS > > On Friday, December 2, 2022 at 7:21:46 PM UTC [email protected] wrote: > > 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:* [email protected] <[email protected]> namens Rob CJ < > [email protected]> > *Verzonden:* vrijdag 2 december 2022 20:20 > *Aan:* [email protected] <[email protected]> > > *Onderwerp:* Re: [jallib] Re: Variable Table Append > 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 > > > ------------------------------ > *Van:* [email protected] <[email protected]> namens flyway38 < > [email protected]> > *Verzonden:* vrijdag 2 december 2022 19:23 > *Aan:* jallib <[email protected]> > *Onderwerp:* Re: [jallib] Re: Variable Table Append > > 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 > > On Friday, December 2, 2022 at 6:06:56 PM UTC [email protected] wrote: > > 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:* [email protected] <[email protected]> namens flyway38 < > [email protected]> > *Verzonden:* vrijdag 2 december 2022 12:38 > *Aan:* jallib <[email protected]> > *Onderwerp:* [jallib] Re: Variable Table Append > > Am trying to mimic a "Read_String" from serial port. > Any ideas? > > Thank you. > > Regards, > FS > > On Friday, December 2, 2022 at 9:42:34 AM UTC flyway38 wrote: > > 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. > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/2251b524-7658-42f7-970b-a6817d6709e1n%40googlegroups.com > > <https://groups.google.com/d/msgid/jallib/2251b524-7658-42f7-970b-a6817d6709e1n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/37733abd-20ed-4130-8aa2-03381fb3ac1an%40googlegroups.com > > <https://groups.google.com/d/msgid/jallib/37733abd-20ed-4130-8aa2-03381fb3ac1an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/GVXP195MB16374C5EDB5CFD44C5580F26E6179%40GVXP195MB1637.EURP195.PROD.OUTLOOK.COM > > <https://groups.google.com/d/msgid/jallib/GVXP195MB16374C5EDB5CFD44C5580F26E6179%40GVXP195MB1637.EURP195.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/1af55b5d-54bb-4ea7-a2d6-21574ba3ea7an%40googlegroups.com > > <https://groups.google.com/d/msgid/jallib/1af55b5d-54bb-4ea7-a2d6-21574ba3ea7an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/bfa9ccd1-54c6-47d1-9535-8272eb0cca90n%40googlegroups.com > > <https://groups.google.com/d/msgid/jallib/bfa9ccd1-54c6-47d1-9535-8272eb0cca90n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsrRDXRbaHZi8f3zPGVVje5YzHQn1yzXzQvLBE5NxD5_w%40mail.gmail.com > > <https://groups.google.com/d/msgid/jallib/CAM%2Bj4qsrRDXRbaHZi8f3zPGVVje5YzHQn1yzXzQvLBE5NxD5_w%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jallib/6748d6c6-d1a3-4f0c-82ea-baf9410375d0n%40googlegroups.com > > <https://groups.google.com/d/msgid/jallib/6748d6c6-d1a3-4f0c-82ea-baf9410375d0n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/b7996e98-cc9c-4621-876f-2d7146956ddan%40googlegroups.com.
