simple software for GUI and serial interfacing  - Page 1
Forum section: electronics / projects

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 14, 2016, 07:57:31 pm
content: Hi all nearly 20 year ago I was writing software to control various types of machinery. The equipment was quite simple in operation but had lots of data entry required to set up the equipment.I used to use Visual Basic and Microsoft MFC. Found Visual Basic much easier to make nice GUI but was always missing some vital DLL with no internet access in some remote ass hole of a forgotten country. When the Internet was one computer in the manager office on a broken cga monitor.MFC was much more capeable and the exe file always ran without issues. However it takes a 100 lines of impenetrable code to change the shape or colour of a message box.I'm just getting back into programming and I want to know what's popular these days. I want something that can quickly build simple GUI can access com port and open files to store measurements.My preference would probably be closer to VB than C and freely available.Any suggestions I was thinking of C sharp. But the guys at work seem to love Python. I'm not sureThanks

author: nctnico
author_rank: Super Contributor
timestamp: November 14, 2016, 08:14:03 pm
content: If you know VB then C# may be closer to what you know then Python. I think C# also leads to programs which are easier to distribute.

author: Fungus
author_rank: Super Contributor
timestamp: November 14, 2016, 08:26:42 pm
content: http://cyrille.rossant.net/create-a-standalone-windows-installer-for-your-python-application/

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 14, 2016, 08:48:36 pm
content: Yes I'm thinking C sharp as I'm programming my PIC based test equipment in C so I will probably do better to stick with learning One language at a time. I must have had a bash at several languages over the years as the projects required but don't do it frequently enough to ever become proficientMany thanks for the suggestionsDoes anyone know why Vissual basic was dropped apart from the flakey distribution builder I thought it was really quick and easy.Regards Chris

author: PA0PBZ
author_rank: Super Contributor
timestamp: November 14, 2016, 09:11:25 pm
content: Quote from: Ginettag20 on November 14, 2016, 08:48:36 pmIt's far from dropped, have a look at visual studio express, or visual studio community as they seem to call it now:https://www.visualstudio.com/vs/visual-studio-express/

author: NottheDan
author_rank: Frequent Contributor
timestamp: November 14, 2016, 09:15:50 pm
content: Have you looked into the classic tool for the job - Tcl/Tk?

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 14, 2016, 09:28:10 pm
content: Thanks for that I had thought that Vissual studio was just an ide and that Microsoft had dropped basic. I was obviously just out the loop on this. Still even though I prefer basic I guess I should take the pain and improve my C.Just had a look at some YouTube tutorial for c# and basic and they both look very suitable for what I need. I never really enjoyed C but I guess I should stick with it as it will better complement my embedded work.

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 14, 2016, 09:31:06 pm
content: No I have never even heard of tcl/tk. I think I'm likely to get drawn into visual studio though.But thanks for the suggestionRegards chris

author: LaserSteve
author_rank: Super Contributor
timestamp: November 14, 2016, 10:53:33 pm
content: PowerBasic if you want to remember the old days. It's basically a Windows version of TurboBasic by Borland.

author: MarkF
author_rank: Super Contributor
timestamp: November 15, 2016, 12:51:43 am
content: PIC C is nothing like C#. Visual Studio C/C++ and PIC C are more equivalent than C#. C# is more geared toward GUI development. Personally, I stay away from MFC and use Win32 projects. The Win32 GUI development is much easier.An optional GUI development tool is QT. It is widely used and is cross platform (Windows and Linux).35+ year software developer here.

author: snarkysparky
author_rank: Frequent Contributor
timestamp: November 15, 2016, 01:16:18 am
content: check out sharp develop. It's free and can create VB as well as C#some example statements for the serial portSerialPort my_serialPort= new SerialPort("COM4",9600,Parity.None,8,StopBits.One); // declare a new serial port objectmy_serialPort.Open(); // open itmy_serialPort.DiscardInBuffer(); // clear input buffermy_serialPort.ReadTimeout=300;my_serialPort.Write(sendbuf,0,1); // write characters from sendbuf array.bytzin = my_serialPort.BytesToRead;Thread.Sleep(140);bytzlast = my_serialPort.BytesToRead; // check buffer for number of recieved bytes.

