• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Rtty gps

Status
Not open for further replies.

SwingeyP

Member
Hello again,

First of all thanks to everyone that has helped me with this project.

I am still having a few problems but i'm much futher forward.

The RTTY side of the code has been working for some time and so I decided to add the GPS bit.

The code works just fine under simulation well appears to any way but in the real world things go bad.

--- SIMULATION
Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'RTTY with NTX2 Test written by paul swingewood
'March 2013   - PIC 16F628A
'Based on code developed by Rob Harrison for Arduino
'--------------------------------------------------------------------------

'Define SIMULATION_WAITMS_VALUE = 2

'No Fix - added CR
'$GPGGA,,,,,,0,,,,,,,,*66

'Fix - added CR
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B



Define CONF_WORD = 0x3f50  'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital


Define SEROUT_DELAYUS = 1000

Symbol txcr_pin = PORTA.7
Dim i As Byte  'used for loops
Dim j As Byte  'used for loops
Dim ch As Byte  'used to hold individual character
Dim times_sent As Byte  'used to check number of times sent before waiting
Dim gpsin(70) As Byte  'Array
Dim inx As Byte
Dim x As Byte
Dim error_catch As Byte


startup:

Hseropen 4800

times_sent = 0
start:
For i = 0 To 1  '22
ch = LookUp("RY"), i  'M0TVU RTTY TEST BEACON
Hserout ch
Call convert_char(ch)
Next i

ch = 13  'Carriage Return
Call convert_char(ch)

If times_sent = 1 Then  '4
'---------------- READ THE GPS INFO
	error_catch = 0
	read_gps:
	ch = "x"  'anything other than 0x0d - cr
	'Read the data coming back from the URM37'Hserin datain(0)  'Bit1 -14
	Hserin gpsin(0)
	If gpsin(0) = "$" Then
		'load the string into the gpsin array
		inx = 1
		While ch <> 0x0d  'keep load characters until yo see cr
			Hserin ch
			gpsin(inx) = ch
			inx = inx + 1
		Wend
		If gpsin(12) = 0x30 Then  'ascii 0 - No Satelites found
			For i = 0 To 1  '15
				ch = LookUp("No"), i  'No Satellite Fix
				Hserout ch
				Call convert_char(ch)
			Next i
			times_sent = 0
			Goto start
		Else
			Gosub send_time
			'Gosub show_north
			'Gosub show_west
			'Gosub show_alt
			times_sent = 0
			Goto start
		Endif
	Else
		If error_catch < 2 Then
			error_catch = error_catch + 1
			Goto read_gps  'do this until you see the $
		Else
			Goto start
		Endif
	Endif
Endif
times_sent = times_sent + 1
Goto start
End                                               

send_time:
For x = 7 To 14
	ch = gpsin(x)
	Hserout ch
	Call convert_char(ch)
Next x
Return                                            


Function convert_char(chr As Byte) As Byte

Call rtty_txbit(0)  'start Bit

For j = 0 To 7  'ascii-7 / ascii-8
	If chr.0 Then
		Call rtty_txbit(1)
	Else
		Call rtty_txbit(0)
	Endif
chr = ShiftRight(chr, 1)
Next j

Call rtty_txbit(1)  'stop Bit
Call rtty_txbit(1)  'stop Bit

End Function                                      

Function rtty_txbit(b As Bit) As Bit

If b = 1 Then
'High
	High txcr_pin
Else
'Low
	Low txcr_pin
Endif

WaitUs 2  '1/50th of a second = 50 Baud? -20000
End Function
I have reduced the characters sent and the loops. It still takes a while to run n the simulator so stay with it.

