• Support
  • Articles
  • Resources
  • Products

Character Translation

Moderator: boris

1 postPage 1 of 1

IshmaelCallMe
Guru

Posts:
676
Joined: Thu Jan 26, 2006 2:28 am
by IshmaelCallMe » Mon Apr 14, 2008 8:14 pm
Thought I would put this here to make it easier to find. Thread that explains history is here:
viewtopic.php?t=699

This is a AutoIT script, but it does stuff for TERATERM.

Code: Select all

  1.  
  2. ;This will insert a pair of sockets between a physical serial port and TTERMPRO to translate characters
  3.  
  4. $n_uplinktable = 3
  5. Dim $uplinktable[$n_uplinktable][2] = [[ 'A', 'B'], ['c', 'd'], ['e', 'f']]  ;will translate 'A' to 'B', etc
  6.  
  7. $pid = Run('C:\Program Files\com0com\com2tcp.exe \\.\COM90 600', 'C:\Program Files\com0com', @SW_MINIMIZE)
  8. TCPStartup()
  9. $phys = TCPConnect('127.0.0.1', 600)
  10. $MainSocket = TCPListen('127.0.0.1', 601, 100)
  11. Run('C:\Program Files\TTERMPRO\ttermpro.exe /nossh 127.0.0.1:601')
  12. Do    ;Wait for and Accept a connection
  13.    $ConnectedSocket = TCPAccept($MainSocket)
  14. Until $ConnectedSocket <> -1
  15. While 1
  16.    $recv = TCPRecv($ConnectedSocket, 1)
  17.    If @error Then ExitLoop   ; If the receive failed with @error then the socket has disconnected
  18.    TCPSend($phys, $recv)
  19.    $recvphys = TCPRecv($phys, 1)
  20.    For $i = 0 To $n_uplinktable - 1   ;Do uplink char translation here
  21.       If Asc($recvphys) = Asc($uplinktable[$i][0]) Then
  22.          $recvphys = $uplinktable[$i][1]
  23.          ExitLoop
  24.       EndIf
  25.    Next
  26.    TCPSend($ConnectedSocket, $recvphys)
  27.    Sleep(1)
  28. WEnd
  29. ProcessClose($pid)    ;kill com2tcp when teraterm disconnects
  30.  

1 postPage 1 of 1

Users browsing this forum: No registered users
cron