author: Jeroen3
author_rank: Super Contributor
timestamp: November 15, 2016, 06:29:04 am
content: If you want to vendor lock on microsoft, go with some Visual Studio language. Else, Qt.

author: kripton2035
author_rank: Super Contributor
timestamp: November 15, 2016, 06:57:49 am
content: you can try xojoyou can develop the same code almost for windows,linux,mac,ios, raspberry and next year android.very nice for gui, and powerfull enought even if it's not Coh and it's free until you want to build standalone apps, and you can run everything under debug mode (the ide must be launched)

author: JPortici
author_rank: Super Contributor
timestamp: November 15, 2016, 07:09:20 am
content: i'd say, learn one thing at a time, get a copy of vb6 sp6 from somewhere as the programs will nearly write themselves it's so easy, then move on to something else. that's what i'm doing. i have a reasonable high degree of knowledge about C, i'm moving on to c++, then maybe qt. code::blocks would have been perfect if not that it's impossible to use on a mac from after 2009

author: obiwanjacobi
author_rank: Super Contributor
timestamp: November 15, 2016, 08:10:58 am
content: I read some half truths around C# etc.The .NET framework works on byte code - like Java, only they call it Intermediate Language (IL). The actual programming language that you use does not really matter as long as it produces valid IL. Dlls made with one programming language can be reused by another programming language. C# is not the only language and it is not closest to the old VB6 (that was COM oriented). VB.NET is closest to the old syntax although many new concepts have been introduced (like classes). The libraries you use with a .NET project are vastly different from the (COM) libraries you had with VB6 - although the Windows Forms come pretty close. There are also extensions for C++ to produce IL. There are many other languages that produce IL (COBOL anyone?)...It is also not true that .NET only runs on Windows. Although Windows is its native home, there is also this thing called Mono that attempts to make it available on the Mac and Linux. Note though, that it does not support all features and libraries that run on Windows.I hope this helps, Marc

author: nctnico
author_rank: Super Contributor
timestamp: November 15, 2016, 11:18:51 am
content: Quote from: obiwanjacobi on November 15, 2016, 08:10:58 amSo .NET doesn't run on anything else but Windows in the real world. Checking whether a feature is supported is a major PITA. If you need to go cross platform you better look at QT or WxWidgets.

author: obiwanjacobi
author_rank: Super Contributor
timestamp: November 15, 2016, 11:35:51 am
content: Quote from: nctnico on November 15, 2016, 11:18:51 amMono does supports a lot. You can be really productive in .NET - way more than in C++ using Qt, especially if you do not know Qt - it would be suboptimal not to at least look at it and spent a couple of minutes checking feasability of doing the project in Mono.

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 15, 2016, 12:32:15 pm
content: Thanks for the replies. My software guys use QT at work for some of our Scarda type applications. However learning the framework would just add extra complication for what will be a very simple interface for controlling a pic based dc load bank. I don't have to worry about code portability as this is not a commercial product. I just need to send serial command and decode returned strings and display then. So it will be C# or VB. I have had a look at some of the YouTube tutorial and both look similar to use and easy to creat GUI controls. I still think C# will aid my C programming and will probably go this way.Regards Chris

author: Jeroen3
author_rank: Super Contributor
timestamp: November 15, 2016, 01:24:40 pm
content: C# is not like C. It's more like Java, but from Microsoft. C++ is like C, except it requires a very different design mindset.

