Could not get receive sequence from COM port's RX line in docklight - docklight

I used a RS232 to connect my pc and VALHALLA 4300C, and used Docklight software to explore it. I went through a sample project: PingPong.ptp, I followed the instruction and I did not get any data back. I could only see the TX info but not RX info. (NOTE: the reason that I used 4300C is because I just explore Docklight and I can only have access to 4300C for the moment.)
Here is the link to the instruction of the sample project. It is REALLY short.
http://docklight.de/manual/index.html
Any help would be appreciated.

As mentioned, the PingPong example is not suitable for the application you have with the VALHALLA 4300C. The 4300C will not respond to a "Ping" text it does not understand.
Here is how I suggest you get started communicating with your VALHALLA 4300C from a Windows PC.
Start Docklight (but also any other plain text terminal like Realterm, Teraterm oder YAT should work, of course).
Select the COM port number that is your actual RS232 interface on your PC. (Docklight displays a dropdown list of available ports and their descriptions.)
Set the serial port settings to 9600 baud, no parity, 8 data bits, one stop bit (see the Valhalla 4300C Manual on page 6-15).
Open the COM port and send a command the VALHALLA 4300C understands, e.g. *IDN? followed by a CR (carriage return) and LF (line feed). Refer to the 4300C Manual from 6-18 for the full command list.
You can use the ValhallaScientific_4300C_Example.ptp Docklight example project I created: Download it, open it by double-click, adjust the COM1 port number to what is the actual COM port for your PC's RS232 interface. Then click on the "IDN" Send Sequence to send a query about Manufacturer & model details.

Related

Wemos D1 Mini (ESP8266) control with USB

I have a Wemos D1 Mini (ESP8266), flashed with WLED and I want to create an application like .exe and have control on turning it on/off and choose colors. Does anyone have any idea how I can do without to connect on wifi and just do everything via USB?
To control the WLED firmware over USB, you would use the firmware's ability to be controlled over a serial connection. It looks like you would open the virtual serial port that appears when you plug in the device, at a speed of 115200, and then you take the same JSON that you would POST to /json/state for controlling it over WiFi, and instead send it over the serial connection, and get your responses back over the serial connection.
You could also implement the TPM2 protocol, or the Adalight protocol (which doesn't really seem to be documented except in code), as those are also supposed to be supported.
If you want to do all this in C++ on Windows, you might start by reading the (very old) Windows tutorials for Win32 API serial port programming. If you only want to target Win10 or newer, you could learn C++/WinRT and then use the new WinRT serial APIs. Or you could consult the answers to this question about serial programming on Windows.

Issue with hex data being sent out of a serial port

I am really hoping someone can help me with this issue, I have been working on it for 3 days and its driving me insane now.
I have two linux based devices connected over serial, one is an embedded device the other is a pc type device. I have some python code on the PC device that currently, successfully reads messages sent by the embedded device (hence the serial settings are correct).
However I now need to send commands back to the embedded device and this is what i am struggling with, I have a data tap on the serial line so i can see the data being sent / received.
When I send the string "\x2a\x00\x00\x00\x00\x00\x57\x78\xD6\x81\x00\x01\x00\x8D\x54" out of the serial port, on the serial data tap I see only "EF F7 FF FF".
Please see the code below:
import serial
serialport = serial.Serial(port=self.device,
baudrate=self.baudrate,
bytesize=self.bytesize,
parity=self.parity,
stopbits=self.stopbits,
timeout=0)
data = "\x2a\x00\x00\x00\x00\x00\x57\x78\xD6\x81\x00\x01\x00\x8D\x54"
serialport.write(data)
serialport.flushOutput()
This is now resolved, turned out to be a couple of issues the customer neglected to tell me that unless the embedded device is in engineering mode it will ignore commands. Also the data tap had a dip switch set incorrectly, so there was nothing wrong with my code. Thanks to Shane for making me question the hardware and not my code !

Determine is a Serial Port exists, Linux C/C++

My development target is a Linux computer that has two physical serial ports located at /dev/ttyS0 and /dev/ttyS1. I also expect /dev/ttyS2 and /dev/ttyS3 to be defined.
Using stty -f /dev/ttyS0 and S1 reports the configuration of the two serial ports and reports something menaing "doesn't exist" for S2 and S3.
The hardware designers are talking about offering USB to Serial ports built onto the main board. They'll be DB9 connectors on the outside and just circuitry - no USB connectors on the inside. The number of USB-to-serial connections is not guaranteed and I know enough to design for "many" instead of one.
So, in setting up my port server daemon, I need to be able to determine which ttyS's and which ttyUSB's are "real" and which aren't. Will there ever be placeholdeer ttyUSB's? What if one were to be "unplugged" (say it was, indeed, a real USB coupler on the inside of the PC)?
Is there a better approach than popen()ing stty and examining its output to determine the status of the serial ports? Is there a C API for stty?
Thanks!
The "C-API" which stty uses is tcsetattr(3) and tcgetattr(3).
For finding TTYs without opening the device you may look at this question:
How to find all serial devices (ttyS, ttyUSB, ..) on Linux without opening them?

Testing Serial port application

I have a code to send data to serial port. I just want to make sure that it is sending the data properly. I checked the function's return value and the number of bytes written and it is success. Is there any other way to actually see the data whatever i am writing?
if(WriteFile(m_hSerialComm, pszBuf, dwSize, &dwNumberOfBytesWritten, NULL) != 0)
I tried to use "Advanced Terminal Port software"
but the data is not coming in that window.
There are several ways to test your software. If you have two serial ports then connect them with a cable and listen on the other port with a terminal application such as the one you mentioned. Otherwise, you could loop back on the same port by connecting pins 2 and 3 together. A hardware-free option would be to use virtual serial ports as provided by tools like com0com.
Assuming from your piece of code that you are developing on a Microsoft Windows operating system, I would recommend the Portmon for Windows "official" serial port monitoring utility. I have used it in in the past, and found it simple enough, and also quite useful specifically for its multiple filtering/search options (since sometimes the amount of data passed on your serial port is huge).
If all you want is a log of the data you have written to your own port, why not encapsulate your WriteFile (and maybe also your ReadFile) functions in some "utility" function(s) that reads/writes both on your serial port and in some log file? You could even add timestamps, and filter "whatever you are looking for" straight from your own code.
I found this last option really useful when remotely debugging applications with customers. You add a button in your application that toggles the logging on and off, then you simply have to ask your customer to hit the "log" button and to send you the results.

How to get the actual COM port number with SetupDiGetDeviceRegistryProperty

I'm trying to get a list of available COM ports with the "Windows 2000"-method explained here:
http://www.codeproject.com/KB/system/setupdi.aspx
My current code: http://pastebin.ca/1977670
This is what I get:
\\?\ftdibus#vid_0403+pid_6001+ftf479xra#0000#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
USB Serial Port (COM13)
USB Serial Port
\\?\hdaudio#func_02&ven_11c1&dev_1040&subsys_11c10001&rev_1002#4&ddab605&0&0101#{86e0d1e0-8089-11d0-9ce4-08003e301f73}
Agere Systems HDA Modem
Agere Systems HDA Modem
I looked through the different options of SetupDiGetDeviceRegistryProperty, but I can't find the right one to get the actual COM port number. (see http://msdn.microsoft.com/en-us/library/ff551967(VS.85).aspx)
I could look for COMXXX in the friendly name (via regex or whatever..), but I don't think that this would be the correct solution...
You can use SetupDiOpenDevRegKey to open the device's registry and query the "PortName" value; this will give you back something like "COM4". There are a few more ways to query COM ports.