Jump to content
THIS IS THE TEST SITE OF EUROBRICKS! ×
THIS IS THE TEST SITE OF EUROBRICKS!

Recommended Posts

  • Replies 359
  • Created
  • Last Reply

Top Posters In This Topic

Posted
9 minutes ago, Lok24 said:

Ah, thats different!.

Look here:

https://pybricks.com/projects/sets/technic/42131-cat-bulldozer/powered-up-remote/#program

and scroll to the code-window, there's a blue "copy" button upper right the code, use this and then ctrl-v to insert in code.pybricks.com

That is my problem! There seems to be a Problem with the copied code. Thats why i need an already filled code site with this in it!!!

Posted

Again i use my phone for this. But i just read somewhere that using a phone with pybricks can cause copy issues. 

I ordered a bluetooth 5.0 dongle for the pc. Quite a cheap one. Hope that works!

Posted

@Polarlicht just going to throw this out there.  I am loving pybricks for almost everything.  However, I wasn't a fan of the pybricks Cat variant because it didn't implement the 'subtractor' control layout. In fact, of the 8 or so hubs I converted, this is the only one I switched back to the original firmware.

Posted

Whats a subtractor?

13 minutes ago, shroomzofdoom said:

@Polarlicht just going to throw this out there.  I am loving pybricks for almost everything.  However, I wasn't a fan of the pybricks Cat variant because it didn't implement the 'subtractor' control layout. In fact, of the 8 or so hubs I converted, this is the only one I switched back to the original firmware.

 

Posted
4 hours ago, shroomzofdoom said:

However, I wasn't a fan of the pybricks Cat variant because it didn't implement the 'subtractor' control layout.

But that does not explain @Polarlicht's problem, does it? You are describing something that was/is missing, he is facing a corrupt program (at least, this is what I understood).

Question is, did the program that did not have the subtractor control work for the remaining functions? Or was it corrupt in the first place?

I find this very strange, to say the least. For me, the initial starting point is: Does the PyBricks program for the CAT work on other platforms? May have been answered yet, I did not follow all the content in this thread.

Best regards,
Thorsten

Posted (edited)

Sorry for the detour. The Cat program loaded fine for me. Yes. I loaded mine from Chrome on Windows 10 machine. Are you using a phone or computer? 

Edited by shroomzofdoom
Posted
5 minutes ago, shroomzofdoom said:

Sorry for the detour.

Hey! Don't feel sorry at all - it's a discussion.

I don't have the problem, @Polarlicht is suffering from that issue. Which is not nice. Knowing that it works to copy the code on a win10 machine and loading it up onto the website and then into the hub via BLE connection tells that it actually may be a phone issue.

Let's see what he finds out with the dongle.

Thanks for that info!

Best,
Thorsten

 

Posted (edited)

I just did some quick tests...

First, I tried from my Samsung Note 20 and was able to download the firmware to the hub with Chrome, but ONLY when I selected 'Settings>Desktop Site' from the mobile browser.  When I tried copying and pasting the Cat code using the same method I got 'Indentation error'.  

hbHEDQ.md.jpg

Second, I used a BT enabled Chromebook and was able to copy/paste the code no problem.

Edited by shroomzofdoom
Posted (edited)
16 minutes ago, shroomzofdoom said:

'Indentation error'

That is important information!!! Thanks for doing this!

It means that you may be to resolve the issue by "just" removing all the spaces - creating the indention just for making the code "looking nice".

Does PyBricks "natively" use tabs for indention? This messed up things in the past, as the tab code was replaced upon copying, by replacing the tab code with x spaces, x depending on the IDE settings.

No clue, just guessing.

Best,
Thorsten

Edited by Toastie
Posted (edited)
9 minutes ago, Toastie said:

That is important information!!! Thanks for doing this!

It means that you may be to resolve the issue by "just" removing all the spaces - creating the indention just for making the code "looking nice".

ALL code is very particular about indentation and syntax. Too many tabs or a stray character and it won't work.

It's not as easy as just removing spaces, the indents have to be EXACTLY like it shows in the code snippet that pybricks posted

Edited by shroomzofdoom
Posted
7 hours ago, shroomzofdoom said:

I just did some quick tests...

First, I tried from my Samsung Note 20 and was able to download the firmware to the hub with Chrome, but ONLY when I selected 'Settings>Desktop Site' from the mobile browser.  When I tried copying and pasting the Cat code using the same method I got 'Indentation error'.  

hbHEDQ.md.jpg

Second, I used a BT enabled Chromebook and was able to copy/paste the code no problem.

Yes, i had this exact problem! I removed all indenteations and was able to load it on the Hub with no errors, but i guess it still didn't like that...

Posted (edited)

I just did a link with code to a filled CAT code site myself. But hub and controll still can't find each other and won't connect.

But it worked fine with the Volvo... No errors and works on first try

But the Volvo steering isn't quite centered! Is there a way to set the center??

Edited by Polarlicht
Posted
9 hours ago, shroomzofdoom said:

ALL code is very particular about indentation and syntax.

