Scripting in Br@y's terminal

Go To Last Post
22 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

< title of thread edited in order to cover the contents - Plons >

hello,
i would like to insert an auto timer macro in my bray's terminal 1.9.
i want this macro switches with DTR and RTS each 5 or 10 minutes for example.

i would like you help me because i get some problems with the syntax and the language used.
Here is the help :

DB9 PINOUT on PC:
1 - CD - Carrier Detect (IN)
2 - RX - Data Receive (IN)
3 - TX - Data Transmit (OUT)
4 - DTR - Data Terminal Ready (OUT)
5 - GND - Ground
6 - DSR - Data Set Ready (IN)
7 - RTS - Request To Send (OUT)
8 - CTS - Clear To Send (IN)
9 - RI - Ring Indicator (IN)

HOT KEYS:
F1 - send macro #1
F2 - send macro #2
F3 - send macro #3
F12 - clear Rx box

HOW TO USE MACROS?
In macros you can use all characters from keyboard and any ASCII char if
you use $xx or #xxx. Where $xx is hex and #xxx dec format of ascii code.
If you want to use # or $ char in macro you should type it twice ($$=$ and
##=#).
To calculate XOR checksum byte use !XOR command.

Macro examples...

example 1.
abcdefgh123456 - this will send 'abcdefgh123456'

example 2.
AT#013#010 - this will send AT and "CR" + "LF" (cariage return + line
feed)

example 3.
X1##Y2##Z3##$0D$0A - this will send 'X1#Y2#Z3#"CR""LF"'

example 4.
$$value=123$0D - this will send '$value=123"CR"'

example 5.
$01$02$03$04$05!XOR - this will send $01 $02 $03 $04 $05 and
calculated
XOR byte $01

Macro string can be up to 128 characters long.

SIMPLE SCRIPTING (experimental) - NEW!

- pascal syntax

Random(range: Longint): Longint - return random number in range
Beep() - sound signal
Delay(ms: integer) - simple delay (milli seconds)
ShowMessage(s: string) - show message box

ComSendchr(c: byte) - send one byte
ComSendstr(s: string) - send string
ComSendmacro(s: string) - send macro like string ($xx,#ddd,!XOR,...)
ComReadchr() - read curent char/byte
ComBaud(s: string) - set baudrate...'9600','19200',...
SetRTS(state: boolean) - set or clear RTS line
SetDTR(state: boolean) - set or clear DTR line

Graph_Rx(enable: boolean) - enable/disable Rx graph
Graph_Text(x: integer; y: integer; text: string) - print text on graph
Graph_Clear() - clear graph
Graph_Point(x: integer; y: integer; color: string) - Plot point on graph;
color:
'R' - red
'G' - green
'B' - blue
'0' - white
'1' - black

it's not so helpfull for me... my tries were not conclusive. i'm not an expert in programming, i'm a chemist, but it could be very usefull for me and my work.

kurt

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It's an interesting feature. I did make some progress ..... and grabbed a 1980 book on Pascal. It's a lot of trying and testing.

Fwiw: it would be much simpler using an AVR for that task ;)

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay, ... done.

Unzip the attachment, put it in the Br@y-folder, start Br@y, choose your Com, click connect, click Script, click Open, choose kurtabar3.tsc, read through the code: there is a place where you define the On- and Off-time, in minutes and seconds. When you altered the values, save the script.
Now click Run. It will continue until you hit the Stop-button.

Note that the indicator for RTS and DTR do not respond to the script: but the actual control-lines do :)

The supplied script is for RTS only. But it's not very hard to get DTR in as well, but I leave that to you.

Have fun !

Nard

Attachment(s): 

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, that's nice!
thanks a lot!

anyway, i want the RTS button goes on- when the DTR button goes off-
so, can i write the same procedure (from "SetRTS(true)" to the second " i:=i-1;" ) for the DTR line and put it before "SetRTS(true);" , i don't need an other procedure or variable ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
anyway, i want the RTS button goes on- when the DTR button goes off-
It's not clear to me what you mean. RTS and DTR are not buttons, they are signals.
Use PM if you want to explain in German. If you can do it in English you can post here :)

