상세 컨텐츠

본문 제목

Wxwidgets Serial Port Programming Vb6

카테고리 없음

by quedeclandsi1980 2020. 2. 10. 15:02

본문

Hello there people, I always had a crush for programming. I've wrote some programs in C, because I had a course in C language, but always in 'console mode' and this was one factor that led me to quit programming. Now that I've been learning in my class, Data Structures and Algorithms with C, I gained again the interest in programming. I know that they still remain using the console mode, but I think that this is a new opportunity to restart. Apart from this detail, what I'd like to learn is something more related to GUI.

  1. Serial Port Programming

I don't know how this works, so I hope that you guys could help me out. My interest are on building some applications that could be useful, like calendars, photo database, mp3 players, and etc, all beginner stuffs. And other interest is on building applications that could communicate with RS232, IrDA, Parallel port, USB, etc. For example, communicating to a printe via USB, communicating with a equipment through RS232 like a multimeter, and so on.

For example, the multimeter - Fluke has a software that uses their own language, where we can write down a code that can communicate with their multimeter, and who says their multimeter, can be with others, I think. It is possible to do all this with C? Does the C has a GUI interface, like java? I hope that you can help me out here guys. Best regards, Charles.

Although there is no built-in library to do this in C, there are a lot of API's to pick from to do the work for you. My personal recommendation would be Qt, which I am, in fact, learning myself (be it with very long gaps of time between it). Qt is good for doing multi-platform GUI development and usage, meaning that your code will work on Windows, Linux and Mac OS (be sure to compile per OS to get the desired program, but there is no change in source code).

As far as I know it works for all major platforms, has some nifty features and seems to be pretty fast. If you are developing for Windows specifically, try using Visual C. It should be packed with the appropriate 'templates' to build your program (Windows Form) from. Qt and Windows Forms are a lot like each other, though, Qt might seem a bit more of a problem (especially to install). Thank you all guys. Framework, the site that you gave me is reliable?

I'm using the MS Visual Studio 2005. In that website, the content is like too advanced, no? All that code is really needed to know for building an application?

And theForger's, the same goes with the website that you sugested (Win32 API), but more friendly, but with the same hard code. Allow me to ask you something.

Can you give some examples of applications that are built with this Win32 API stuff? By the way, the code that is your website theForge, is in C. It can be used in C applications? Well, C is no an Object Oriented Programming, so, it still a good why to then learn more about C? I mean, because I'm learning Data Structures and Algorithms in C (I know, there is some code in C), learning this stuff isn't a waste of time, or is the same thing?

Well, I'm basically a newbie on the topic, but since I stand where you stand, I will tell you why I went with Qt. If you want GUI, you should first ask yourself, do you want it to be cross-platform or OS specific. If you want OS specific GUI, and the OS is Windows, then MS technologies are ok. However, learning a GUI api is not fun, especially when proprietary vendors tend to change their interface over night. I used to study Win32, which was very uncomfortable API, and then for some time COM for certain purposes, and finally MS invented.Net. So, if you don't want to learn OS specific stuff, which will evolve under your feet, then you need some kind of mediator - a cross-platform mediator.

Port

I'm not saying that learning the ever changing MS technologies is a bad thing, but for personal development I wouldn't recommend it.Net is not cross-platform in practice, although as I said, it is very productive. Then you are left with either using something like Java, or C frameworks, or Python, etc. For Python, I can not help you much, except to tell you that it looks like a (relatively) clean language, but unfortunately produces slow programs. 10x slower at times compared to C/C. If your program is not processing intensive you can consider it. You should probably learn it anyways, since it is very pervasive.

I've been planning on taking this step for some time. Java is as cross-platform as they get. It is also as fast as a managed language gets and garbage collection is really nice for GUI development, since manual memory management is simply not justified for such trivia. The language is fast all right, but the memory consumption is much higher and the GUI is very slow. Also, it doesn't look native.

I believe there are changes happening with Java as we speak, but the memory consumption will remain a problem. I have used Eclipse for a while in the past, which is written in Java, also a version control system written in Java, and a mail client written in Java. It simply suffocated the hardware that my employer provided, and although not top of the line, it was a decent box. What I am saying is, Java is a bit of resource hog and has a somewhat flickering GUI.

So, there are different C frameworks, wxWidgets, Qt, GTK+, etc. Almost all support comparable features. I know that both Qt and wxWidgets use the platform look-and-feel, which was one of my criteria.

But Qt IMHO is simply more evolved as a framework. It has a very convenient programming model. It can actually improve the quality of your coding practice. The only downside I see is that it uses a meta-compiler in front of your C compiler and this is not entirely desirable in some situations. Qt supports stuff like networking, databases, etc, but wxWidgets also extends beyound GUI. There are not many books for Qt, but the ones available from bookstores are of above average quality. And there is a nice official IDE available, although some people might say that's a downside.

Now, no matter what you choose, GUI is always sluggish and resource hog these days, so Java is something to consider. But C is a low-level language, which gives you a lot of possibilities to develop hardware specific stuff without using Java Native Interface to connect between C and Java. The lack of garbage collection and debugging features is pain in my opinion. For the serial port. Qt does not offer anything out of the box, but you can use any library you choose. There seem to be few cross-platform (if you go that way), but I found those: Please, make note that I am studying Qt as we speak, so my information may be premature.