That is 100% correct for the syntax - but usually (and as far as I have seen it with BASIC, VB6, Pascal, C, C++, NQC, RobotC :pir-wink:, tabs and spaces (and sometimes other characters as well) are treated as "white space" by the interpreter or compiler. They are just for the "looks" and structure appearance. Well, that is what I thought.

That is also why I thought removing these white spaces should not change the code itself at all. However, I just looked up "indentation"  regarding Pybricks - and it really does matter, even one space too much (or less) may result in non-functioning code, according to discussions on GitHub.

I looked at the code in Notepad++ (using the copy button on the referenced website or simply c/p the window content) leads to the same result: All appears to be good with the code - every indentation is exactly 4 spaces.

So this is then maybe indeed a c/p issue when using the smart device - would have never expected that.

Best
Thorsten

Posted

This indentation is the basic coding method of python, as there are no end/loop statements.

They are - more or less - essential part of the code.

 

Posted
30 minutes ago, Lok24 said:

They are - more or less - essential part of the code

I understand. Never used before Python - I tried to read the code, @Polarlicht wants to upload, and just did not understand how the interpreter/compiler can tell, where a loop/while/if beginning with the ":" structure actually ends. The indentation then makes perfect sense.

Good to know - I may also try it ...

Are 4 spaces equivalent to one tab?

Best,
Thorsten

Posted
9 minutes ago, Polarlicht said:

I copied it from their website and had to remove unnecesary indentation. All done on phone.

When I open your code in Notepad++ with the option of showing all characters, the end-of-line character (EOL) is a linefeed (LF, 0x0A).

When I copy the code from the Pybricks website, EOL is a carriage return (CR, 0x0D) followed by 0x0A, i.e. CR LF. 

Could it be that something on your phone strips the CR at the end of line? Happens indeed here and there when using different viewers/editors.

I have no clue though what the EOL code for Pybricks really is.

Best,
Thorsten

Posted
36 minutes ago, Toastie said:

I understand. Never used before Python - Are 4 spaces equivalent to one tab?

 

Number of spaces has to be the same in a block, but not equal for the complete program.

"4" is just one of very many valid numbers

You can change it via your IDE whatever you llike, if > 0.  "4" ist often used as a standard.

And use differnt number of spaces in different blocks. (which istn't really useful, but not "wrong")

Posted
3 minutes ago, Polarlicht said:

Iam not into these things...

And I am not into many other things :pir-huzzah2:.

Familiar with typewriters? From the good'ol days? When you typed something and then the right end of the carriage came close, you would be pushing the lever on the left end of the carriage so that you end up at the left end and can do more typing. Moving it to the left end (by pushing it to the right :pir-laugh:) = carriage return (CR), the mechanism in the carriage also moved the platen one "line" up by rotating it = line feed (LF). You won't believe how many weird names from that time are in use today for ultra-high powered computers ... tabulator (tab), backspace, shift, cut and paste ... (https://en.wikipedia.org/wiki/Typewriter, scroll close to the end).

Now, on any text editor running on a computer, there is normally no carriage nor a lever :pir_laugh2: ... but at the end of a line in the editor window, or word processor, you usually hit "return" to start a "new line" provided it does not do that automatically. In the programming world, you always have to tell the program (e.g. Pybricks) where the end of a line of code is. And that is in many cases a "carriage return" + "line feed". When you hit the return or enter key/symbol on your keyboard or smartphone, you insert a CR and LF character, which is the same as inserting "A" or "b" - but CR LF don't print on the screen; they are just stored in the file; when you type: Print "Hello world" and hit return, the computer reads: Print "Hello world" CR LF. 

Some editors (word processors) on smart devices/computers just do that one CR and no LF or the other way around. On many programming editors you can tell it, what to insert at the end of a line: CR or LF or CR+LF.

In your code there is only LF at the line end, in the code copied from the Pybricks website there is CR+LF at each line end.

Best,
Thorsten

1 hour ago, Lok24 said:

"4" is just one of very many valid numbers

You can change it via your IDE whatever you llike, if > 0.  "4" ist often used as a standard.

Thanks a lot, Werner!!!

Posted (edited)

I'll try to answer some of the questions here. Let me know if I missed anything.

----

Copy pasting

@Polarlicht, since copy-pasting doesn't seem to work well on mobile phones, you could do this instead:

- Save the program on your computer. Just paste the contents in a text editor and save it as my_program.py.

- Send it to your phone using email or something else. Personally I use Dropbox on all my devices.

- In Pybricks Code, use the open button to upload your script. This should preserve all the spacing.

Or get a Bluetooth dongle for your PC for a few euros/dollars. Looks like you've got one on the way already. Nice!

----

How to check programs stored on the hub

Usually, it's best to test your program before you save it on the hub. That way, you can easily see output and errors in the app.

But you can also do that for a program already stored on the hub. To do that:

- Turn the hub on.

- Connect via Bluetooth in Pybricks Code.

- Click the button to start the program saved on the hub.

- Now you can read any output or errors in the app output window.

---

Should we make a block language for Pybricks?

Seriously. Would it be worth the effort? Would the community like to help make this happen?

---

More example programs

21 hours ago, shroomzofdoom said:

@Polarlicht just going to throw this out there.  I am loving pybricks for almost everything.  However, I wasn't a fan of the pybricks Cat variant because it didn't implement the 'subtractor' control layout. In fact, of the 8 or so hubs I converted, this is the only one I switched back to the original firmware.

Thanks! Many of the programs on our site are made by the community, and we're certainly looking for more example programs. It would be cool to add a program like you describe. Would anyone like to make one and share it?

Edited by Pybricks
Posted

That information about the typewriters and terminology is very interesting @Toastie, thanks for sharing!

9 hours ago, Pybricks said:

Should we make a block language for Pybricks?

Seriously. Would it be worth the effort? Would the community like to help make this happen?

What would the benefit be over the official Lego block languages (MINDSTORMS and PoweredUp)?

My instinct is to say no, as it could take  resources away from developing the current IDE - which is so good and has features that I'm looking forward to.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.

Announcements

  • THIS IS THE TEST SITE OF EUROBRICKS!

×
×
  • Create New...