Edit:
Oops, I see you're not from Germany ... the name Kurt made me think so. My czech is bad ....
And in your explanation, try to describe the function, not the details (yet)

Edit2:
Aha, you want the signals to be opposite of eachother ?!

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yeah sorry, i meant 'signals'...
...
no, i'm neither german nor czech :)
ok, you got me i'm in czech republic but i'm french!
i'm working in cz
...
exactly, i want the signal to be opposite of eachother!

i'm working on a specific spectrophotometer for photochromic compounds. it will help me to control the shutting and the opening of a gap which opens toward a UV light.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
ok, you got me i'm in czech republic but i'm french!
i'm working in cz
:lol:

Quote:
i'm working on a specific spectrophotometer for photochromic compounds. it will help me to control the shutting and the opening of a gap which opens toward a UV light.
You may need a little delay between the two signals then. The shutter needs some time to close from open position and vice versa.

Yes, you can add SetDTR(true) right before (or after) SetRTS(false). And a simular procedure for the other state.
You don't need extra variables.

Have fun !

Edit: oh, one more thing: in the initial state (so right after starting Br@y), both signals are false.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, i think it's clear now.

so, i wrote that after the notification of the variables:

begin
// Assign a value here: 1 second per on- or off-state is the minimum
dtr_on_min:=0;
dtr_on_sec:=4;
dtr_off_min:=0;
dtr_off_sec:=2;

j:=1;
Writeln(string1);
while j<>0 do
begin

SetDTR(true); SetRTS(false);
Writeln('DTR on'); Writeln('RTS off');
//Beep();
i:=60*dtr_on_min;
i:=i+dtr_on_sec;
while i>0 do
begin
Delay(1000);
i:=i-1;
end;
SetDTR(false); SetRTS(true);
Writeln('DTR off'); Writeln('RTS on');
//Beep();
i:=60*dtr_off_min;
i:=i+dtr_off_sec;
while i>0 do
begin
Delay(1000);
i:=i-1;
end;
end;
end.

yeah, i know that there is a delay between the signals, but it doesn't matter because it too little compare with the times i will use (about 5/10 minutes... even more)
i only hope this delay won't grow...

tell me if it looks ok!
i gonna test it soon.
;-)
thanks again

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
tell me if it looks ok!

Try it. I am no guinea-pig.
If there is an error in the code, the script will hold and report. I have seen many errorcodes when I tried sorting out how the scripting works.

If you use Code-tags when posting here on freaks, your code looks much better !
And I'd rather use one line per statement.

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

i tried it today for my tests and it works.
may be, i will improve the script to count how many cycles are done.

thanks a lot for your help!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're welcome !

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi guys,
Sorry to pile on this thread.I use Br@y (v1.9b) quite frequently too and now want to try scripts.
I just tried

program test;
const string1 = 'MyString';
begin
  Writeln(string1); 
  SetRTS(true);
end.

Should this set RTS on and output "MyString" It shows MyString in the debug window.
But nothing happens on the terminal window!
I am trying to make an emulator for my trials. For example if I get an AT on my machine it should reply with an "OK"; and so on. Is this possible with Br@y ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Should this set RTS on and output "MyString" It shows MyString in the debug window.
But nothing happens on the terminal window!

That's exactly what it should do :)
If you want output in the terminal-screen in the sent-window, you need to use a Macro *in* your script, or use ComSendstr(s: string).
But I see a problem with reading characters: scripting can do "ComReadchr() - read curent char/byte" but has nothing for reading a string.

But for me this is the first time I fiddled with scripting in Br@y's Terminal. So there may be a work-around, but not that I know of.

AT
OK .... use a modem ! :lol:

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If you want output in the terminal-screen in the sent-window, you need to use a Macro *in* your script, or use ComSendstr(s: string).