I have the Hardware Uart open - you will see ryry and then the code waits for something from the GPS. send it ghghghg or some other rubbish dont forget 0x0d for cr. The first character is checked if its not a $ then get data again. Enter same string again - code will drop out from here and send ryry again. (error trap so it doesn't just sit there)

Once ryry is sent again the code waits for something from GPS. Enter $GPGGA,,,,,,0,,,,,,,,*66
again add 0x0d (code will wait for it). This time the code fills the array and checks to see if fild 12 is "0". If it is then we don't have any satellites as yet. Report this and return to start. If field 12 isn't a "0" then this is a valid packet. Send the time data. Then do it all again.

All seems to work just fine.

--- Real World

Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'RTTY with NTX2 Test written by paul swingewood
'March 2013   - PIC 16F628A
'Based on code developed by Rob Harrison for Arduino
'--------------------------------------------------------------------------

'Define SIMULATION_WAITMS_VALUE = 1

'No Fix - added CR
'$GPGGA,,,,,,0,,,,,,,,*66

'Fix - added CR
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B



Define CONF_WORD = 0x3f50  'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital


Define SEROUT_DELAYUS = 1000

Symbol txcr_pin = PORTA.7
Dim i As Byte  'used for loops
Dim j As Byte  'used for loops
Dim ch As Byte  'used to hold individual character
Dim times_sent As Byte  'used to check number of times sent before waiting
Dim gpsin(70) As Byte  'Array
Dim inx As Byte
Dim x As Byte
Dim error_catch As Byte


startup:

Hseropen 4800

times_sent = 0
start:
For i = 0 To 22  '22
ch = LookUp("M0TVU RTTY TEST BEACON"), i  'M0TVU RTTY TEST BEACON
Call convert_char(ch)
Next i

ch = 13  'Carriage Return
Call convert_char(ch)

If times_sent = 4 Then  '4
'---------------- READ THE GPS INFO
	error_catch = 0
	read_gps:
	ch = "x"  'anything other than 0x0d - cr
	'Read the data coming back from the URM37'Hserin datain(0)  'Bit1 -14
	Hserin gpsin(0)
	If gpsin(0) = "$" Then
		'load the string into the gpsin array
		inx = 1
		While ch <> 0x0d  'keep load characters until yo see cr
			Hserin ch
			gpsin(inx) = ch
			inx = inx + 1
		Wend
		If gpsin(12) = 0x30 Then  'ascii 0 - No Satelites found
			For i = 0 To 15  '15
				ch = LookUp("No Satellite Fix"), i  'No Satellite Fix"
				Call convert_char(ch)
			Next i
			times_sent = 0
			Goto start
		Else
			Gosub send_time
			'Gosub show_north
			'Gosub show_west
			'Gosub show_alt
			times_sent = 0
			Goto start
		Endif
	Else
		If error_catch <= 2 Then
			error_catch = error_catch + 1
			Goto read_gps  'do this until you see the $
		Else
			times_sent = 0
			Goto start
		Endif
	Endif
Endif
times_sent = times_sent + 1
Goto start
End                                               

send_time:
For x = 7 To 14
	ch = gpsin(x)
	Call convert_char(ch)
Next x
Return                                            


Function convert_char(chr As Byte) As Byte

Call rtty_txbit(0)  'start Bit

For j = 0 To 7  'ascii-7 / ascii-8
	If chr.0 Then
		Call rtty_txbit(1)
	Else
		Call rtty_txbit(0)
	Endif
chr = ShiftRight(chr, 1)
Next j

Call rtty_txbit(1)  'stop Bit
Call rtty_txbit(1)  'stop Bit

End Function                                      

Function rtty_txbit(b As Bit) As Bit

If b = 1 Then
'High
	High txcr_pin
Else
'Low
	Low txcr_pin
Endif

WaitUs 20000  '1/50th of a second = 50 Baud? -20000
End Function

In the real world however the error_catch never 'catches' (i assume) and after M0TVU RTTY TEST BEACON is sent 4 times thats it. It just sits there doing nothing.

The GPS is pulsing every second and I am monitoring it's output so I know it's there.

Can anyone see

1) whay the error_catch doesn't work
2) why I don't ever seem to see any GPS data

Thanks for all the help it's really appreciated.

Regards - Paul
 

SwingeyP

Member
The thick plottens ....

I decided to put in a few LCDout's here and there to track the code. I took all these out originally as it seemed to be causing me timing issues

The code now does this ...

send ident 4 times - (M0TVU RTTY TEST BEACON)
Read the GPS looking for $
Show the character read on the LCD - $ appears
Now populate the array - G appears on the LCD and then it hangs ......

