ni.com is currently experiencing unexpected issues.

Some services may be unavailable at this time.

キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

controlling Tera Term from labview

解決済み
解決策を見る


@billko wrote:
That's actually very interesting.  If Tera Term has a development kit, you might be able to do it yourself.

From what I saw it doesn't! The DLLs shown in the OP are just support DLLs for various UI aspects but not the gist of the applications. The main code for both TeraTerm Pro and the TeraTerm Macro application is directly located in the executable. There is some very limited C++ for some Windows GUI handling but everything else is simply standard C so no ActiveX, .Net or whatever modern Windows functionality either.

 

In order to use the TeraTerm Pro and Macro as DLL shared library one would have to significantly rearchitect the source code and also change the whole organization of the source files. Not something that is easily done and has a big chance of causing all kinds of breakage. I would estimate the effort to redesign TeraTerm Macro so it can be used as shared library from LabVIEW and other applications in the same order than rewriting the whole functionality as macro executer in LabVIEW. The only thing where you won't get around to use some sort of compiled external code is for the implementation of SSH. Even (T)FTP can be fairly easily implemented in LabVIEW directly and has been at least for FTP already available in the Internet Toolkit although the implementation in there isn't a good example of how to do it.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 件の賞賛
メッセージ11/17
6,383件の閲覧回数

Thanks for the insights Rolf! I do conceide that I am not a Windows framework expert so I don't even dare to start with Visual Studio. スマイリー ハッピー

 

My main interest in Teraterm Macro is the macro/scripting language itself. They are full-featured and has worked for me for many years.  I do not want to reinvent those in LabVIEW. If I can somehow pipe LabVIEW controls and indicators to the Teraterm Macro DLL's stdin and stdout then half the effort to implement Teraterm Macro as a LabVIEW plugin is complete - or so I hope.

 

From what Rolf described the source is a bit convoluted. From what I can observe, the 'Macro' portion of Teraterm does not depend upon the GUI or widget parts of Teraterm terminal program. Macro is a completely independent executable with its own DLLs. You should only re-build that not the whole Teraterm suite in the source code.

 

Although, you can probably implement all the nice built-in features (RS232, FTP, TFTP, TELNET, SSH, TCP/IP) in LabVIEW, Teraterm Macro already supports all those nicely. If I can only build the functions as statically callable DLL from LabVIEW C function node, that would be awesome!

 

Cheers!

Aldrin

 

0 件の賞賛
メッセージ12/17
6,376件の閲覧回数

I guess what Rolf is saying is that you can either reinvent it as a dll or reinvent it as LabVIEW code.  Either/or, it seems like a rewrite is almost necessary.  Ugh.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 件の賞賛
メッセージ13/17
6,362件の閲覧回数

@billko wrote:

I guess what Rolf is saying is that you can either reinvent it as a dll or reinvent it as LabVIEW code.  Either/or, it seems like a rewrite is almost necessary.  Ugh.


Not a complete rewrite for the DLL but a serious redesign. The problem with this is that it would be programming in C(++) where you don't only have to deal with the actual problem on hand but also about proper memory management and all that stuff, which tends to get tedious and debugging of the actual communication and execution task is very frequently hampered by subtle memory management bugs in your code.

In LabVIEW you would have to start from scratch but you can concentrate on the communication and execution tasks without having to worry about proper memory allocations in the first place. That and the pretty high level APIs that LabVIEW provides make almost any programming task a lot easier in the LabVIEW environment than when programming it in C(++).

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 件の賞賛
メッセージ14/17
6,340件の閲覧回数

Hi Relativity,

 

How can I run a TTL script in the windows command promt? The script can run under the "tera term" console but I cannot run it in the command promt. I'm asking because I would complete command I need to send in the system exe. Please let me know when you have time. Thanks.

 

Regards,

JP

0 件の賞賛
メッセージ15/17
6,097件の閲覧回数

Hi Even, 

I am facing a same issue here and was wondering how you finally control Tera Term from labview? 

 

Thanks a lot! 

Han 

0 件の賞賛
メッセージ16/17
5,826件の閲覧回数

Hi Folks,

 

