|
That's a different situation though, that's a 'make this method self-marshalling' rather than 'marshal this method call'. The StackOverflowEx is pretty obvious if you don't guard this. If you put the responsibility on the caller (i.e. they must use control.Invoke(() => control.SomeFunction())), or you provide an explicit SomeFunctionAsync (using BeginInvoke) then it's not an issue.
On a different note you don't need to define a void delegate type, MethodInvoker exists for this already.
|
|
|
|
|
I am coming from Texas instruments Forum (MSP430f47197) due to my curiosity on C# and serial communications!
I just started to make a GUI that can communicate with two energy meters and read their voltage, current, power factor, and the Active power as well.
The GUI itself was easy for me as I saw a couple of Youtube videos and learnt how to make forms in Visual Studio.
The confusion and ambiguity was started when I noticed that I need to make the PC connected to the serial port and most importantly, read the values. Moreover, for one out of two meters I need to write as well and return that back to the GUI!
As I am new in Serial communication and C# stuff, what do you think of this project? Is this doable?
I have the code for one of the energy-meters. The code which is written in the CHIP of the board is partially modified by me and I am almost familiar with.
But the other energy-meter is not. It is just a black-box and I have only some h files! Is this possible to talk to such energy meter?
I would like to know how much time do I need and where is the best point to start with?
I have divided the steps for my project as follows. However your feedback and comments much more appreciate it.
1. Receiving data from the E-meter code through Hyper-terminal or other monitoring software.
2. Receiving the Voltage from the SPM without decimal points via Hyper.
3. Receiving the Voltage from the SPM Using C#.
4. Modifying the Voltage from the SPM Using C# and sending it back to the MCU and showing the modified version of Voltage on the display.
5. Receiving the Voltage from the Radian-meter Using C#.
6. Comparing voltage from SPM to Radian-meter and calculate the offset and sending back to SPM.
P.S.
SPM: energy-meter 1
Radian-meter: energy-meter 2
Voltage: Just as an example to get one value.
|
|
|
|
|
Doable? Sure.
Doable by you? We have no idea since we can't get inside your head and find out exactly what you know and don't know.
This is not a project for a newbie in C#/Windows programming.
There are more to your list of "steps" than what you've got. Two-way Serial communication without blocking the UI and threading issues (updating controls from background threads) are going to be your biggest design roadblocks.
Don't make the mistake of believing that "oh, I'm not using any threads so I'll be OK". With the serial port classes, you're using background threads. You just don't know it.
|
|
|
|
|
In good software design you do not attach a GUI to communicate with electrical systems like that.
1.
First of all start of with a prototype class library that you run in debug. Start creating handlers for communicating with the ports and check the results. (also create unit tests for those). Working with ports means you use machine "resources", which implies cleaning up those resources and also making sure you do not use resources used by other applications (potentially blocking those)
Sending data to the port is probably easy, but reading from it requires some loop OR a callback handler of some sort. There is probably a good tutorial or sample code on the internet, but try to understand before using!
2.
Then you work you way up to business layers or something similar that never communicates to the electrical systems directly, but with the class you wrote in 1. (which you cleaned up, foresaw with sufficient commenting, including intellisense and which is preferably a totally different project. The business layer handles workflow and quality checks of the data. The workflow pumps the data up to the next level.
3.
Create yet again a project that will hold your GUI and that uses the business layer assembly. If you want your GUI to remain responsive you´ll need a backgroundworker.
So for me your steps 1-6 are just one step in the process.
If it is to some interest read my article[^] .
Hope this helps!
|
|
|
|
|
Serial port communication is definitely possible in C#/.Net. It's a low level interface though so you need to know what bits to read and write, handle wait periods and transfer rates and things like that, which require a lot of information about the chips' behaviour (i.e. documentation).
You definitely shouldn't be interacting directly with the ports from UI code. Apart from it being generally good programming practice to separate concerns (and there are at least two obvious distinct parts of this app, serial port I/O and UI; probably three if there's any logic to be done), I/O does lots of things on background threads and that really doesn't play nicely with UIs.
|
|
|
|
|
Ok Guys! Thanks for your comments so far! May you please guide me to a tutorial just to send some amounts through a serial port please?
In other words, I receive my values through Hyper-Terminal but now I just would like to have a window (built by myself) to show those! (As a first step!)
That would be appreciated!
|
|
|
|
|
Hi! I have a proyect where I´m creating .mp3 files with different names each, but I need to download those files in .vox format, so after, another program could read the files, bc it only accepts .vox files. Anyone here have done that before and could help me with some code, or any suggestion would be great. Thanks to all.
|
|
|
|
|
Member 10701353 wrote: Anyone here have done that before and could help me with some code Easiest way is to find a command-line tool and execute that from code;
Process.Start("convert.exe bla.vox bla.mp3"); Alternatively, you'd be googling for a library that implements that functionality; I doubt that you want to implement the conversion yourself.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: I doubt that you want to implement the conversion yourself. Aw
That would actually be interesting, unlike the other two ways.
vox seems pretty simple, decoding mp3 would be the hard part and there are plenty of libraries to do that.
|
|
|
|
|
How to add a context menu in web forms? I want a context menu to be added to a grid and also another context menu outside the grid Without using any third party tool.
Can anyone help me?
|
|
|
|
|
You're going to have to do this via JavaScript. You'll be better off asking this in one of the CodeProject web forums as this has nothing to do with C#.
|
|
|
|
|
Thank you. I will post this question in web forums.
|
|
|
|
|
hi
how chenge close botton in extra tab?
style PropertyView
tanks
|
|
|
|
|
You need to provide more information if you hope to have any meaningful answer to this question.
Describe the technology you are using: WinForms ? WPF ? ASP.NET ?
Tell us what, exactly, is a "Tab" and a "PropertyView" in your application.
“Use the word 'cybernetics,' Norbert, because nobody knows what it means. This will always put you at an advantage in arguments.” Claude Shannon (Information Theory scientist): letter to Norbert Weiner of M.I.T., circa 1940
|
|
|
|
|
|
You're going to have to supply a lot more information than that. What technology are you talking about here? What extra tab?
|
|
|
|
|
extra tab in c# in component devexpress
|
|
|
|
|
|
if you are looking win forms tabs have a read of this CP article
Painting Your Own Tabs - Second Edition[^]
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Does anyone know proper place where I send a request about C# new language feature?
---------------------------
Mail To:
higlabo@outlook.com
---------------------------
|
|
|
|
|
How about these people?[^]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Thank you
I will ask here.
Higty
modified 27-Mar-14 22:02pm.
|
|
|
|
|
|
|
I will only note that based on a vast array of language requests that I have seen over the years that you might want to at least discuss it with a few people first just to insure that
- It is feasible
- Usable to a large number of people
- Not already existing
|
|
|
|