uvic-auvic / polaris

2019 Submarine Code.
0 stars 6 forks source link

Monitor/serial_manager.cpp cannot connect with powerboard #13

Open anijjar opened 4 years ago

anijjar commented 4 years ago

Background: The Powerboard will not connect with the jetson.

anijjar commented 4 years ago

Here is a txt file with the powerboard firmware pwer board firm.txt

robwasmann commented 4 years ago

With regard to Jetson Monitor/serial_manager.cpp lines 74 and 75: '65536ul' is meant to be defining the size passed in to the readline function (to be 16 bits unsigned long). However 2^16 -1 is 65535 and not 65536. I would use uint16_t instead.

However, if you look at the actual readline method in wjwwood's serial.cc implementation you can see that the buffer used in that function is a character array. And that the size var that is passed in is the size of the length of that array. ie how many char it should be. Not the size in bits.

Anyway, the readline function just reads until it finds the eol character. But it is obviously kinda bad because it's allocating memory for a buffer of 65536 characters. 65KB.

This 65536ul size is also being used in power_board.cpp on line 68.

Line 75 is just finding the result of a comparison and storing that bool in device_found.

anijjar commented 4 years ago

Right, I understand line 75 after I found some random line of code somewhere on github. I think you are on to something, Lets change that section tommorow at the meeting. @robwasmann

robwasmann commented 4 years ago

I don't think it would make anything crash to allocate the 65K, but we can try changing it anyway to something more reasonable.