Sorry for this very, very late follow-up post but my original article got buried under the rubble of articles after NI switched from the old forum and blog system to the current system. I stumbled onto these requests of how I used Teraterm in the command line. I still have no idea how to look-up your own old posts in this new system unless someone replied or kudoed. NI please fix this issue.

 

Now to try to answer the previous questions. If you didn't know, Teraterm Pro comes in two versions in the same installer package. The serial terminal that you can run as an application in Windows [ttermpro.exe] is used just like any serial terminal like Hyperterm or Putty for doing VT/SSH/TFTP queries. The version of Teraterm you will need to use when scripting from LabVIEW is Teraterm Macro [ttpmacro.exe] These executables are typically installed together from the same ZIP or package installer.

System Exec Node (CMD shell) Scripting with Teraterm MacroSystem Exec Node (CMD shell) Scripting with Teraterm Macro

The System Exec node (CMD shell) is used to invoke/call the [ttpmacro.exe] executable and pass the "TTL" script file as the argument. The "cmd /c" option for the System Exec node is optional but here I want the command line window to execute in the background. What I want is the Teraterm macro window dialogs to appear and interact with the operator instead.

 

One script (included in the ZIP file) is a PING test and I am including here as an example. I have included other script examples to load JFFS and uBoot/uImage images.

 

Please note that in my setup, I am pulling the image files from a TFTP server in my local network using the TFTP feature of TeraTerm Pro. Doing this in SSH/SCP may be doable but you would need to add a way to send your credentials to the SSH/SCP server. For local provisioning of engineering boards, SSH/SCP may be overkill. Stick to the simpler TFTP. You can actually install the TFTP server in your local PC provisioning machine so the IP address will be localhost or 127.0.0.1

 

Another important note that I must state: The DUT uses a Linux-based Freescale SoC processor thus needing uBoot, JFFS and uImage provisioned over a BDI RGMII programmer. I am sure this method can be adapted to a Xilinx or Altera setup (if these have no LabVIEW or command line interface included)

 

