<div dir="ltr">Hey Rhys,<div><br></div><div>You've found a bit of sample code for a function, but then used it as a method.</div><div><br></div><div>Methods get passed an additional argument on call, that of the object itself, usually named as `self`.</div><div><br></div><div>So just adding that argument in is sufficient:</div><div><br></div><div>def L76X_GetMoreData(self, GPS_Speed, SPD_Direction):</div><div><br></div><div>But if you're passing in parameters from itself anyway, so you could remove those and reference self.GPS_Speed anyway, but then, you're not actually using those parameters, so I kind of wonder why.</div><div><br></div><div>I can suggest downloading JetBrains's Python IDE, PyCharm, which'll help identify problems like these as you type. It's not open source, but it's a key part of my professional toolkit.</div><div><br></div><div>Dave.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 13 Jul 2022 at 23:29, Rhys Sage via Swlug <<a href="mailto:swlug@mailman.lug.org.uk">swlug@mailman.lug.org.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I found a lot of the demo code for the L76D doesn't actually work. Rather than modify it, I'm trying to add my own sections. I'm struggling a bit on my own with the Python so here's what I'm doing....<br>
<br>
In Main.py I'm using this...<br>
<br>
x.L76X_GetMoreData(x.GPS_Speed,x.GPS_Direction)<br>
print('Speed ', x.GPS_Speed, ' Direction ', x.GPS_Direction)<br>
<br>
in the L76X code I'm using this:<br>
<br>
def L76X_GetMoreData(GPS_Speed, GPS_Direction):<br>
#data = GPS_DATA<br>
for i in range(0, BUFFSIZE-71):<br>
if(ord(data[add]) == 36 and ord(data[add+1]) == 71 and (ord(data[add+2]) == 78 \<br>
or ord(data[add+2]) == 80) and ord(data[add+3]) == 82 and ord(data[add+4]) == 77\<br>
and ord(data[add+5]) == 67):<br>
print("Bloody Hell, it works!") <br>
# self.GPS_Speed = 0<br>
# self.GPS_Direction = 0<br>
#self.GPS_DATA = ""<br>
<br>
But I'm getting errors...<br>
<br>
Traceback (most recent call last):<br>
File "<stdin>", line 56, in <module><br>
TypeError: function takes 2 positional arguments but 3 were given<br>
<br>
I am mightily confused by this. What's going on? What am I misunderstanding?<br>
<br>
Rhys Sage<br>
<br>
-- <br>
Swlug mailing list<br>
<a href="mailto:Swlug@mailman.lug.org.uk" target="_blank">Swlug@mailman.lug.org.uk</a><br>
<a href="https://mailman.lug.org.uk/mailman/listinfo/swlug" rel="noreferrer" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/swlug</a><br>
</blockquote></div>