AltME: REBOL3

Messages

Bo
And here's how to write/read data to/from the serial port:
ser/awake: func [event /local p][
    p: event/port
    switch event/type [
        lookup  [open p]
        connect [write p to-binary request]
        read [
           result: to-string p/data
           close p
           return true
        ]
        wrote [read event/port]
    ]
    false
]
write ser "ping^/"
s: wait [ser 5]
print to-string s/data
Bo
The problem I have now is that I cannot figure out how to read data from the serial port. I always only get back the last command I wrote to the serial port in s/data.

Bo
Hmm, I guess nobody has any ideas here nor on Stack Overflow. :-(

Pekr
Isn't serial port occupied by other app? I very vaguely remember, I once met such situation too. Or it might be related to USB to serial converted, not sure ....
Gregg
I've only ever used R2 for serial port work.

Arnold
Bo, what is wrote [read event/port] ? Is it a typo you only made here?
Arnold
(I saw on SO you also had WROTE not WRITE)

Marco
@Bo . Try also to search for "gs: open" in this group (6-dec-2015 by Josh)
Bo
Arnold: "wrote [read event/port]" is part of the awake handler.
Bo
@Marco: Thanks! That's what I was looking for!

amacleod
does r3 not have a set-net function?
"** Script error: set-net has no value"

Gregg
Protocols were never completed for R3.

Bo
A long time ago (Sep 2014 I believe), I wrote a question here but never got an answer. I did eventually figure it out, but I recently had to figure it out again, so I'm posting it here for posterity:
Here's the solution when encountering the following:
$ sudo ./r3
sudo: unable to execute ./r3: No such file or directory
ARM devices running 64-bit operating systems don't generally have the 32-bit libraries installed. This can be fixed with the following commands:
sudo dpkg --add-architecture armhf
sudo apt install libc6:armhf libncurses5:armhf libstdc++6:armhf
After installing those libraries, the executable should now run!
A similar procedure can be performed for Intel machines as well by replacing the "armhf" with "i386".

Endo
Thank you for posting this Bo, I had this issue several times and it was diffcult for me to find.

Bo
:-)

GiuseppeC
How could I find the corresponding date for:
"The monday of 2 weeks ago"
"The next sunday"
"The last day of the current/next/prev month ?"
Ashley
The monday of 2 weeks ago ... either now/weekday = 1 [now - 14][now - (6 + now/weekday)]
The next sunday ... either now/weekday = 7 [now + 7][now + (7 - now/weekday)]
The last day of the current/next/prev month ... http://www.rebol.org/view-script.r?script=date-time.r

Gregg
Giuseppe, individual date calcs are relatively easy. Designing a dialect to interpret human expressions of them is more work, though still doable. I have a number of things that do part of it, but no complete, open system I can post.
Watch for boundary issues. Here are a couple helpers that show what I mean.
set 'last-day-of-month func [date /local d] [
    d: date
    d/day: 1
    d/month: d/month + 1
    d: d - 1
    d
]
set 'same-day-next-month func [date /local d] [
    d: date
    d/month: d/month + 1
    if d/day < date/day [d: d - d/day]
    d
]
GiuseppeC
Ashley, how if I need to calculate a generic monday of N weeks AGO
or
sunday of N weeks in the future ?
Gregg
What have you tried so far Giuseppe?

Last message posted 11 weeks ago.