I have a Linux application (whose code I have access) which must communicate via serial port with a windows one (third party, no access to code). The windows app runs in Wine, so I want to set Wine's com1 to something and make my software read and write from there. I guess the best way is to use pseudo-terminals, is that so?
Is there a way to simply create a pseudo-terminal pair from command line in Linux? I've already know how to do this using the API, but is there a way to do this from bash?
Maybe with socat or something like it?
You might be able to use something like this (untested):
socat PTY,link=$HOME/.wine/dosdevices/com1,raw,echo=0 PTY,link=$HOME/tmp/dev/myserial,raw,echo=0
This will create two back-to-back PTY's which is a bit of overkill, but socat will copy data between them. The wine program would open one side of the link as COM1, and your program would open $HOME/tmp/dev/myserial to communicate with COM1.
Related
My question is very simple.
How does OSX understands that this special process needs to make output to special terminal? Can we change it?
For example, is it possible to run process via ssh connection (without GUI) and make some system call, and this process will start using OSx GUI
I don't really understand your question, but I suspect you maybe have a look at the "expect" tool, which allows you to start some connection and then let the user continue after you have established the connection. Try:
man expect
in a terminal window.
I have used an script in past that enabled me to connect me to multiple unix machines, much like using a tab. Its just that I forgot the name of the script. Anyone know about it?
I suspect you're referring to GNU screen, which is a terminal multiplexer that allows you to have multiple virtual terminal windows in a single normal terminal window (ala PuTTY). I'd suggest tmux as a better alternative, but they're essentially the same. There are other solutions that will allow you to do tabs in the terminal client, but that depends on your OS (I'm assuming you're on Windows), and you'd have to initiate each connection individually. screen/tmux is the way to go most of the time.
I am writing a small tool, that copies clipboard of linux into windows clip-board. Let me take an example, both linux and windows in network connection. I copy something in linux to clip-board, then when I press some keys in windows lets take CTRL+ALT+v what is copied in linux should print in linux.
What I thought is executing some script in linux from windows through ssh connection. That script shall copy the clip-board into some file in windows, then windows shall put the file content into windows clip-board.
My problem is connection with linux from windows and executing the script. How can I achieve this ?
And please share if you have any better idea to do this.
Thanks a lot :).
There is a free, cross-platform, open-source program called Synergy that does exactly what you are describing (and more), and I have tested it with a Windows/Linux connection. You could take a look at the source code and see how the clipboard functions are implemented, or it might fit your needs already.
My university has quite a lot files (like past papers etc) which I need to be on the uni network to access them. I ssh, using port forwarding, into the network and set my browser (Firefox) to go through that port. I know it would be quite easy to write something in most languages that would enter the command into a terminal, but which language/method could I use to make this happen? I expect some sort of scripting language could but I really know nothing about them, but I'd be willing to learn one just to have a little fun with this.
I'm using a cygwin terminal on Windows 7, if that will make a difference.
To neaten up my question: Which language would be best to acheive the above effect? Not necessarily the best, just possible and relatively simple to learn. I used the word best so I suppose I'll put a subjective tag.
EDIT:
Just in case anyway wants to do this precise thing, I'll show my solution. I ended up using a batch file because a few things made the bash more difficult. Anyway, in order to SSH into the network and open a new firefox window with the proxy changed, I just have to open this batch file and enter my password.
cd C:/cygwin/bin
ssh -fND 9001 username#your.website.here
cd "C:/Program Files/Mozilla Firefox"
firefox -no-remote -P SSH_profile
Save as .bat
In order for this to work you need to set up a profile with name SSH_profile (or whatever) and set the connection settings to go through port 9001. The script will open use the ssh command in /cygwin/bin and enter in the information. You enter your password and then it goes to your firefox directory, uses those arguments which opens a separate profile with the connection settings changed (means you can view unaccessible files in one window and anything else you don't want to be on your uni network in another. Just close the windows when you are done.
Quite a specific case but I thought I'd share my answer in the hope of helping someone, some day.
Since you are using cygwin, write a bash shell script.. If you don't want to rely on bash, powershell would be what you want, although you could probably get it working using a batch file.
This is exactly the kind of thing shell scripting is for.
Edit
You can change the firefox settings on the command line by passing the -override flag. This will let you have special settings for the invoked process.
Is there a simple way of redirecting serial port output to a file, that I can put into place on a test Windows desktop system without changing any code?
I'm trying to debug a problem in a serial receipt printer module and I don't have the real device handy today. I don't want to start making any changes to the code if I can help it, I just want to capture what is currently being output at the moment so that I can review it in a file.
It's Windows XP, if that makes any difference.
Another option is through command line:
type com1: >> data.log
Another option: Use putty and turn on logging.
A quick google led me to RS232 Data Logger - I haven't tried it, but if it does what it says on the tin it should be OK for you. Edit: it appears to be incoming, not outgoing. Might be worth a try though :-)
You could run the printer module in a VM. VMWare allows you to redirect serial ports to files and named pipes.
Similar to VMWare, Virtual PC (& Virtual Server) can also redirect a COM port to a text file and setup is very simple.
I think in the control pandel, printers, you can add manual printer and install dummay one
So you can printing to a file for example
If you are developer use Serial Port component from .NET or if you don't are a developer and only want get information to file use windows HyperTerminal
I don't know if you can redirect COM ports but you can use com0com for that kind of job.
For example, you can pair (COM1, COM2), so you can write to COM1 and read from COM2.