Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Namespace' object has no attribute 'csv', reading_from_computer_python #25

Open
nenp93 opened this issue Dec 19, 2023 · 9 comments
Open

Comments

@nenp93
Copy link

nenp93 commented Dec 19, 2023

Hello,
I'm completely new to arduino and python. I need to give my arduino due coordinates from a csv file, which a programs creates on my pc. The arduino is used to controll a robot arm. I'm trying to dive in arduino an python programming and tried to run the example ,,reading_from_computer_python''. I copied the sketch for arduino and uploaded it successfully. When I try to run python --csv hurricanes-csv in the command window on my pc, the following error occures: line 42, in
with open(args.csv .name, 'rb') as f:
^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'csv'. Did you mean: 'csv '?

What am I doing wrong?

@michalmonday
Copy link
Owner

michalmonday commented Dec 19, 2023

Hello,
It looks like in your example there's a space between args.csv and .name. I think removing that space should fix the error, but let me me know if that's not the case.

It doesn't look like that space is in the original file:
image

@nenp93
Copy link
Author

nenp93 commented Dec 19, 2023

Hello,
thanks for the fast respond. To my shame it was the space. I don't know how it went there. The next error is: line 74, in
s.port = COM3
^^^^
NameError: name 'COM3' is not defined

My arduino is connected with COM 3.
Could you please help me again?

with best regards

@michalmonday
Copy link
Owner

In Python strings need to be enclosed in single or double quote characters like:

s.port = "COM3"

Otherwise the program would think that "COM3" is a variable. Btw if you take a look at the arduino_serial.py example, it automatically finds a port with "arduino" in its name, if multiple ports like that are found then it lets the user to select which one to use.

@nenp93
Copy link
Author

nenp93 commented Dec 20, 2023

Allright it worked. But the next issue is right around the corner. Independant which USB port from my Arduino Due I am using, the command window doesn't receive or doesn't print the data. After I run the command, it looks like on the screenshot and I can only close the window. I can't type anything.
Screenshot 2023-12-20 164404

@michalmonday
Copy link
Owner

Is Arduino Due running the reading_from_computer_python.ino example?

@nenp93
Copy link
Author

nenp93 commented Dec 20, 2023

yes

@michalmonday
Copy link
Owner

It looks like the reading_from_computer_python.ino example has a bug that only happens when clock of the board is too fast.

A quick workaround would be to replace this line:

cp << Serial.read();

with this line:

cp << Serial.readString();

I'm going to fix it properly in the future

@nenp93
Copy link
Author

nenp93 commented Dec 20, 2023

unfortunately the quick workaround does'nt solve the problem. I will keep on trying.

@michalmonday
Copy link
Owner

I modified the reading_from_computer_python.ino example and added the new one reading_from_computer_python_row_by_row which should use much less memory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants