I am new to serial communication and I have two questions:
1-what is the difference between using | and & when stepping control flags?
2- How to configure an existing termios structure “options” to comply with 6O2 serial port configuration?
Thank you!
Related
I have a created two different virtual interfaces by using iw utility commands "iw wlan0 interface add p2p0 type managed", i can able to create and configured as SoftAP using hostapd. We can make it that interfaces up and we can able to get the beacon frame also. if do manual hardware reboot sometime the SoftAP name is not discovering in the WIFI scan list but the beacon frame data received in sniffer logs.
If you guys have an idea please suggest to solve this issue.
Is there a way to know how many inbuilt serial ports are available?. We can enable or disable these ports, when the vxworks image is built. For example, if I give command /devs it lists /tyCo/0 and /tyCo/1. I want to know is there a way to know that there are 2 inbuilt serial ports available.
I have here a unit of King Pigeon S275 Remote Terminal Unit..
this RTU has communication modules for GSM, GPRS and TCP/IP (via RJ45 connection)
I can also communicate with this RTU by connecting it to my computer via USB .
The Manual I uploaded in this link...
https://www.mediafire.com/?gnfzfz5l7pess1p
This RTU can be configured using a configurator Software that is included in the purchase. By using that configurator software, you can also see the data/readings of all sensors connected to it, you can also see the status of all Digital Input/contacts connected to the RTU...
I have been researching about MODBUS the past days and I would like to create my own MODBUS program so that the S275 RTU can also send the sensors' data, or all the I/O data to my own program....
However ... I still do not know where I can start ...
Can I make this Modbus Program
1. using VB?
2. using PHP?
What other parameters do I need to know ?
and tutorials for making this modbus software...
I also uploaded here the S275's;
1. GPRS Custom Protocol
2. MODBUS TCP Handshake Communication Protocol
3. Register Address
https://www.mediafire.com/?khnfu53a4p12nrd
Thanks
PHP and ModBus sounds challenging. You want to control a serial port via PHP.
The easiest way is to get/purchase a library for ModBus/RTU.
Otherwise you have to implement the whole protocol by yourself from http://www.modbus.org/specs.php
You can use nmodbus API to add how reference in your VB or C# project.
There you have the manual.
Supports serial ASCII, serial RTU, serial over USB ASCII, serial over USB RTU, TCP, and UDP protocols.
These kinds of RTU’s are pretty inexpensive which means your greatest cost will be the time you will spend developing and debugging a driver. With that in mind I would first check if the RTU comes with its own OPC Server. Implementing an OPC client in C# or vb.net is very straight forward with plenty of code example out there. Some examples can be found here:
https://opcfoundation.org/developer-tools/developer-kits-unified-architecture/-net-stack-and-sample-applications/
If the RTU does not come with its own OPC server then, you can purchase a Modbus OPC Server from $900 to $2000 which will still be much more cost effective than writing and debugging your own driver and tends to be easier to setup. It will also significantly reduce the time to deliver your solution to your end customer which will be important if keep to project schedule is critical. I would check out, https://www.kepware.com/ and http://www.matrikonopc.com/
The other advantage of OPC is that it is a standardized interface which means should the RTU be replaced with a different model that supports a different protocol you would only have to purchase a new OPC server without the need to update your source code.
If the RTU does not have an OPC server or spending up to $2000 also not an option then there is plenty of open source implementations of the Modbus protocol, however implementation tends to be a bit more complex.
No problem, I used PHPModBus in several projects and it works like a charm!
This library supports Modbus TCP and UDP.
Try it, it is quite easy and straightforward.
i'm creating a windows form to send/receive data to/from serial port.
At first : i send the data as string to the serial port .
Second: i tried to read the string again for test the successfull transmission , but i recieved empty string
this is my code :
Try
Dim SerialPort1
As New SerialPort("Com1",9600, Parity.None, 8, StopBits.One)
SerialPort1.Open()
SerialPort1.DtrEnabled=True
SerialPort1.WriteLine("This is my test message ." )
' ================= Read from serial port
Label1.Text=SerialPort1.ReadExisting() ' this returns empty string
Catch ex As Exception
MessageBox.Show(
"Error writing to serial port:" & ex.Message)
Finally
SerialPort1.Close()
End Try
i need to ask another question:
is it required to connect device to serial port to send/recieve data successfully ????
please i need an urgent help
thanks
As Heinzi already mentioned, if you want to see data you need to have some coming in. There is no automatic echo of data you send out.
To answer your other question: Yes, you need to have another device connected to your serial port in order to send/receive data successfully. With no other device, what would be the point?
Fortunately for you, the "device" you connect can be as simple as a plug with some wires. Here is a set of instructions and diagrams for building a so-called loopback plug: http://www.airborn.com.au/serial/rs232.html
This will allow you to echo your output to your input using very simple hardware. If you're not into soldering up your own plug, you can use a so-called breakout box or board. Here's an example: http://www.breakoutboxes.com/D-Series-9-Position-Breakout-Board_p_31.html .
ReadExisting returns the data sent by the device you are communicating with, not the data sent by you.
You could try to use com0com for generating a virtual serial port pair, then you can rename one of these virtual ports to common name like "COM4". You should open other SW like hyperterminal for serial communication, then set to open the remaining port from the pair.
You may try to use com0com fist with two hyperterminals.
You will need a device through which your application will send and receive data.
For testing, you might consider creating a virtual serial port with software like this Virtual Serial Port Driver. It allows you to create serial ports that aren't actually connected to any physical device. You can then debug your program with another program or with something like HyperTerminal or PuTTY.
Assuming you have a loopback plug (simply connect pins 2 and 3 together) so that anything you send is immediately received.
However - you need to consider that the RS232 is slowly. ("S L O W L Y") and the transfer happens asynchronously so your program is hitting the readexisting long before the data has even been sent. So you're reading an empty buffer.
Just for the sake of your test you need to put some delay in there. so that you can wait a moment after sending before trying to receive.
In a real application though you'd use the receive event to read the serial port.
The company I work for makes hardware that communicates to the computer though a serial port. Third party companies write software that communicates with our hardware.
There are times when I need to diagnose our hardware. However, a third party software app connects to the serial port when Windows starts up, blocking any other connection. I don't know the name of this application/service and it's not always the same one.
Is there any way to either:
Find the name/pid of the app/service that is currently using a given serial port or
Steal the serial port connection from another app.
vb.net preferably, but I'll take a language agnostic answer as well.
You can use the process explorer tool also from SysInternals to search for open handles. In this case you would want to search for 'Serial' since it uses device names that may not map to com port numbers. (e.g. COM1 is \Device\Serial0 on my system).
If you want to take control of the serial port from another app I think you would need co-operation of the driver.
As Rob Walker said, you can find who's using a serial port using Process Explorer. Most of the time, typing Ctrl+F and searching for "serial" will show you who has a serial port open, but I just ran into a situation where my "COM3" serial port's handle appeared as "\Device\VCP0". It may be strange because it was running under VirtualBox with a USB-to-serial connector.
If searching for "serial" and "device\vcp" don't get you any results, you may be able to figure out how serial port handles are named by opening one with a known program. In Process Explorer, display the lower pane with each process's open handles by typing Ctrl+L. Click on the process that you used to open the serial port and look through the lower pane to see which handles look like they might be a serial port. You can open and close the port while you're looking, and the file handle should appear and disappear, as well as being highlighted in green or red. Of course, this is only possible if you have more than one serial port or the serial port you're trying to diagnose isn't always locked by some mystery process.
Sysinternals has a slew of utilities I find very useful and educational for tracking down what processes are doing to the system.
They have a utility that does exactly what you need called Portmon, and give some information on how it works near the bottom of the page. That info and a few well-asked questions will probably give you everything you need to implement it yourself if the utility isn't enough.
-Adam