author: Bud
author_rank: Super Contributor
timestamp: November 15, 2016, 01:58:58 pm
content: How hard is it to work with USB in QT? Also, can someone point to a good set of documentation for QT ? Some time ago when working on Flir E4 i ran into QT but found that documentation for the language was scarce and looked half baked and "amateur-ish". I am not looking for examples tutorials but rather core specification of methods/properties/data formats.

author: elgonzo
author_rank: Unknown
timestamp: November 15, 2016, 02:04:18 pm
content: Quote from: Ginettag20 on November 15, 2016, 12:32:15 pmIf you intend to run your C# application with Mono (although i personally would not recommend it; i pretty much side with the argument nctnico made above), i would suggest to do the development in a Mono environment as well.I do not know Mono's current state, but the last time i checked Mono 4..5 years ago, it had severe difficulties to render even simple WinForm GUIs (which were written using VS) properly and in a functional manner on an Ubuntu box. It was less struggle to setup Wine with the necessary .NET libraries and run the .NET program there than trying to experiment with and debug the C# GUIs in a Mono environment to figure out what Mono's problems were. In all likelihood, if the WinForm GUIs were developed in a Mono environment, most issues with Mono rendering these GUIs would have become apparent quickly during the development cycle.There is another Mono-related "issue" that might be relevant for an aspiring C# developer. Most of the C# developer community are Windows or mobile developers, not Mono developers. That means, most information, advice or code samples might or might not apply to or work with Mono. Be prepared to experiment a lot if you encounter problems.On the other hand, if your goal is to have an application that you will only run on Windows, then please ignore my comment

author: Jeroen3
author_rank: Super Contributor
timestamp: November 15, 2016, 02:21:02 pm
content: Quote from: Bud on November 15, 2016, 01:58:58 pmThere is no cross-platform way to use raw USB, therefore Qt does not support raw USB. You'll need third a party api for that, with the consequence of losing cross-platform capability if you don't keep that in yourself.There is however a way to use usb serial, and networking.https://doc.qt.io/qt-5/classes.htmlI know there are projects like libusb, but these are rather hobby-ish and not that stable or end-user friendly.Not to mention novice programmer friendly.

author: MarkF
author_rank: Super Contributor
timestamp: November 15, 2016, 03:28:08 pm
content: Qt has a wrapper around almost everything in order to be cross platform compatible. I only mention it because it's GUI development is on par with Win32 GUI development. If you don't need to be cross platform compatible, I would recommend staying with Visual Studio C/C++ and create your GUI under a Win32 project. Using C for both your PC GUI and your PIC code would be the best place to start. Then branch out from there when you are comfortable.Use the GUI maker in Visual Studio to layout your GUI in the Win32 project.QuoteWRONG. C# is different enough from C to just confuse the beginner. C# and C/C++ ARE two different languages. Forget C# and VB! Learning C for both Windows and the PIC is going to be challenging enough.

author: 3141592
author_rank: Regular Contributor
timestamp: November 15, 2016, 03:50:46 pm
content: Quote from: Ginettag20 on November 14, 2016, 07:57:31 pmTo be honest, Python fits this perfectly. It's easy to learn, gives easily readable code and for one off projects or prototyping I have found nothing better, especially if you value your time and want to do it quickly. There are good quality libraries available for scientific computations, signal processing, plotting etc.

author: macboy
author_rank: Super Contributor
timestamp: November 15, 2016, 04:41:30 pm
content: Just throwing this out there: I have done simple GUIs for serial port access in HTML. Usually this is using an HTA (HTML Application), which is just an HTML file with the extension changed to ".hta". You can also use ".htm" or ".html" files if you change the security settings in the browser to allow basically full computer control for local files, which is not a good idea.The GUI is built in HTML just like any web page. I stick with plain jane vanilla html with no fancy extensions. I prefer vbscript to jscript but they are interchangeable (and online tools can translate between them with excellent success rate). You can add ActiveX/COM controls such as serial port access and other things. I've had some success with GPIB instrument control this way, but it is not as straightforward as I'd hoped it would be.This requires no development environment, just a text editor (preferable with html formatting highlighting). A big drawback is being stuck to Windows and requiring a functional IE version to be installed. Microsoft's ancient "ActiveX control pad" program can be used to add COM (ActiveX) controls to the html, including providing lists of properties, functions, events, etc. from the ActiveX control. Since you have used VB6, you are already familar with VB (VBScript is similar) and ActiveX, otherwise I wouldn't have even suggested this.