Wow - really getting close now - but so infuriating ....

Code:
If times_sent = 4 Then  '4
'---------------- READ THE GPS INFO
	WaitMs 100  'take a breather
	
	error_catch = 0
	read_gps:
	ch = "x"  'anything other than 0x0d - cr
	'Read the data coming back from the URM37'Hserin datain(0)  'Bit1 -14
	Hserin gpsin(0)
	Lcdcmdout LcdLine1Pos(1)
	Lcdout gpsin(0)
	If gpsin(0) = "$" Then
		'load the string into the gpsin array
		inx = 1
		While ch <> 0x0d  'keep loading characters until you see cr
			Hserin ch
			gpsin(inx) = ch
			Lcdcmdout LcdLine2Pos(inx)
			Lcdout ch
			inx = inx + 1
		Wend
		Lcdcmdout LcdLine3Pos(1)
		Lcdout "array loaded"
		
		If gpsin(12) = 0x30 Then  'ascii 0 - No Satelites found
			For i = 0 To 15  '15
				ch = LookUp("No Satellite Fix"), i  'No Satellite Fix"
				Call convert_char(ch)
			Next i
			times_sent = 0
			Goto start
		Else
			WaitMs 100  'take a breather
			Gosub send_time
			'Gosub show_north
			'Gosub show_west
			'Gosub show_alt
			times_sent = 0
			Goto start
		Endif
	Else
		If error_catch <= 2 Then
			error_catch = error_catch + 1
			WaitMs 100  'take a breather
			Goto read_gps  'do this until you see the $
		Else
			times_sent = 0
			WaitMs 100  'take a breather
			Goto start
		Endif
	Endif
Endif
times_sent = times_sent + 1
Goto start
End
Any ideas - Regards - Paul

I thought the lcdouts in the read mught be slowing things down so I tried the output after loading the array. Program hangs after $ is displayed on LCD.
It appears then that the program hangs after the 2nd HSERIN is done.


Code:
If gpsin(0) = "$" Then
		'load the string into the gpsin array
		inx = 1
		While ch <> 0x0d  'keep loading characters until you see cr
			Hserin ch
			gpsin(inx) = ch
			inx = inx + 1
		Wend
		
		For i = 1 To 66
		Lcdcmdout LcdLine2Pos(i)
			Lcdout gpsin(i)
		Next i

		Lcdcmdout LcdLine3Pos(1)
		Lcdout "array loaded"
 
Last edited:

ericgibbs

Well-Known Member
Most Helpful Member
hi Paul,

The difference between simulation and the real world is that in the Sim, the UART waits for the RTTY signal to be completed BEFORE it starts to send the GPS string, so the RTTY and GPS are sequential. synchronised

In the real world the GPS string is being sent while the RTTY is being output, ie: asynchronous, so when you read the UART the RX buffer could contain any character of the string.

You must flush the UART RXD buffer BEFORE waiting for the $ symbol, then read and save in the Array.

E.

PS: Please dont create a new Thread for every aspect of the project, its getting confusing,,,
 

SwingeyP

Member
Hi Eric,

That makes perfect sense however I would have thought that the error_catch would 'catch' and just go back to sending RTTY if nothing of meaning was being received. I'm not sure how to 'flush the RX buffer'. Do I just use TRIS and set what ever address the rx buffer is to all zero's before reading?

I put a lot of LCDOUT's in the code last night and was seeing some weird results. I thought time for bed and have a look at it tomorrow :)

Regards - Paul
 

ericgibbs

Well-Known Member
Most Helpful Member
hi
I would consider doing it this way.
After the slow RTTY has finished, read the UART and dump the characters until you read the 'CR' end of line [EOL], then wait for the '$' sign, then save the full string upto and including the 'CR' .

Another point I have is with the RTTY Send subroutine.

The state of the PORTA.7 pin retains the sense of the last Bit transmitted. ie: if you send a char were the last bit is '1' the next char sent starts with a high and if the last char Bit sent was '0' the next char starts with a low.
Will this cause a corruption in the actual bytes received by the RTTY.???

E.
 
Last edited:

SwingeyP

