Hot answers tagged

5

Looking at the source code of the Arduino IDE on github, it looks like they call an executable (listComPorts.exe). So I would guess you can't get that info through serial. Here's a C# app using WMI that can get port, vid, and pid: namespace PortTest { class Program { // Helper function to handle regex search static string regex(...


3

There's two basic things wrong here. First is your way of opening the serial port and immediately sending data. The Arduino is reset when you open the serial port and the bootloader runs. This takes a second or so, and during that time any data that you send is lost. Secondly you're not checking for a flag of "W" but instead you're assigning "W" to the ...


2

The Arduino should read only whole lines (non-newlines until a newline). Discard the line if it doesn't start with "stat>". This will make your program more robust and less likely to fail with bad input. Fixing the transmitting app instead still leaves your Arduino vulnerable. Consider the rule of thumb for serial communication: "Be restrictive in what ...


1

You are closing the port immediately after you open it. You need to keep it open while you are expecting data. Remove the line serialPort1.Close(); Then, in the callback you try to access the GUI from the callback thread. That's not allowed. Use Invoke(). private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) { SerialPort ...


1

How would i go about finding out if there is the needed driver on that computer where the digispark is plugged in I can't think of any way to do that. That's like asking if a keyboard you plug into a USB port can tell if you have Photoshop installed or not. Is there any way to add my program made in c# to the digispark ... No. The Digispark is a tiny ...


1

You can use TCP or UDP protocols. https://www.arduino.cc/en/Tutorial/UDPSendReceiveString https://www.arduino.cc/en/Tutorial/DhcpChatServer You can use free UDP, TCP port listener sofwares for Windows, Linux etc.. for testing your setup. For C# development: https://stackoverflow.com/questions/20038943/simple-udp-example-to-send-and-receive-data-from-...


1

Either use TCP or UDP to communicate. With TCP one end will be the server and will open a socket (your choice) and the other end will connect to it (much like communicating with a web server). With UDP both ends will open a socket and send discrete packets backwards and forwards. How you would do either of those in C# is outside the scope of this website. ...


1

Please look here https://todbot.com/blog/2012/03/02/listcomports-windows-command-line-tool-for-usb-to-serial/ The article is right about what you are seeking. Thanks to @Johnny Mopp, searching "listComPorts" keyword helped me. Quote from that article: How it works The C and the VBS versions both utilize the WMI infrastructure that’s been around ...


1

Your code currently will only measure the code execution time and not the duration of the note(s) being played. You need to follow uint128_t's suggestion and rewrite the code to detect the "button release", at which point you measure the time with millis(), and call noTone(). Only then will you be able to measure the note's duration. I believe that the ...


1

Your problem arises from a mix of newline-terminated and un-terminated messages. The newline terminated values probably would work by themselves as you can use a ReadLine() type method to wait until they have been completely transferred. But the non-terminated attempts such as your use of the ReadExisting() method cause a problem - these likely fetch ...


1

I assume that by "USB" you mean "USB-to-serial adaptor". Try running the same code without any serial communications, just have an LED do the equivalent of printing, and power it from a good power supply. If it runs for more than five hours, the problem is with the USB adaptor and/or your PC (Windows XP? Really?), and hence not relevant to this forum. If ...


Only top voted, non community-wiki answers of a minimum length are eligible