SimTerm, back to basics

For issues with communication ports, protocols, etc.
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: SimTerm, back to basics

Post by dasyar »

This seems to run as expected, hopefully it will run as expected on a Windows compile. I added the ':' in the program, so all you would type in is '/dev/ttyUSB0' if in Linux, NO ':'. For this program, on a Linux box, ./cltest1 /dev/ttyUSB0 115200. Ah just thought of something, what if somebody types in ./cltest1 115200 /dev/ttyUSB0, what happens then?

It seems like there is less code that has to cover for the Linux Windows differences, but you now have external control over the port and BAUD rate selection. Again, this is a command line program. Since FBC creates a program icon, I tried to see if, in properties, you could add the parameters, but in Linux, it does not allow you to do that. The other option is to create a bash or bat file that will start the program with your parameters. Since the program contains the GUI code, when you start it in the command line, it will open up another window running the program.

Now I have to figure out what to do about the cursor control, should I create another terminal screen area, with a functional cursor. Which leads me to another thought. If I have another terminal screen area, is it possible to create a screen capture for a log file when needed? Then the next step, cut and paste, in the terminal screen area. Now I am really not sure if FBC can accomplish this.

My aim, a nifty, functional little serial terminal program that is written in FBC, is that possible?

Code: Select all

'cltest1.bas
' March 16, 2016
' Test for command line parameters

' For GUI desktop
Screen 12
Width 80,30

Dim As Integer i = 1

Dim As String arg1 = Command(1)  ' Comm port
Dim As String arg2 = Command(2)  ' BAUD rate

Dim As String Key,buffer

' Check for command line parameters
If arg1 = "" Then
	print "Usage : SimTerm port baud"
	Sleep 2000:Cls : Close : End
else
	Open Com arg1 & ":" & arg2 & ",n,8,1,cs0,ds0,cd0,rs" As #1
End If
If Err Then
	Print "Error opening ";arg1;
	Sleep 2000 : Cls : Close : End   ' Don't use GoTo !!!
Else
	Print "Open Port: " & arg1 & " Baud: " & arg2
End If

Print "SimTerm, a simple Terminal Program. [Esc] to quit Program."  _
        ' also X click !
        
'main serial send/receive routine
Do
	Key = Inkey
	If Key <> "" Then    ' [Enter] is also sent ! (so, no check needed !)   
		Print #1,Key;     'Send the char
		Print Key;        'This is the echo
	End If
    While Loc(1) > 0
        buffer = Input(Loc(1),#1)   'Grab a char
        Print buffer; : buffer = ""   'Print the char : clear Buffer
    Wend
	Sleep 10,1
Loop Until key = Chr(255,107) OrElse key = Chr(27)



Close: End
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: SimTerm, back to basics

Post by MrSwiss »

dasyar wrote:Again, this is a command line program.
No, it is a GUI-Program.
The Term "command line program" refers to Console-/Terminal- Screen Output, without any "Graphics-Screen".

BTW: any Program can be started from Command Line ... e.g. vi, with File to be edited, as Parameter.
Since the program contains the GUI code, when you start it in the command line, it will open up another window running the program.
As you've observed yourself.
Ah just thought of something, what if somebody types in ./cltest1 115200 /dev/ttyUSB0, what happens then?
It is your Responsibility, as a Programmer, to handle such Things, e.g. pop up a relevant Message to the User.
dasyar wrote:Now I am really not sure if FBC can accomplish this. My aim, a nifty, functional little serial terminal program that is written in FBC, is that possible?
Yes, FB can do all those Things! Your Question is wrong.
The correct Question would be: can you, as a Programmer, handle it?
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: SimTerm, back to basics

Post by dasyar »

The correct Question would be: can you, as a Programmer, handle it?
Well, when you put it that way, NO. Maybe I will just sit back and wait for somebody else, that can "handle it", do it. I think I made a big mistake.
MrSwiss
Posts: 3910
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: SimTerm, back to basics

Post by MrSwiss »

dasyar wrote:Maybe I will just sit back and wait for somebody else, that can "handle it", do it.
That will probably never happen.
dasyar wrote:I think I made a big mistake.
It is NEVER a mistake, to learn something new ...
But, you should NOT (as the Title of this Thread suggests) try to appear more skilled, than you are.

REASON: The answers you are getting, are geared towards the skill level you seemingly have.
So, you won't understand them, when People "overestimate" your know-how.
The proper Platform to post for you, would be: Beginners.
Easier, better to understand advice will (hopefully) be the Result.

This then, will get you "off the Ground" far quicker.
dasyar
Posts: 372
Joined: Dec 04, 2008 15:31

Re: SimTerm, back to basics

Post by dasyar »

But, you should NOT (as the Title of this Thread suggests) try to appear more skilled, than you are.
Hmm, interesting interpretation. You are absolutely right, my mistake was to post my code and ask some questions. So, I will no longer post my code, consider this thread, dead. I will wait for somebody else to post there example code and let other people ask the questions, problem solved.
Post Reply