Member
Hi Eric,

I am earning a crust in my day job at the moment. I'll get back to the code later today.
I was looking at the interupt code that Ian posted earlier. It seems that filling the buffer is a common problem and something I had completely overlooked as a novice.

Your suggestion looks like a good idea. I'll have a play again later. - I'll probably cut the GPS code out and focus on getting that bit working properly.

The RTTY works fine but does keep the line high at the end of transmission. There is no corruption and all works a dream. I will reset it low however just to give the transmitter a rest.

This has been a great project. I do find it diffcult to find basic command references. I personally think the OSHON reference manual is lacking a lot. It needs much more info on things like this. No where does it mention RCREG etc.... I know this is published in datasheets but it's difficult to see examples of how OSHON uses this.

This is why I have to keep pestering the gurus :)

Thanks for all the help its very much appreciated.
 

ericgibbs

Well-Known Member
Most Helpful Member
hi Paul,
If required you can mix ASM instructions with the Basic code, this enable you to control and read individual registers/flags associated with the UART.

E

EDIT:
My concern in using interrupts would be that you are using delay timing loops to create the slow RTTY Bit serial output timing.
 

SwingeyP

Member
Hi again Eric,

I'm now back at the mill stone.

I have made some changes to the code and with a hash up of what you said and some infor from Ian I can now at least trap the error.

I do still get buffer overflow and I don't know how I can fix it.

--- complete code ------

Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'RTTY with NTX2 Test written by paul swingewood
'March 2013   - PIC 16F628A
'--------------------------------------------------------------------------

'Define SIMULATION_WAITMS_VALUE = 1

'No Fix - added CR
'$GPGGA,,,,,,0,,,,,,,,*66

'Fix - added CR
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B

Define CONF_WORD = 0x3f50  'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital

'Define the comms for the LCD display.
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4  'Use the high order bits'
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_EREG = PORTA
Define LCD_EBIT = 0
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1


Define LCD_COMMANDUS = 5000  'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100  'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20


Define SEROUT_DELAYUS = 1000

Symbol txcr_pin = PORTA.7
Dim i As Byte  'used for loops
Dim j As Byte  'used for loops
Dim ch As Byte  'used to hold individual character
Dim times_sent As Byte  'used to check number of times sent before waiting
Dim gpsin(70) As Byte  'Array
Dim cnt As Byte
Dim x As Byte

WaitMs 100  'let things settle

startup:
Lcdinit LcdCurBlink
Lcdcmdout LcdClear
WaitMs 5000  'Give everything time to power up 5 seconds?



Hseropen 4800

times_sent = 0
start:
For i = 0 To 21  '21
ch = LookUp("M0TVU RTTY TEST BEACON"), i  'M0TVU RTTY TEST BEACON
Call convert_char(ch)
Next i

ch = 13  'Carriage Return
Call convert_char(ch)

If times_sent = 4 Then  '4
'---------------- READ THE GPS INFO
	Gosub read_gps
	
Else
	times_sent = times_sent + 1
Endif
Goto start
End                                               

Function convert_char(chr As Byte) As Byte

Call rtty_txbit(0)  'start Bit

For j = 0 To 7  'ascii-7 / ascii-8
	If chr.0 Then
		Call rtty_txbit(1)
	Else
		Call rtty_txbit(0)
	Endif
chr = ShiftRight(chr, 1)
Next j

Call rtty_txbit(1)  'stop Bit
Call rtty_txbit(1)  'stop Bit

End Function                                      

Function rtty_txbit(b As Bit) As Bit

If b = 1 Then
'High
	High txcr_pin
Else
'Low
	Low txcr_pin
Endif

WaitUs 20000  '1/50th of a second = 50 Baud? -20000
End Function                                      

read_gps:
'---------------- READ THE GPS INFO
ch = "x"  'anything other than 0x0d - cr
RCSTA.CREN = 0  'flush
RCSTA.CREN = 1  'the buffer
cnt = 1
While ch <> 0x0a  'keep loading characters until you see lf
	If RCSTA.OERR = True Then
		Lcdcmdout LcdLine4Pos(1)
		Lcdout "OVERFLOW!"
		times_sent = 0
		WaitMs 4000  'show the display for 4 seconds
		Return
	Endif
	Lcdcmdout LcdLine1Pos(1)
	Lcdout "Count = ", #cnt
	Hserin ch
	Lcdcmdout LcdLine2Pos(cnt)
	Lcdout ch
	gpsin(cnt) = ch
	cnt = cnt + 1
