BBC BASIC for Windows
« Serial Port and ESC code »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:13pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Serial Port and ESC code  (Read 734 times)
tuk091
New Member
Image


member is offline

Avatar




PM


Posts: 3
xx 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


User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx 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:
      k=27
      BPUT#1,k 

which you can simplify as follows:

Code:
      BPUT #1,27 

or you can add a semicolon to your code to suppress the LF:

Code:
      k$=CHR$(27)
      BPUT#1,k$; 

Richard.
User IP Logged

tuk091
New Member
Image


member is offline

Avatar




PM


Posts: 3
xx Re: Serial Port and ESC code
« Reply #2 on: Jun 26th, 2012, 10:03pm »

Richard,
Many thanks i give that a try.

Regards

viv
User IP Logged

tuk091
New Member
Image


member is offline

Avatar




PM


Posts: 3
xx Re: Serial Port and ESC code
« Reply #3 on: Jun 27th, 2012, 05:32am »

Hi Richard
It fixed issue . Many thanks

Viv
User IP Logged

Designer
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx 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
User IP Logged

admin
Administrator
ImageImageImageImageImage


member is offline

Avatar




PM


Posts: 1145
xx 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.
User IP Logged

Designer
New Member
Image


member is offline

Avatar




PM


Posts: 2
xx Re: Serial Port and ESC code
« Reply #6 on: Jul 5th, 2012, 07:09am »

Richard.

Thanks. Will try it out and report.

Zeb
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls