Any Raspbian bash script examples for USB serial

The following script works fine after the booting. But then it no longer triggers the USB.
It only works one time. Are there any example scripts available?


stty -F /dev/ttyUSB0 9600

#reading Nano USB
cat /dev/ttyUSB0 > readings.dat & #collect and write to file
sleep 5

I assume there is more to do, but it works fine the first time after system boot.

The following script works fine after booting (with the L led flashing). But then it no longer triggers the USB (no flashing L led). It only works one time. Are there any example scripts available?


stty -F /dev/ttyUSB0 9600

#reading Nano USB
cat /dev/ttyUSB0 > readings.dat & #collect and write to file
sleep 5

I assume there is more to do, but it works fine the first time after system boot.

It would be a big help if you describe the project you are trying to implement and post the Arduino program.

I wonder is your problem due to the fact that the nano resets when the serial port is opened by the PC program? Your PC program should open the serial port, allow time for the Arduino to reset before trying to send data and then keep the serial port open until the PC program is completely finished with the Arduino.

This may be easier to with Python rather than a bash script. This Simple Python - Arduino demo may give you some ideas.

...R

Please don't double Post. I have already responded in your other Thread

I am suggesting to the Moderator to delete this Thread.

...R

Threads merged.

REPORT TO MODERATOR IS NOT A REPLY BUTTON

Bob.

Sorry I was not permitted to reply. I am a beginner in Python, so I was hoping, because it is an USB connection, that the com via bash would be very easy to manage. I was wrong.

Once upon a time I did program microcontrollers in assembler, but I was hoping that USB today would offer a more accessible option for automation. But it seems the community decided to implement Python and so everything was created to be executed as .py

I might as well turn my attention towards I2C. Let's see...

One more thing, to read the ADC would be good enough. The format doesn't matter that much, as long as the data is put in a file so I can analyse it. Whatever a bash command does, it would be fine as is. To some degree it even has worked using "cat" as script command. The baud rate however seems to be fixed as default on USB. So the USB has a mind of its own anyway. Good, I like that. It should be to our advantage though, otherwise you can go I2C. Although I like the idea to use a USB cable, the modules for I2C are smaller and cheaper. Still, one would hope that USB is the way to go today. The USB was not born yesterday.

Nano2PI:
Once upon a time I did program microcontrollers in assembler, but I was hoping that USB today would offer a more accessible option for automation.

I'm not sure how to interpret that. USB is just a communication system. It doesn't make automation more or less accessible.

But it seems the community decided to implement Python and so everything was created to be executed as .py

I wonder what community you are talking about? Python is certainly commonly used on an RPi but you can also program it in many other languages including C++

I might as well turn my attention towards I2C. Let's see...

I doubt that that will be easier than using Serial over a USB cable.

...R

Robin2:
I doubt that that will be easier than using Serial over a USB cable.

...R

Probably not, but it would help to lower the cost in an commercial application.
For now I am only testing some kind of noise reduction, so I need many ADC readings coming in.

So for the future, to consider the I2C early might be the way to go. The Arduino IDE serial monitor is great, but does not export the output to a file, unless I have overlooked it.

Nano2PI:
Probably not, but it would help to lower the cost in an commercial application.

If this is a commercial project it does not seem to me to be fair to be trying to get free advice on this Forum to bolster your profits. Why not hire professional advice.

Separately, I can't see how there is a difference in cost between free Serial communication and free I2C communication.

...R

Robin2:
If this is a commercial project it does not seem to me to be fair................
...R

You can't be serious, is this the the opinion of the manufacturer of the products?

The project is to collect sensor data and analyse it. The hardware is not part of a commercial project, nor am I a company.

Did you read your "AboutUs"?

It says ".. tool for IoT product development ..". That sounds quite a bit commercial to me. Please talk to your CEOs about this and let me know what they think.

Nano2PI:
Please talk to your CEOs about this and let me know what they think.

Please you understand that everyone giving their time here is doing it voluntarily without any pay or any CEO.

That is why I do not wish my free time to engorge the wallet of anyone developing a commercial product. I am very happy to help with non-commercial personal hobby projects.

...R

Nano2PI:
You can't be serious, is this the the opinion of the manufacturer of the products?

The project is to collect sensor data and analyse it. The hardware is not part of a commercial project, nor am I a company.

Did you read your "AboutUs"?

It says ".. tool for IoT product development ..". That sounds quite a bit commercial to me. Please talk to your CEOs about this and let me know what they think.

What CEO?

I certainly do not work for Arduino !

Get your facts straight.

.