Learning Serial Communication and Interacting with Computer

Good morning everyone.

I'm new to this forum, but not completely new to the Arduino world.

I have a project in mind. The main topic is the serial communication and interfacing with PC so I hope this is the right section.

It's an educational (for me) project, and I know there are yet a lot of software and libraries that do things better than I could ever do, but I want to learn. I also don't mind if it will take a year, it's a passion and I prefer understand well what I am doing rather than using someone else work.

All this discussion makes sense in a "hobby realm", when you do things because you want and not because you have to. In a work-context this cannot be always accomplished, because you have one task and you should carry on only that task. That said, it doesn't matter if I can even finish the project but how much I'll learn doing it.

Sorry for the long introduction, but I want to make clear my position about this project, so you will understand the motivation behind my questions.

Background:

still at university, I know C, C++ (plus a little of Qt) and Python. I have basic knowing in electronics, both analog and digital. I'm open at learning new things and really interested about embedded system and low programming.

Project:

Creating a serial protocol that allows me to communicate between the Arduino and a c++ program on my pc, maybe on visual studio. The Arduino IDE will be used only to loading the sketch onto arduino, then the real communication will take place between arduino and the c++ program. I want to be as (reasonable) low level as possible, that means that I don't want to use assembly but maybe some port manipulation. Is there, for instance, a way to handle the serial communication without the "serial.begin" function?

Question:

Obviously I am not asking you to do the project for me, neither providing answers for all the problems I will bump into. What I mostly lack is some material, internet resources, books, tutorials etc that explain a general way to accomplish these type of things. For example, where can I found explained a way to handle the serial communication? Can I define some subroutines while the rest of the uC will behave as always? What registers are involved in the serial comm? How can I know the bit frequency? And also how can I handle that real time stream of data in the c++ file?

Feel free to answer these questions or providing some materials (name of books, links, free resources). I'll be very thankful.

Last but not least, if someone is interested please contact me, we can learn together, do some experiments, share results. Together is funnier!

Regards,
FrAxl.

Creating a serial protocol that allows me to communicate between the Arduino and a c++ program on my pc, maybe on visual studio.

Visual Studio is an application development tool. It has NO clue how to communicate with an Arduino via a serial port.

What it can do is allow you to build an application that DOES know how to do that.

I want to be as (reasonable) low level as possible, that means that I don't want to use assembly but maybe some port manipulation.

Direct port manipulation IS assembly language code, near enough. Do not go there unless you REALLY need the speed. An application that is getting input from a serial port does NOT have that need.

Is there, for instance, a way to handle the serial communication without the "serial.begin" function?

Sure. The Serial object is just an instance of the HardwareSerial class. Feel free to write your own class to replace HardwareSerial.

Personally, I've got better things to do.

What I mostly lack is some material, internet resources, books, tutorials etc that explain a general way to accomplish these type of things.

On the other hand, you have a fully functional class and the source code.

First of all I want to thank you for the answer.

I know that visual studio is just a development tool, I explained bad, but thanks for pointing it out.

PaulS:
Direct port manipulation IS assembly language code, near enough. Do not go there unless you REALLY need the speed. An application that is getting input from a serial port does NOT have that need.

Sure. The Serial object is just an instance of the HardwareSerial class. Feel free to write your own class to replace HardwareSerial.

Personally, I've got better things to do.

That's the point! I am here to learn, doesn't matter if it will take effort or time. Then I will decide if that is too difficult/boring/time-wasting.

PaulS:
On the other hand, you have a fully functional class and the source code.

And that's a beautiful thing, thank you very much for telling me of that library, maybe I won't re-implement it, but it will give me some ideas on how things work "under the hood". And that exactly the kind of stuff I want from any person that will answer: some material, some tips or hints.

Regards,
FraXl

You may find some interesting stuff in Serial Input Basics and in this Python - Arduino demo

...R