Oshonsoft programs with INTERRUPTS and PARSE

Thread Starter

camerart

Joined Feb 25, 2013
3,830
Morning C,
If you can get a Ring Buffer working, what will be its purpose/advantage in your project program.? ;)
E
Hi E,
I was advised to use a ring buffer, and was told to make the buffer 2x the size of the largest STRING. I wondered about PIC memroy size and asked if it would affect it. After no response, I started to learn ring buffers, and spent so long that it was after the point of no return, when you remined me about PIC memory. (I've spent hours!!!)
The answer to your question is, for this project and your reasons, it probably won't fit in my project.
EDIT: #127
C.
 
Last edited:

ericgibbs

Joined Jan 29, 2010
21,442
hi C,
From what I recall about your project, I would say using a ring buffer is pointless, it will increase the complexity of the program and gobble up memory, which is already tight.
E
 

Thread Starter

camerart

Joined Feb 25, 2013
3,830
hi C,
From what I recall about your project, I would say using a ring buffer is pointless, it will increase the complexity of the program and gobble up memory, which is already tight.
E
Hi E,
Ok, it's only an exersize, and I'm not finding it easy. As explained #142, I realise it may not be suitable for my project.
EDIT: I've had a re-think and as it may not suit my purpose, I'll leave ring buffers for now, thanks.
C
 
Last edited:

Thread Starter

camerart

Joined Feb 25, 2013
3,830
Hi,
I'm still trying to get my program to work. First I'm trying a LINEAR one.
Here it is so far, but it gives errors, that are either my poor programming, or a recurring LEFT STRING, MID STRING problem, I had previously.

Will someone run this through a simulator please, to see if the error still happens, please?

I had to turn OFF/ON the INTERRUPT, and recall, I was advised not to, but it wouldn't do anything otherwise.

ENTER into UART:
$GPRMC,123519,A,4807.038,N,01131.000,W,022.4,084.4,230394,003.1,W*6A?
$QEIDEG,111,W$QEIDEG,222,W $QEIDEG,333,W
$REMOTE,12,20,50,W
C
 

Attachments

jjw

Joined Dec 24, 2013
823
Hi,
I'm still trying to get my program to work. First I'm trying a LINEAR one.
Here it is so far, but it gives errors, that are either my poor programming, or a recurring LEFT STRING, MID STRING problem, I had previously.

Will someone run this through a simulator please, to see if the error still happens, please?

I had to turn OFF/ON the INTERRUPT, and recall, I was advised not to, but it wouldn't do anything otherwise.

ENTER into UART:
$GPRMC,123519,A,4807.038,N,01131.000,W,022.4,084.4,230394,003.1,W*6A?
$QEIDEG,111,W$QEIDEG,222,W $QEIDEG,333,W
$REMOTE,12,20,50,W
C
What is the error?
 

sagor

Joined Mar 10, 2019
1,049
Setting PIE1.RCIE=0 does not stop the UART from receiving characters, and eventually causing an overflow if data does come into the UART. The PIR1.RCIF flag still gets set as well, regardless of the RCIE setting. You have to turn off RXSTA.CREN=0 to prevent the UART from processing data and causing an overflow error.
Or, if you are leaving the UART enabled and are going to enable RCIE=1 again, first clear the RX data and error registers, and flags first.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,830
Setting PIE1.RCIE=0 does not stop the UART from receiving characters, and eventually causing an overflow if data does come into the UART. The PIR1.RCIF flag still gets set as well, regardless of the RCIE setting. You have to turn off RXSTA.CREN=0 to prevent the UART from processing data and causing an overflow error.
Or, if you are leaving the UART enabled and are going to enable RCIE=1 again, first clear the RX data and error registers, and flags first.
Hi S,
OK, I'll try to change it, thanks.
C.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,830
For example all the "REM":s come from Leftstr(...,3) .
Look at the manual what Leftstr does.
Hi J,
This has always confused me. I don't understand why there are 3x choices.

How I understand it is: e,g,
------------------------------------------------
Case 2
strremvolt = LeftStr (msg1, 3)
-------------------------------------------------
= 1st 3x digits of the STRING left of COMMA 2

C.
 

djsfantasi

Joined Apr 11, 2010
9,237
The leftmost characters in a string, characters in the middle of a string or the rightmost characters in a string. Each will return different results.
 

Thread Starter

camerart

Joined Feb 25, 2013
3,830
The leftmost characters in a string, characters in the middle of a string or the rightmost characters in a string. Each will return different results.
Hi J,
Got it! It's not left or right of the comma, I didn't think about MIDSTR in this regard :)
Thanks.
C.
 

sagor

Joined Mar 10, 2019
1,049
If you want to locate the comma first, look into the INSTR instruction (or INSTRREV). You can use that to find the location of a character within a string, then use that pointer to extract data after that position with a MIDSTR function
 

Thread Starter

camerart

Joined Feb 25, 2013
3,830
Hi,
After testing RIGHT and LEFTSTRING, I think there is either a fault in Oshonsoft, or maybe my programming, but I find that MIDSTRING seems to work ok.

I removed CASE and COMMAS and re-wrote the INTERRUPT/PARSE program.

It works mostly, but I think it gives error in certain circumstances. It's a bit difficult for me to actually find where the errors are produced. Anyway, I'll keep trying.

Here is the program:
EDIT: After a slight change, I think the attached program is working ok. A second opinion, before I add it into the FUL program would be helpful, please.
C.
 

Attachments

Last edited:

jjw

Joined Dec 24, 2013
823
Hi,
After testing RIGHT and LEFTSTRING, I think there is either a fault in Oshonsoft, or maybe my programming, but I find that MIDSTRING seems to work ok.

I removed CASE and COMMAS and re-wrote the INTERRUPT/PARSE program.

It works mostly, but I think it gives error in certain circumstances. It's a bit difficult for me to actually find where the errors are produced. Anyway, I'll keep trying.

Here is the program:
C.
I tested PICBASIC v.7.85 ( pic12f683 ) and found no faults in Leftstr, Rightstr.
Can you give examples of the faults.
 
Top