Wend

If gpsin(12) = 0x30 Then  'ascii 0 - No Satelites found
	For i = 0 To 15  '15
		ch = LookUp("No Satellite Fix"), i  'No Satellite Fix"
		Call convert_char(ch)
	Next i
	times_sent = 0
	Return
Else
	WaitMs 100  'take a breather
	Gosub send_time
	'Gosub show_north
	'Gosub show_west
	'Gosub show_alt
	times_sent = 0
	WaitMs 4000  'show the display for 4 seconds
	Return
Endif



Return                                            
send_time:
For x = 7 To 14
	ch = gpsin(x)
	Call convert_char(ch)
Next x
Return

I guess the bit causing problems is here...

Code:
read_gps:
'---------------- READ THE GPS INFO
ch = "x"  'anything other than 0x0d - cr
RCSTA.CREN = 0  'flush
RCSTA.CREN = 1  'the buffer
cnt = 1
While ch <> 0x0a  'keep loading characters until you see lf
	If RCSTA.OERR = True Then
		Lcdcmdout LcdLine4Pos(1)
		Lcdout "OVERFLOW!"
		times_sent = 0
		WaitMs 4000  'show the display for 4 seconds
		Return
	Endif
	Lcdcmdout LcdLine1Pos(1)
	Lcdout "Count = ", #cnt
	Hserin ch
	Lcdcmdout LcdLine2Pos(cnt)
	Lcdout ch
	gpsin(cnt) = ch
	cnt = cnt + 1
Wend

If gpsin(12) = 0x30 Then  'ascii 0 - No Satelites found
	For i = 0 To 15  '15
		ch = LookUp("No Satellite Fix"), i  'No Satellite Fix"
		Call convert_char(ch)
	Next i
	times_sent = 0
	Return
Else
	WaitMs 100  'take a breather
	Gosub send_time
	'Gosub show_north
	'Gosub show_west
	'Gosub show_alt
	times_sent = 0
	WaitMs 4000  'show the display for 4 seconds
	Return
Endif



Return
i'll do a video so you can see exactly what it looks like and whats happening.

Regards - Paul
 

SwingeyP

Member
So, Conclusions of last nights and tonights work. The buffer is just too small to hold all the data being presented to it. No matter what I do it always overflows.

Take 2 steps back

Why load all the data in one go? - (I think people have been trying to tell me this)

EUREKA!!!!!!

I decided to just read the data from the GPS and get that working.

Here's the code - It's scrufy and certainly needs a function or two but it actually works ... The LCD is displaying data from the GPS. - 1 week and 1 day - not bad for an idiot.

Code:
'- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
'Just read the GPS written by paul swingewood
'March 2013   - PIC 16F628A
'--------------------------------------------------------------------------

Define SIMULATION_WAITMS_VALUE = 1

'No Fix - added CR
'$GPGGA,,,,,,0,,,,,,,,*66

'Fix - added CR
'$GPGGA,183238.0,5233.736,N,00153.799,W,1,5,1.28,00 177,M,048,M,,*7B

Define CONF_WORD = 0x3f50  'Internal Oscillator'
Define CLOCK_FREQUENCY = 4
AllDigital

'Define the comms for the LCD display.
Define LCD_LINES = 4
Define LCD_CHARS = 20
Define LCD_BITS = 4
Define LCD_DREG = PORTB
Define LCD_DBIT = 4  'Use the high order bits'
Define LCD_RSREG = PORTA
Define LCD_RSBIT = 2
Define LCD_EREG = PORTA
Define LCD_EBIT = 0
Define LCD_RWREG = PORTA
Define LCD_RWBIT = 1
Define LCD_READ_BUSY_FLAG = 1


