Go Down

Topic: Any Raspbian bash script examples for USB serial (Read 497 times) previous topic - next topic

Nano2PI

Nov 11, 2019, 05:43 pm Last Edit: Nov 11, 2019, 06:11 pm by Nano2PI
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.

Nano2PI

#1
Nov 11, 2019, 06:07 pm Last Edit: Nov 11, 2019, 06:26 pm by Nano2PI
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.

Robin2

#2
Nov 11, 2019, 06:35 pm Last Edit: Nov 11, 2019, 06:36 pm by Robin2
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
Two or three hours spent thinking and reading documentation solves most programming problems.

Robin2

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

I am suggesting to the Moderator to delete this Thread.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Coding Badly


ballscrewbob

REPORT TO MODERATOR IS NOT A REPLY BUTTON

Bob.



It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

Nano2PI

#6
Nov 11, 2019, 10:28 pm Last Edit: Nov 11, 2019, 11:09 pm by Nano2PI
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.

Robin2

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.

Quote
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++

Quote
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
Two or three hours spent thinking and reading documentation solves most programming problems.

Nano2PI

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.

Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

Nano2PI

#10
Nov 12, 2019, 06:13 pm Last Edit: Nov 12, 2019, 06:15 pm by Nano2PI
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.


Robin2

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
Two or three hours spent thinking and reading documentation solves most programming problems.

ieee488

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.

.

Go Up