Author |
Topic: Serial Port and ESC code (Read 734 times) |
|
tuk091
New Member
member is offline


Posts: 3
|
 |
Serial Port and ESC code
« Thread started on: Jun 26th, 2012, 8:40pm » |
|
Hi All, I am writing a control programme which uses Relays controled via a serial port. Unfortunately i am struggling to get the ESC code sent to the port. I am using a simple piece of code k$=CHR$(27) BPUTS#1,k$
Unfortuately when i use the esc code it does not seen to sent it to the port. If i change it to another character it works fine.
I know the basic RS232 port works as i have tested with test programme.
So i was just wondering if there was anything special i need to know to send an ESC code to the port.
Many thanks for any help in advance.
Regards
viv
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Serial Port and ESC code
« Reply #1 on: Jun 26th, 2012, 9:24pm » |
|
on Jun 26th, 2012, 8:40pm, tuk091 wrote:I am using a simple piece of code k$=CHR$(27) BPUTS#1,k$ |
|
That code will send two characters: an ESC (CHR$27) followed by a Line Feed (CHR$10). To send just a single ESC character you can use a numeric variable rather than a string:
Code: which you can simplify as follows:
Code: or you can add a semicolon to your code to suppress the LF:
Code: Richard.
|
|
Logged
|
|
|
|
tuk091
New Member
member is offline


Posts: 3
|
 |
Re: Serial Port and ESC code
« Reply #2 on: Jun 26th, 2012, 10:03pm » |
|
Richard, Many thanks i give that a try.
Regards
viv
|
|
Logged
|
|
|
|
tuk091
New Member
member is offline


Posts: 3
|
 |
Re: Serial Port and ESC code
« Reply #3 on: Jun 27th, 2012, 05:32am » |
|
Hi Richard It fixed issue . Many thanks
Viv
|
|
Logged
|
|
|
|
Designer
New Member
member is offline


Posts: 2
|
 |
Re: Serial Port and ESC code
« Reply #4 on: Jul 3rd, 2012, 12:12pm » |
|
Viv,
Hi.
Just starting out on BBC BASIC. Can you please share the test program code for sending and receiving a couple of bytes of data.
Regards
Zeb
|
|
Logged
|
|
|
|
admin
Administrator
member is offline


Posts: 1145
|
 |
Re: Serial Port and ESC code
« Reply #5 on: Jul 3rd, 2012, 9:09pm » |
|
on Jul 3rd, 2012, 12:12pm, Designer wrote:Can you please share the test program code for sending and receiving a couple of bytes of data. |
|
Sending code something like:
Code: port% = OPENOUT("COM1:9600,n,8,1")
BPUT #port%,dat1%
BPUT #port%,dat2%
CLOSE #port% Receiving code something like:
Code: port% = OPENIN("COM2:9600,n,8,1")
dat1% = BGET#port%
dat2% = BGET#port%
CLOSE #port% This code waits for the data to arrive. If you need to be doing something else whilst waiting, you can monitor how many bytes have arrived using EXT#port% and only read them when they're ready.
Richard.
|
|
Logged
|
|
|
|
Designer
New Member
member is offline


Posts: 2
|
 |
Re: Serial Port and ESC code
« Reply #6 on: Jul 5th, 2012, 07:09am » |
|
Richard.
Thanks. Will try it out and report.
Zeb
|
|
Logged
|
|
|
|
|