Define LCD_COMMANDUS = 5000  'delay after LCDCMDOUT, default value is 5000
Define LCD_DATAUS = 100  'delay after LCDOUT, default value is 100
Define LCD_INITMS = 20


Define SEROUT_DELAYUS = 1000



Dim buffer(10) As Byte
Dim sepchar As Byte
Dim ix As Byte
Dim i As Byte
Dim char As Byte
Dim pos As Byte
Dim field As Byte

startup:
Lcdinit LcdCurBlink
Lcdcmdout LcdClear
WaitMs 2000  'Give everything time to power up 2 seconds?



Hseropen 4800  'open hardware serial comms
sepchar = ","  'set the separator character, in this case a comma

Lcdcmdout LcdLine1Pos(1)
Lcdout "Time : "
Lcdcmdout LcdLine2Pos(1)
Lcdout "Lat : "
Lcdcmdout LcdLine3Pos(1)
Lcdout "Long : "
Lcdcmdout LcdLine4Pos(1)
Lcdout "No of Sats : "

readgps:
field = 0
char = 0xff  'set char to something other than the separator or '*'
While char <> "*"  'continue this loop until we read in a '*' character
Gosub getsubstring  'call the parsing subroutine

'we now have the next substring in buffer, with its length in ix

If field = 1 Then
For i = 0 To ix  'so, for the length of the substring...
	pos = i + 8
	Lcdcmdout LcdLine1Pos(pos)
	Lcdout buffer(i)  '...output a character...
	buffer(i) = 0  '...clear the buffer element...
Next i  '...and go on to the next one
Endif

If field = 2 Then
For i = 0 To ix  'so, for the length of the substring...
	pos = i + 7
	Lcdcmdout LcdLine2Pos(pos)
	Lcdout buffer(i)  '...output a character...
	buffer(i) = 0  '...clear the buffer element...
Next i  '...and go on to the next one
Endif

If field = 4 Then
For i = 0 To ix  'so, for the length of the substring...
	pos = i + 8
	Lcdcmdout LcdLine3Pos(pos)
	Lcdout buffer(i)  '...output a character...
	buffer(i) = 0  '...clear the buffer element...
Next i  '...and go on to the next one
Endif

If field = 12 Then
For i = 0 To ix  'so, for the length of the substring...
	pos = i + 12
	Lcdcmdout LcdLine4Pos(pos)
	Lcdout buffer(i)  '...output a character...
	buffer(i) = 0  '...clear the buffer element...
Next i  '...and go on to the next one
Endif


Wend
'RCSTA.CREN = 0  'flush
'RCSTA.CREN = 1  'the buffer

Goto readgps
End                                               


getsubstring:  'this is the parsing subroutine
While char <> sepchar  'while we are not reading the separator character...
If RCSTA.OERR = True Then
		RCSTA.CREN = 0  'flush
		RCSTA.CREN = 1  'the buffer
		Lcdcmdout LcdClear
		Lcdcmdout LcdLine2Pos(5)
		Lcdout "OVERFLOW! - 1"
		Halt
	Endif

Hserin char  'get the next character
Wend

'we have now read the separator, so the next char is the start of the substring

ix = 0  'zero our buffer index
char = 0xff  'and set char To something other than the separator

While char <> sepchar  'while we are not reading the separator character...
If RCSTA.OERR = True Then
		RCSTA.CREN = 0  'flush
		RCSTA.CREN = 1  'the buffer
		Lcdcmdout LcdClear
		Lcdcmdout LcdLine2Pos(5)
		Lcdout "OVERFLOW! - 2"
		Halt
	Endif

Hserin char  'get the next character
If char = sepchar Or char = "*" Then
field = field + 1
Return                                            
Endif  'if it's a terminator, return

buffer(ix) = char  'otherwise, put the character into buffer...
ix = ix + 1  '...and bump the index
Wend
Return
I'm not fully out of the woods yet but I now have a much clearer understanding of what's going on and more importnatly how to fix it.

I would like to thank all the people that helped me get this bit going. I have been out of my depth at times with this but I have learned plenty.

Thanks

Regards - Paul
 
Status
Not open for further replies.

EE World Online Articles

Loading

 
Top