18F4620 Memory full! What to do? Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
I understood we are only using the $GPGGA msg.??
$GPGGA,162254.00,3723.02837,N,12159.39853,W,1,03,2.36,525.6,M,-25.6,M,,*65

E
Hi E,
Correct, this was for LAT, LON and ALT. Since then I've added a Barometer/Altimeter module, so now I don't need to go past 'W' in the sentence, so I changed to the $GNRMC sentence which is received faster by the GPS.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
We have Str1 [Dim str1(50) As Byte ] Is this a STRING?

It looks to me that once Str1 has been PARSED, this produces the STRINGS.

Doesn't this mean that STRING_MAX_LENGTH only needs to be long enough to hold the longest STRING?
e,g, LON = 4807.038 (8) Only needs to be 8

Until calculations need decimal places, when I assume I will need to lengthen STRING_MAX_LENGTH.

How much of this is correct?
C.
 

ericgibbs

Joined Jan 29, 2010
18,848
hi C,
Oshonsoft Manual clip.
Arrays.
It is also possible to use one-dimensional arrays. For example: DIM A(10) AS BYTE
declares an array of 10 Byte variables with array index in the range [0-9].

A Basic String is ASCII characters.

Attached a copy of my manual rewrite, hope it helps, use the blue hyper links to navigate.

E

EDIT: I asked you earlier is all your incoming data ASCII format.?
 

Attachments

djsfantasi

Joined Apr 11, 2010
9,163
I’m not sure in OBasic, but I would say that Str1 is NOT a string, but a character array. Ironic.

It is good to define strings or character arrays only as long as needed, perhaps with a little pad to allow for unexpected input or future expansion. But! Strings DONT have a defined length. In Arduino C, Strings don’t have a maximum length defined; They are as long as they need to be. This is convenient and a curse as well. Read up on array bounds violation and garbage collection to see a couple of the curses of strings.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
I’m not sure in OBasic, but I would say that Str1 is NOT a string, but a character array. Ironic.

It is good to define strings or character arrays only as long as needed, perhaps with a little pad to allow for unexpected input or future expansion. But! Strings DONT have a defined length. In Arduino C, Strings don’t have a maximum length defined; They are as long as they need to be. This is convenient and a curse as well. Read up on array bounds violation and garbage collection to see a couple of the curses of strings.
Hi D,
This is a it confusing, but I can test different ideas in the simulator, so I should be able to figure it out.

OBASIC has limitations. 'E' is also answering, and he understand OBASIC, so we may get clear answers.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
Oshonsoft Manual clip.
Arrays.
It is also possible to use one-dimensional arrays. For example: DIM A(10) AS BYTE
declares an array of 10 Byte variables with array index in the range [0-9].

A Basic String is ASCII characters.

Attached a copy of my manual rewrite, hope it helps, use the blue hyper links to navigate.

E

EDIT: I asked you earlier is all your incoming data ASCII format.?
Hi E,
I'll give your manual a good looking at, thanks.

I hope I answered the ASCII question in #57.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
All that shows is a Table of GPS messages, what about all the other peripheral devices you have attached.?
E
Hi E,
Yes, it shows all of the GPS messages plus an example of the message that will be sent from the REMOTE all of the incoming messages.

The other modules: AK8963C compass, and BMP280 Altimeter give numbers with perhaps 10 digits, and a decimal point.

Looking at your Manual, and the ARRAY example.has cleared things up a bit.
I've taken OFF the stop at 'W', now STR1 and STR2 enter up to the number in brackets STR(50) then carries on but those numbers aren't stored. The simulator box now clears.
Then the stored ARRAY, can be PARSED as usual.
Still testing.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
For anyone looking at the program! It is always changing slightly.
Now knowing that STR1 anSTR2 are ARRAYs they are now named ARY1 and ARY2.
C
 

ericgibbs

Joined Jan 29, 2010
18,848
Morning C,
A very long time ago, when we were only using the GPGGA message from the GPS receiver, so for convenience only, we called the Array 'str1' as it was storing the message as a ASCII data string. [it was actually Dim str1(60) As Byte]

By using the Str1 [Array] we could parse out the data values of interest from the 'message' by using str1, [Array] pointers ie: 'x'