author: nctnico
author_rank: Super Contributor
timestamp: November 15, 2016, 04:57:19 pm
content: Quote from: Ginettag20 on November 15, 2016, 12:32:15 pmWhatever framework you use you'll need to put time into learning it. Don't expect anything will come flying in by itself.

author: Fungus
author_rank: Super Contributor
timestamp: November 15, 2016, 05:05:32 pm
content: Quote from: MarkF on November 15, 2016, 03:28:08 pmNitpick: C and C++ are ALSO two completely different languages. Just because you're using C++ compiler doesn't mean you're writing C++.C# is closer to C++ then C.

author: MarkF
author_rank: Super Contributor
timestamp: November 15, 2016, 07:04:10 pm
content: Quote from: Fungus on November 15, 2016, 05:05:32 pmThe point I'm trying to make is that the OP is already learning C for his PIC processor and that he should stay with C for the Windows side as well. And creating a GUI for a Win32 C project is about as easy as it gets.One language (i.e. C) and the Visual Studio built-in GUI tools equals MINIMUM LEARNING CURVE.

author: nctnico
author_rank: Super Contributor
timestamp: November 15, 2016, 09:02:19 pm
content: Quote from: MarkF on November 15, 2016, 07:04:10 pmThe problem is that there is no way to built a GUI using C or C++ in Visual Studio using a point & click interface. MS has made that a tedious task on purpose.

author: matt6ft9
author_rank: Contributor
timestamp: November 15, 2016, 09:19:59 pm
content: Processing has a low learning curve:https://processing.org/reference/environment/It's free and the IDE is similar to the arduino IDE.

author: MarkF
author_rank: Super Contributor
timestamp: November 15, 2016, 09:35:38 pm
content: Quote from: nctnico on November 15, 2016, 09:02:19 pmNOT TRUE. In a Win32 project, the resource tab will let you create a dialog box via point and click. It will also let you drop widgets for files, buttons, text boxes, etc. Then all ypu need to do is make it the main window and process the callbacks for the widgets you created.

author: Ginettag20
author_rank: Regular Contributor
timestamp: November 15, 2016, 10:16:41 pm
content: Thanks for the replies. Well I understood most of the replies. I really hated using the MFC and found even simple things like control a serial port or opening a dialog box just tedious. To be honest I'm more interested just getting something up and running as quickly. I guess though it's probably worth me trying each of the suggestion in a simple hello world application to see which I like best.Thanks again for everyone's suggestionsRegards Chris

author: Buriedcode
author_rank: Super Contributor
timestamp: November 15, 2016, 10:47:40 pm
content: I have only skimmed replies, so I'm not sure if I'm repeating anything. I would avoid VB. Up until a few years ago the PC apps I wrote were mostly in VB (yup, for windows platforms) and I switched to C#. The C# code is much more readable, and makes more 'sense' to look at, where-as whilst it seems everyone can follow VB, it can become extremely lengthy and has certain quirks that make little sense. Whilst of course C# is different from C, it is of course still based on C. Syntax, operators, assignments are pretty much the same. But whoever suggested writing raw C for windows... really?I cannot claim to be a developer, I'm just n electronic engineer who occasionally needs to add host software for configuration, logging or networking - so my experience is somewhat limited but at the same time, this is from an engineers point of view, not for someone who wants just just write PC apps.Visual studio is just an IDE that can be used for many languages and has become extremely popular. And whilst winforms are dying out (even WPF is dying out..), people still use them, especially for quickly knocking up neat and simple GUI's. I would suggest using Visual Studio Code (https://code.visualstudio.com/) and working with the .NET environment if you're writing applications specific to windows based platforms. C# is popular for a reason. You could also go with visual studio community (https://www.visualstudio.com/vs/community/) which now has Xamarin integrated. That means you have the option of writing for windows, OS X and Android using C#, further down the line.If you wish to have some example code for using the serial port let me know and I'll post some. The .NET 'serial port' is fine for basic terminal stuff, but it can be quite buggy so many use it, but write their own threads to fetch raw bytes and handle the formatting themselves. I have a few past projects that have been running a while now at > 115.2kbuad and as far as I know, haven't dropped a byte yet.