Ok,I assume this would output it physically on the serial port too(which is what I want).BTW is there a manual or something with these function listed :) ? If not where did you see these functions ( procedures ? ).I am a C coder .Any way to toggle the RTS pins physically using these functions.

Quote:

But I see a problem with reading characters: scripting can do "ComReadchr() - read curent char/byte" but has nothing for reading a string.

Well,I am too new to Br@y.Maybe I am looking for too much.

AT
OK .... use a modem !
Trying to save some silver till the last minute :oops:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
BTW is there a manual or something with these function listed Smile ? If not where did you see these functions ( procedures ? )
In the upper left corner of the screen, the third button is the Help-button. Scroll down in the fixed-size Help-window.

I did most of my findings with trial and error. I am an old debugger ;)

For instance:

SetRTS(state: boolean) - set or clear RTS line

So I used SetRTS(1) to set the RTS line. But that caused errors, with a description like "Typemismatch error 203" or so.
So I defined a variable "true" and got "variable already defined" That was an interesting response, so I tried

SetRTS(true); //or
SetRTS(false);

And that worked.
It's not a very nice script (structurewise) I wrote for kurtabar, but you can imagine that after 2 hours of trial and error (mostly errors), I was glad it finally worked.
Oh, ... and I took and old Pascal-book of the shelf. That helped too ;)

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Nard,

Thanks for your responses. Well I tried it again.
But nothing happens in the window viz.the RTS button does not go green and nothing is shown in the transmitted window too. But a loopback test shows the received characters and checking the voltage shows it toggling the pin.
Is this how it works with you too ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On the indicators: I mentioned earlier:

Quote:
Note that the indicator for RTS and DTR do not respond to the script: but the actual control-lines do :)

I checked the script with my home-brewed RS232 analyzer: 4 bi-colour-leds with resistors in series. I think I used 1k5 or 2k

I haven't tried other things in the script than I posted for kurtabar. Try that first, see what it does, and then try your own version.

Remember, I had to discover this all using trial and error method.

But still: Bray did a wonderfull job on this terminal-program. He deserves the donation I sent for 100% :)

If you don't post your script, how do you expect me to answer a question like:

Quote:
Is this how it works with you too ?

Nard

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If you don't post your script, how do you expect me to answer a question like:

This is what I tried.As I said it works physically but nothing comes up on the transmit window and the RTS green button.

//******************************
// Terminal Script
// Created: 7/17/2009 3:39:10 PM
//******************************
program test;
const string1 = 'MyString';
begin
  Writeln(string1);
  ComSendstr(string1);
  SetRTS(true);
end.
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are we in the clear on the indicators ? I noted that twice in this thread.

Writeln(string1); writes to the debug window
ComSendstr(string1); transmits from the terminal (= your PC), so if you want to see that message, use either loopback (but you tried that already), or a second PC.

Your script runs once. Are you aware of that ?

------

Another thing: it will most likely not be possible to emulate a modem with Br@y. The why I explained earlier.

Consider to use an AVR as fake modem. It's not rocketscience IMHO. And when done, you can use that faky modem for other purposes.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi, you say that is better to make it with avr, may you help me with some examples ,thanks

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have following code in Br@y's terminal scripting attached file, question is if it's posible make same in avr and how to do it

 

 

 

 

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You've woken up a 7 year old thread..

 

No, you probably can't do that as a script in an AVR. You likely won't find a Pascal interpreter for an AVR.

 

If you just want an AVR to perform the UART coms equal to that Pascal script then it is quite possible. All it does is set some transmission parameters and send a few characters with some delays in between. It can be done in any programming language for which there is an AVR compiler.

 

Start by reading up on the U(S)ART functionality for your AVR model.

 

And remember that while a PC serial port has the level translation to comply with the RS232 standard (-3..-15/+3..+15 Volts), the AVR USART has output at logic levels (absolute numbers depends on how the AVR is powered, but typically+supplyvoltage/0V). If the device the AVR is going to talk to is normally communicating with a PC serial port your AVR solution needs to incorporate level and polarity transformation of the AVR USART output. Google "MAX232" for a commonly used chip.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]