;  -----------------------------------------
; |               PING test                  |
;  -----------------------------------------
; Parameters (arguments) and CONSTANTS
;
inputbox 'Enter IP Address to PING:' 'Enter  IP#' '192.168.1.1xx'
ipaddress = inputstr
gatewayip = '192.168.1.1'
netmask = '255.255.255.0'
comport = '/C=3'
; ~~~~~~~~~~~~~~~~ Main ~~~~~~~~~~~~~~~~~~~~
prompt = '1) Power-OFF the CPU board.\n2) Disconnect BDI2000 from CPU board.\n3) Attach COM serial cable to CPU board.\n4) Connect CPU board to LAN.'
strspecial prompt
messagebox prompt 'Message'
;
messagebox 'Now apply power to the CPU board.' 'Message'
;
; command line = 'TERATERM /C=1' (COM1 port)
timeout = 30
connect comport
;
;initial boot may take up to a minute to expand JFFS.
wait 'Mounting filesystems'
if result=0 goto noconnect ; failed to connect or bad COM settings
;
prompt = 'Mounting Filesystems.\nThis may take up to a minute on first boot.\nPlease wait...'
strspecial prompt
statusbox prompt 'Message'
;
timeout = 90
wait 'Welcome to Freescale'
statusbox 'Logging into Linux...' 'Message'
if result=0 goto exitprog
;
call ubootprompt
;
call login
;		
call verifylogin
;
call delbr2
;
messagebox 'Plug Ethernet to Port 1 of 4-port LAN switch...' 'Message'
statusbox 'Wait for LAN port to acquire ARP...' 'Message'
call flushipcache
wait 'PHY: e0024520:06 - Link is Up - 100/Full'
call pingtest
wait '-sh-2.05b#'
;
messagebox 'Plug Ethernet to Port 2 of 4-port LAN switch...' 'Message'
statusbox 'Wait for LAN port to acquire ARP...' 'Message'
call flushipcache
wait 'PHY: e0024520:06 - Link is Up - 100/Full'
call pingtest
wait '-sh-2.05b#'
;
messagebox 'Plug Ethernet to Port 3 of 4-port LAN switch...' 'Message'
statusbox 'Wait for LAN port to acquire ARP...' 'Message'
call flushipcache
wait 'PHY: e0024520:06 - Link is Up - 100/Full'
call pingtest
wait '-sh-2.05b#'
;
messagebox 'Plug Ethernet to Port 4 of 4-port LAN switch...' 'Message'
statusbox 'Wait for LAN port to acquire ARP...' 'Message'
call flushipcache
wait 'PHY: e0024520:06 - Link is Up - 100/Full'
call pingtest
wait '-sh-2.05b#'
;
; PING test completed
wait '-sh-2.05b#'
messagebox 'Gojoseon (CPU) board PING test complete.' 'Message'
closett
end
;
; ~~~~~~~~~~~~~~~~ Subs ~~~~~~~~~~~~~~~~~~~~
; Boot and wait for the 'freescale login:' prompt.
:ubootprompt
timeout = 15
wait 'freescale login:'
if result=0 goto exitprog
; send a CR ASCII char x2
send #13 #13
return
; -----------------
; send username/password
:login
sendln 'root'
pause 1
sendln 'root'
return
; -----------------
; Verify if we are logged-in
:verifylogin
timeout = 30
call sendcr
wait 'sh-2.05b#'
if result = 0 goto nologon
return
:nologon
messagebox 'Login not successful.' 'Message'
closett
end
; -----------------
; bring BR2 bridge down first prior to TFTP operations
; shutdown bridge
:delbr2
statusbox 'Stopping and Deleting IP bridge <BR2>...' 'Message'
sendln 'brctl show'
pause 2
sendln 'ifconfig br2 down'
pause 1
; delete eth0 and eth1 interfaces
sendln 'brctl delif br2 eth0'
pause 1
sendln 'brctl delif br2 eth1'
pause 1
; remove bridge entry
sendln 'brctl delbr br2'
pause 1
;
return
; -----------------
; clear route table
:flushipcache
sendln 'ifconfig eth1 down'
sendln 'ip route flush cache'
; now manually assign IP to interfaces
sendln 'ifconfig eth1 10.10.220.251 netmask 255.255.0.0'
; add route to gateway
sendln 'route add default gw ' gatewayip ' dev eth1'
; now bring eth0 and eth1 up.
sendln 'ifconfig eth1 up'
return
; -----------------
; PING server
:pingtest
statusbox 'Sending 10 PING packets.' 'Message'
sendln 'ping -c 10 ' ipaddress #10 ; send 10 PING packets
statusbox 'PING started. Please wait...' 'Message'
wait 'packets transmitted'
wait '100% packet loss' '0% packet loss'
if result=0 then
	prompt = 'Some PING packets were not received.\nPlease manually check LAN port.'
	strspecial prompt
	statusbox prompt 'Message'
	goto badping
elseif result=1 then
	prompt = '100% PING packets were not received.\nPlease manually check LAN port.'
	strspecial prompt
	statusbox prompt 'Message'
elseif result=2 then
	statusbox 'PING test passed on port.' 'Message'
endif
; good ping
send #3 ; send CTRL-C
send 13 10
return
; bad ping
:badping
prompt = 'TFTP server PING was not successful.\nPlease check DUT is attached to LAN from ETH0 port.\nAlso check your TFTP server is serving the correct directory.'
strspecial prompt
messagebox prompt 'Message'
closett
end
; -----------------
; allow LAN Phy negotiations to complete
:waiteth1
statusbox 'Waiting for 4-Port LAN switch (ETH1) to become active...' 'Message'
wait 'br2: port 2(eth1) entering forwarding state'
;wait 'PHY: e0024520:06 - Link is Up - 100/Full'
call sendcrkey
return
; -----------------
:sendarp
arpmsg = 'arping -U'
strconcat arpmsg ipaddress
sendln arpmsg
; -----------------
:exitprog
messagebox 'Timeout reached. Try again...' 'Message'
end
closett
; -----------------
; sends CR and LF to DUT
:sendcr
send 13 10
return
; -----------------
:sendcrkey
; send a CR keyboard char
sendkcode 28 1
return
; -----------------
:noconnect
prompt = 'Serial port connection failed.\nMake sure Teraterm can access serial port.\nMake sure script COM setting is correct.'
strspecial prompt
messagebox prompt 'Message'
end
closett

Cheers!

 

Enjoy RF Engineering!!

Relativity

 

メッセージ17/17
5,057件の閲覧回数