author: hans
author_rank: Super Contributor
timestamp: November 15, 2016, 11:04:17 pm
content: Don't let the linear combination of words to be a hint for you to what a language is like to program. It's nice that maths work that way, but unfortunately naming conventions do not. C# has absolutely nothing to do with C++ or C, just like C++ can be completely incompatible with C (or sometimes vice versa) code once you start to use the more advanced features of C++.Java and C# are fine for in house tools. C# is actually really productive on the Windows eco system thanks to .NET. As mentioned C#.NET compiles to IL code which the .NET runtime interprets/JIT compiles. This is similar to Java.. it also compiles down to 'bytecode' and has alternatives like Scala.I wouldn't bother with Visual Basic to be honest, VB6 is dead and VB.NET is just C# in a nostalgic shape.Note that the .NET langauges are ridiculously easy to disassemble and reverse engineer because the IL is very verbose. It's viable to take an exe, disassemble, grab the source code (albeit with loss of comments and some symbols), tinker around with it and recompile it. If you want to sell your program to customers in C#/Java, or license it in some form, I would highly recommend looking up some kind of protection of IP.For in-house tools consider what I just said as noise.I personally use Python because I'm not tied by Microsoft neck's strangle. Python is also a great small productive scripting language. However I don't go as far as building GUI's because often CLI is often good enough for me, and further I like to chain or re-use existing scripts in Python. This is not unique to Python at all, but it's just like Python does what I need and I can program this in the most primitive text editor (like nano in SSH), in which the latter is great for deployment on e.g. a VPS.

author: nctnico
author_rank: Super Contributor
timestamp: November 15, 2016, 11:32:27 pm
content: Quote from: hans on November 15, 2016, 11:04:17 pmThis is a good point! Last year I had a software tool provided by a customer which could do a secret calculation to start communicating with a device. Ofcourse getting the official docs would need to go through NDAs and other slow bureaucratics. A .NET decompiler solved the problem quickly!

author: hans
author_rank: Super Contributor
timestamp: November 16, 2016, 08:41:58 am
content: Yep, the protections blueskull describe are common and take literally a coffee break to modify. Aside from IL viewers, there are also many IL editors out there that decompile, edit IL and reassemble.In summary, anyone that thinks stuff in source code is "hidden" is wrong. Stuff like file formats, protocols, crypto keys, etc. are all out there. My old boss always said "we don't need an IL obfuscater, our customers are not technically inclined enough!". Sure, next year we had an OEM that was buying more hardware than software licenses. I wonder how that ended..C/C++ programs take considerably more time to attack, and in practice this means that people refrain from it.It's just like those stupid laptop lock cables I saw people use at universities and stuff. I once was at a university where laptops frequently were stolen, even with these cables in place. The thief was caught in a few weeks time and it turns out he was carrying a huge cutter under his jacket. Sure the lock cable may stop someone that smells 'an opportunity' but it doesn't stop those who are inclined.

author: krho
author_rank: Regular Contributor
timestamp: November 16, 2016, 06:16:29 pm
content: You can also look at the Lazarus. Behind that is a FreePascall compiler.