Dryos Basic scripting

  • 64 Replies
  • 25058 Views
*

Offline reyalp

  • ******
  • 11514
Re: Dryos Basic scripting
« Reply #20 on: 14 / August / 2010, 20:50:57 »
Advertisements
function syntax
Code: [Select]
private function twoplus(arg)
twoplus = arg + 2
end function

...
if twoplus(2) = 4 then
LCDMsg_SetStr(b, "twoplus(2) = 4")
end if
...

On another note:
The StartRedirectUART() function mentioned in the PDF is quite useful.

I found (on D10) that the first Printf line didn't get sent to the log unless I put a Wait(10) after the StartRedirectUART()

edit:
There also appears to be an "extern" keyword.

edit:
I've updated the wiki page with adapted versions of  Alfredo and Orens original PDF documentation, as well as some additional observations.
« Last Edit: 14 / August / 2010, 23:42:14 by reyalp »
Don't forget what the H stands for.

*

Offline reyalp

  • ******
  • 11514
Re: Dryos Basic scripting
« Reply #21 on: 15 / August / 2010, 00:01:23 »
@reyalp, multiply(*) is working in your D10?
It seems that a=2*2 crashes my a710, but a=2+2 works

Looks like they use space to decide if it's a pointer dereference or multiplication.

Code: [Select]
StartRedirectUART(1)
Wait(10)
a = 2 * 2
b = &a
Printf("%d %08X\n",a,b)
*b = 42
Printf("%d %08X\n",a,b)
output:
Code: [Select]
4 0034E414
42 0034E414

If I change it to 2*2 with no space, it asserts.

edit:
The same applies to & which can be bitwise and or "address of"

The C bitwise operators << >> | & all seem to produce the expected results.

!, % and ~ all appear to assert.

edit: Some more oddities
Why is there peek and poke if you can just do *ptr ? I guess MMIO might require actual byte or halfword access.

There don't seem to be any logical operators, e.g I don't see any way to say
if x = 1 and y = 3 ....
& and | have their regular bitwise meanings in conditionals. The C style && || don't work, and neither do the english AND OR.
« Last Edit: 15 / August / 2010, 01:12:50 by reyalp »
Don't forget what the H stands for.

*

Offline c10ud

  • ***
  • 245
Re: Dryos Basic scripting
« Reply #22 on: 15 / August / 2010, 12:52:44 »
very interesting stuff!

just tried the firmware dumper with a SX200 and it worked great altrough the screen isn't showing any message.. i'll now make some more tests, too bad i don't own a 2010 camera :(

edit: uartredirect seems working too
« Last Edit: 15 / August / 2010, 12:58:44 by c10ud »

*

Offline reyalp

  • ******
  • 11514
Re: Dryos Basic scripting
« Reply #23 on: 15 / August / 2010, 14:23:23 »
very interesting stuff!

just tried the firmware dumper with a SX200 and it worked great altrough the screen isn't showing any message..
Was the upper left of the screen black or very dark ? The default text color is black, so you won't see the messages if there are no images on the camera, or that part of the image is dark. In my experience, the camera will shut down if you try to call a non-existent function.
Don't forget what the H stands for.


*

Offline c10ud

  • ***
  • 245
Re: Dryos Basic scripting
« Reply #24 on: 15 / August / 2010, 15:04:36 »
i checked the firmware's strings and they indeed exist and don't crash the camera, since i didn't have any pic i guess it's just black on black then :)

*

Offline fe50

  • ******
  • 3088
  • IXUS50 & 860, SX10 Star WARs-Star RAWs
    • fe50
Re: Dryos Basic scripting
« Reply #25 on: 15 / August / 2010, 16:00:00 »
Was the upper left of the screen black or very dark ?
LOL - the color palette also wasn't really friendly to me when i did a fast test on my SD870 yesterday - black on black !
...with a white image the text is visible, dark-red on this camera.

*

Offline msl

  • *****
  • 1237
  • A720 IS, SX220 HS 1.01a
    • CHDK inside
Re: Dryos Basic scripting
« Reply #26 on: 15 / August / 2010, 16:02:12 »
Good investigations - respect for your work.

"Hello world" and firmware dump script work properly for a720. But the text color is red!

msl
German CHDK pages:  CHDK forum | CHDK inside | CHDK Twitter News by msl | Download CHDK-DE (Autobuild)
Note: SDM violates the GPL rules!

*

Offline reyalp

  • ******
  • 11514
Re: Dryos Basic scripting
« Reply #27 on: 15 / August / 2010, 20:38:15 »
StartRedirectUART() actually takes two arguments. The second is a file name. NULL gives you the auto generated filenames. If you specify a filename, output is appended to it.

I'm not completely sure what the first is, but it looks like it's a buffer size, which is rounded up to 8192.

Note also that this won't normally capture the camera log, but you can do ShowCameraLog() to record recent entries. Other functions that print to the camera console, such as ShowAllTaskInfo will also get logged.
Don't forget what the H stands for.


Re: Dryos Basic scripting
« Reply #28 on: 16 / August / 2010, 00:54:42 »
Excellent info reyalp.

One procedure that we couldn't make work was drysh(), it actually spawns a shell (Yes! a shell!) and connects it's output to stdout and stdin. I could see the shell output via StartRedirectUART() but sadly couldn't redirect stdin to it in any way. It would be great to issue commands to this "shell".

*

Offline reyalp

  • ******
  • 11514
Re: Dryos Basic scripting
« Reply #29 on: 16 / August / 2010, 01:53:07 »
Excellent info reyalp.

One procedure that we couldn't make work was drysh(), it actually spawns a shell (Yes! a shell!) and connects it's output to stdout and stdin. I could see the shell output via StartRedirectUART() but sadly couldn't redirect stdin to it in any way. It would be great to issue commands to this "shell".
You'd have to hook up your own device driver. This is how output was camera console output was captured on vxworks cameras. (see generic/main.c  console_init)  This is easier on vxworks though, since complete documentation is readily available.

Or figure out how to physically wire up to the UART :)

Another oddity:
I tried to use PostLogicalEvent* to switch to rec mode (exact same sequence as CHDK uses) and shoot pictures, but the events to switch to rec mode only get processed after the script ends, even if you Wait().
Don't forget what the H stands for.

 

Related Topics