I don't see an advantage in renaming the 'str1' as 'ary1', especially IIRC, we also used 'ary' Dims for other variables, it's your call.

E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Morning C,
A very long time ago, when we were only using the GPGGA message from the GPS receiver, so for convenience only, we called the Array 'str1' as it was storing the message as a ASCII data string. [it was actually Dim str1(60) As Byte]

By using the Str1 [Array] we could parse out the data values of interest from the 'message' by using str1, [Array] pointers ie: 'x'

I don't see an advantage in renaming the 'str1' as 'ary1', especially IIRC, we also used 'ary' Dims for other variables, it's your call.

E
Hi E,
I only renamed it to make it different from other STR words, but I'll change it back as now you've explained it is a DATA STRING, then I'll comment it ARRAY for my clarity.
C.
 

ericgibbs

Joined Jan 29, 2010
18,848
hi C,
The downside of defining as an actual ASCII String, is that to extract/parse a value from the String, we have to use the MidStr(x,y,n), TrimStr, etc.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
The downside of defining as an actual ASCII String, is that to extract/parse a value from the String, we have to use the MidStr(x,y,n), TrimStr, etc.
E
Hi E,
I've not used Trimstr before but midstr leftstr and rightstr are still working as you wrote them.

What downside?
C.
 

ericgibbs

Joined Jan 29, 2010
18,848
hi C,
By using an Array, its size [length] can be defined for that array.
Look at the extra coding we had to do for the 5110 LCD when we used String , MidStr, in order to extract the ASCII value and then convert to Numeric value.
E
I post some samples later.
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi C,
By using an Array, its size [length] can be defined for that array.
Look at the extra coding we had to do for the 5110 TFT when we used String , MidStr, in order to extract the ASCII value and then convert to Numeric value.
E
I post some samples later.
Hi E,
As you know this program has been built over a couple of years, and it's almost working using the elements already in the program.
I think, for me it would be better if I plod on till the program works, then I'll ask for refinements such as what you are suggesting here, plus the many suggestions others have offered, and I will try to improve my programming skills.
C
 

ericgibbs

Joined Jan 29, 2010
18,848
hi,
I would say that's the best way, let's getting working.

A clip from a noddy program to show that once you define String_Len, Oshonsoft allocates the same string len to all your strings, even if it only uses say 8 or 9 bytes.

Define STRING_MAX_LENGTH = 60
Dim nmsg As String
Dim emsg As String

0009 000000 ; The address of 'nmsg' (array 61) (string) (global) is 0x014
0010 000000 ; The address of 'emsg' (array 61) (string) (global) is 0x080
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
hi,
I would say that's the best way, let's getting working.

A clip from a noddy program to show that once you define String_Len, Oshonsoft allocates the same string len to all your strings, even if it only uses say 8 or 9 bytes.

Define STRING_MAX_LENGTH = 60
Dim nmsg As String
Dim emsg As String

0009 000000 ; The address of 'nmsg' (array 61) (string) (global) is 0x014
0010 000000 ; The address of 'emsg' (array 61) (string) (global) is 0x080
Hi E,
Ok, I'll come back to it, remind me please.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Hi,
I'm trying to get the Nokia 5110 LCD working.

If I program an old example program onto the PIC, nothing shows.
I've copied the relevant sections from the old program into the new program.
If I now program the PIC, a message shows on the screen.
If I change the message in the new program, nothing changes, even after more ERASEs.

I've tried two different programmers MPLAB and PICKIT3. I've tried ERASE, READ show FLASH and EEPROM all showing FFFs, then reprogram the new program onto the PIC but the original message is still there.

NOTE: There is a message in the D/S to RESET it, which I do.

Can someone outline what they think is going on please?
C.
 

jjw

Joined Dec 24, 2013
823
Do you mean, that the old message shows in the FLASH after erasing and programming or in the LCD, when running the program?
 

Thread Starter

camerart

Joined Feb 25, 2013
3,730
Do you mean, that the old message shows in the FLASH after erasing and programming or in the LCD, when running the program?
Hi J,
All references in #78 refer to showing on the 5110LCD.. After an ERASE, READ which show FFFFs in EEPROM and FLASH, then re-programmed.
C.
 
Top