CSV-Parser-for-Arduino icon indicating copy to clipboard operation
CSV-Parser-for-Arduino copied to clipboard

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

Open nenp93 opened this issue 1 year ago • 9 comments

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?

nenp93 avatar Dec 19 '23 18:12 nenp93

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

michalmonday avatar Dec 19 '23 19:12 michalmonday

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

nenp93 avatar Dec 19 '23 20:12 nenp93

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.

michalmonday avatar Dec 19 '23 23:12 michalmonday

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

nenp93 avatar Dec 20 '23 15:12 nenp93

Is Arduino Due running the reading_from_computer_python.ino example?

michalmonday avatar Dec 20 '23 16:12 michalmonday

yes

nenp93 avatar Dec 20 '23 16:12 nenp93

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

michalmonday avatar Dec 20 '23 17:12 michalmonday

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

nenp93 avatar Dec 20 '23 18:12 nenp93

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.

michalmonday avatar Dec 26 '23 19:12 michalmonday