Also, my comparison is based on info from the web and browsing example code of various frameworks and platforms and using applications written with those. Then you are left with either using something like Java, or C frameworks, or Python, etc. For Python, I can not help you much, except to tell you that it looks like a (relatively) clean language, but unfortunately produces slow programs. 10x slower at times compared to C/C. If your program is not processing intensive you can consider it.

You should probably learn it anyways, since it is very pervasive. I've been planning on taking this step for some time. When we do comparison, we try to compare orange to orange if possible. Python being interpreted like Perl perform not as well as compiled languages like C/C is understandable. But we cannot deny the abundant built-in operators and data-type Python provides is a time-saver.

To do a fair comparison, I would think Perl vs Python vs Ruby. For C/C, hmmmm.

Compare with who? Java, Pascal, Ada, Others?:P. Sohguanh wrote: When we do comparison, we try to compare orange to orange if possible. Python being interpreted like Perl perform not as well as compiled languages like C/C is understandable. But we cannot deny the abundant built-in operators and data-type Python provides is a time-saver.

This was not supposed to be a detrimental comparison. It did sound a bit unjust to Python. I didn't want to compare languages at all, but I had to summarize briefly on the topic. And the topic was, what options for constructing GUI are there. Interpreted languages are good for anything as long as it is less processing intensive. And I can not help in this case. It is not my area of interest.

However, learning interpreted languages facilitates the development process if you want to prototype a solution fast, or create a tool, or a code generator. So everyone should know some. Pity I don't. Thank you all guys. Well, my idea is to build a simple application that read some data from a multimeter, like, for example Volts. What I'm thinking is something like a form, with a blank space, where the 'volts' will be displayed, accordingly to the multimeter readings.

I don't know if I'm explaining myself well, or maybe I'm not quiet well 'inside' the subjetc to make myself clear. The fluke 45 has a RS232 port, which, in matter of fact, communicates with the Fluke software named Metcal.

Well, when you guys and other, says that want to make an app to communicate with RS232, I think that, that app that they/you want, will do something that you already know. I mean, you type something in the hyper terminal or something else, whatever, but that you already know.

Now, I don't know if trying to get the reading from the multimeter, through the RS232 to the app that I want to build, have the same 'story' like those who want to build their app to communicate with the RS232. Do you understand what I'm trying to tell?

For example, this is the user guide/manual of the Fluke 45: From page 60/122 to 92/122 you can see the 'theory' about programming the multimeter There is some Computer Interface Command Set, and register that are explained there. Attention that exists two types of commands, EEE-488 and RS232. In page 89, you can look to a code in BASIC A (I don't even know what's that, never heard about) that has an example of that 'communication' to the multimeter. Has you can see, there some commands, that belongs to the RS232 category, that are used to do some interaction with the multimeter. Now, my doubts are, how can I write an app similar to that BASIC A code, that make the thing that I mentioned above? Did I made myself clear?

Sorry about my english. Best regards.

Hi based on my working experience about 10 years ago, I wrote a Visual Basic app that is supposed to interface to a RS232 port which is connected to GPS and compass. Step 1 Visual Basic provide a Comms control so it is very easy for your application to 'talk' to the RS232 port which will be pumping out data sent in from the GPS and compass.

I use the HyperTerminal app to see those data. At this step, you need to find an equivalent API to do that. That is, find some API that allow your app to 'talk' to the RS232. Step 2 Assume your app can now 'talk' as in read from RS232 you need to have the hardware manual.

Serial Port Programming

The GPS and compass all uses text-oriented data format to make my life easier. The content of the data is of course different since the GPS and compass are manufactured by different manufacturers. E.g A,123,456 //manual will say first field represent what, second field represent what etc etc Step 3 You then interpret those data based on what the hardware manual says.

Then you write your own company specific business requirement from there onwards. My business requirement during that time did not request for me to write to the GPS and compass but I presume the method would be similar. That is, send data TO the RS232 and the data must conform to what the hardware manual say.

C++

Possibly a RESEND, RESET etc etc commands to the hardware. Please note some hardware data format is binary instead of text so using HyperTerminal you see lot's of hexa-decimal numbers which is very reader un-friendly.

Most of the time you will spent some time to build some small utility to convert those hexa-decimal numbers to human-readable string so it is easier for you to do debugging during development. I don't see much problem with creating the program if you know the tools. I am just not the man to guide you through it, because I am exploring the options myself. With Qt, it would be very (and I mean very) easy to create a dialog box with a text edit control for logging the communication and some other control for the multimeter readings.

I think you will have to start another thread (Qt supports platform-independent threads) to perform the initialization. Then, you can subscribe to a timer and request a reading every xx ms from the device. Altogether, only the threading aspect is more sophisticated, and beyond my capabilities at the moment, but it is certainly doable.

Your multimeter seems to use console like interaction through the serial port, and that should be (in theory) no issue with the libraries I dug from the web. I understand your tentativeness.

You want to do it in the proper, established, most productive way. But, if you have some time on your hands, why don't throw yourself in.:) Regards.