writing signals to serial port - c#

I am trying to write data to a DMX receiver via USB to RS485 cable. I can see the correct data frames, but for the packet to follow the DMX protocol, I need a break and MAB signal. So my question is, is there a way to generate such signals? My thoughts were to write hi and lo signals with delays to the serial port but I have not found a way to do this in VS C#.

There is an example (though not in .NET but you can translate it) here:
How to control DmxSimple over serial
And use the SerialPort class to send the data down your cable

Related

C# usb serial port Listener

okey, i have been working on this for some time now.
i am trying to create a Serial COMS listener to read HEX Bytes from car CanBus system.
the OBD cable drivers are originally using a "FTDI" chip which i have the APK for,
my implementation allowed me to only read several bytes before the APK would freeze the app..
So i scrapped that, i moved on to Implementing BUSDOG USB Driver filter.
which i implemented into .NET6.
yes i was able to get a read out finally, but the Driver signing is very old and causing Windows ALL HID Devices to stop working as the BUSDOG driver is hooked as a LowerFilter driver, so that is very unstable..
my question is, What is the best and easier route to go about this?

C# serial port outgoing traffic sniffing

I've been looking around quite alot for a way to sniff outgoing traffic on a serial port.
The reason I want to do that is to be able to sniff and decipher message Im sending from another app I have.
There are apps that allow sniffing on a serial port without blocking it from other apps (I usually use free serial port monitor).
Is there a way to do that with C#?
Thanks

Is it possible to simulate com port sending and receiving data using only C# programming?

I have a device which sends data by com port on my computer.
I know how to simulate it, but the controller must be plugged in to simulate sending data (using Proteus)
Is it possible to simulate the com port sending data without having any external device plugged in?
For example: I want to write a C# program which opens the com port and waits for data, and another c# program which writes data on the same port.
The best way to do this is to use a software COM port emulator. I use com0com :
Null-modem emulator
This provides virtual NM COM port pairs on the system (ie: what is output to one is input to the other and vice-versa). The devices show up in Device Manager just like a real COM port so you interact with them in C# as though they were real hardware devices.
For simplicity's sake, get yourself a com port or null modem emulator. You'll get very far off track, and maybe waste a lot of time, trying to do this yourself.
See this post, too:
Faking an RS232 Serial Port

How to forward packets via C# to another TCPClient running on another port

How can I forward packets using C# to another TCPClient running on another port.
I am new to Sockets programming in .Net. I am trying to make a VNC Repeater much like this perl script: http://snipt.org/wonG but I cannot keep my stream continuous.
An example of what I want to achieve is this:
Port 5500 listens, inspects the packet RemoteEndPoint and then and sends the packet back out on Port 5901.
Because the bulk of the traffic is considered 1 big open stream (it does not close or send chunks of data, it sends traffic for upwards of 10 minutes) how can I do this?
Does anyone have any suggestions or ideas on how to execute a TCPClient packet forwarding solution that supports large open streams(sessions)?
http://tcpsoftrouter.codeplex.com/ Is a good example.
EDIT: Since this time I have written NRepeat. Available here https://github.com/jeremychild/NRepeat

question about PORT

I have written a program in C# that sends text to COMx.
I wish to test it using HyperTerminal, meaning I want to read the text that I send with my program. When I set the WAIT FOR CALL in HyperTerminal, my program is refused access to the given port.
How can I test my program? Is it possible?
The best answer I can give is that the serial port is locked by your program and hence HyperTerminal cannot access the port as it is in use by your program. The best thing is to use a null modem cable loopback device in which you can send data and it will get looped back, like what EricLaw suggests.
Hope this helps,
Best regards,
Tom.
tommieb75 and EricLaw's answers are both right. When an application opens a serial port, the port is opened exclusively and no other app can work with it.
In order to test my serial applications I always use com0com. You can create a pair of virtual linked serial ports and setup your app to write to one of them and the HyperTerminal to listen to the other one.
This tool has helped me countless times. I strongly recommend it.
Take your serial cable and solder in on your RX or TX side of the COM port. Now, connect this to another COM port on your PC. Tada - now you can monitor what you are sending or receiving on this port by listening in on the other. Don't terminate TX on this other COM port so you don't disturb this connection. I have a couple of these cables in the office for this very purpose. I don't trust Serial Port monitoring software.
Your best bet would probably be to put a null-modem DB9 cable from COM1 to COM2 and use COM2 to talk to COM1.

Categories

Resources