<jhass>
Virviil: lib LibC; fun ioctl(...); LibC.ioctl(...)
<jhass>
FLOOR_9_: see if spawning a new coroutine for each accepted socket helps any
<jhass>
FLOOR_9_: also make sure to close the client socket
<Virviil>
jhass: Nice! And to wrap it somewhere i can just call LibC.ioctl, and put outed value to return from some method?
<jhass>
Virviil: probably, I didn't look at the parameters for ioctl
<jhass>
Virviil: note that all of our IO goes through libevent by default, so messing with the FDs directly might not be too wise depending on what you're doing
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
trapped has joined #crystal-lang
<jhass>
Virviil: because none of the APIs bound used an uchar yet
<jhass>
well actually uchar == char and there's schar?
<jhass>
idk C
<Virviil>
jhass: It's just come from background - 'u' means 'unsigned'. 's' prefix is absolutely no obvious
<Virviil>
as for me
<Virviil>
I'll make an issue, mb we could discuss a bit at the github
fowlduck has quit [Remote host closed the connection]
waterlink has joined #crystal-lang
sane_k_ has quit [Ping timeout: 272 seconds]
<waterlink>
Hi all. Toying around with alternative anonymous function syntax, typeof and concurrency: https://github.com/waterlink/streams - probably that is how Crystal is not intented to be used :D
<waterlink>
I have discovered very interesting thing about anonymous functions (blocks and lambdas): that in cases when compiler can not figure out types of block/lambda, it asks developer to fully annotate it. Turns out that with a bit of generics and typeof, you can annotate only arguments and you do not need to annotate the result (that is where typeof + allocate comes into the play)
shama has joined #crystal-lang
tomchapin has joined #crystal-lang
<Virviil>
how to get errno from calling C functions?
<jhass>
Virviil: raise Errno.new("ioctl")
<Virviil>
jhass: For example I call fd = LibC.open
<jhass>
raise Errno.new("open") if fd < 0
<Virviil>
jhass: And in this exception would be the error reason?
<jhass>
yes
<crystal-gh>
[crystal] radarek opened pull request #1938: Array#sort_by & Array#sort_by! calls given block only once for each element (master...sort_by_calls_block_once_for_each_element) http://git.io/vRHIc
fowlduck has joined #crystal-lang
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
fowlduck has quit [Ping timeout: 240 seconds]
FLOOR_9_ has joined #crystal-lang
FLOOR_9_ has quit [Client Quit]
<Virviil>
is it good idea to make nonblicking serialport, or no?
<Virviil>
As i understand, when nonblocking you can loose part of the message, get zeroes instead of missing bytes?
<jhass>
ideally you would hook it up with libevent so that if the call would block the current coroutine is suspended and then resumed when data is ready
<jhass>
no
<Virviil>
jhass: "no" for what?
<jhass>
the data loss
<jhass>
can't you subclass FileDescriptorIO or something?
<jhass>
subclass or wrap
<jhass>
I just realize how little I know about how serialports are exposed on linux
<Virviil>
jhass: I thought about include IO
<Virviil>
jhass: As i understand, for example, I get 4 data bytes in serail in 4 seconds - 1 byte in second. [1,2,3,4]. If the mode is blocking, the call of serialport.read(4) would block the thread for 4 seconds and then return [1,2,3,4]. But in nonblocking mode, the thread would not be blocked, and because i didnt get more then 1 byte in the port, it would return [1,0,0,0]
<Virviil>
So this is wht i mean in data loss
<jhass>
if the nonblocking interface would be directly exposed to the user, you wouldn't return [1, 0, 0, 0] but [1] or [1, 0, 0, 0] and "sucessfully read 1 byte of the 4 you requested"
<jhass>
but since we can suspend the current coroutine when the user requests 4 bytes but we only got 1 from our nonblocking call, it can look to the user like a blocking call while we can run other coroutines while we wait for the data
<Virviil>
jhass: So, because of using libevent, you suggest to make serialport block?
<Virviil>
blocking*
<jhass>
nonblocking on the kernel API level but seemingly blocking to the user
<jhass>
FileDescriptorIO already does that for files, sockets etc, File subclasses it, Socket subclasses it
<Virviil>
jhass: Well, i'l try to read read this
<jhass>
Virviil: fyi Go does basically the same
aladagemre has joined #crystal-lang
fowlduck has joined #crystal-lang
<Virviil>
How to define private method? "priate" like in ruby doesnt work?
<Virviil>
put private before every def?
fowlduck has quit [Ping timeout: 250 seconds]
<Papierkorb>
Virviil: 'private' acts like a marker, every method after it will be private
<Papierkorb>
Virviil: Aaah wrong channel, thought this was #ruby
fowlduck has joined #crystal-lang
<Virviil>
Seems to me that i've finished
<Virviil>
Need some resources to test, no ideas how to do this - no serilport in my hands now(
<jhass>
uh, I'd hand you one of my $9 arduino boards, but ...
<Virviil>
jhass: i'l get seril in 5 hours, but still have no idea, how to work with FileDescriptor
<Virviil>
mb some examples, to implement into tests?
<jhass>
reading its code, tests and existing usages is your best bet, yeah
<crystal-gh>
[crystal] asterite opened pull request #1939: Make `String#split` keep all results. Fixes #1070 (master...string_split_keep_all_results) http://git.io/vRHPm
ozra has quit [Ping timeout: 240 seconds]
ozra has joined #crystal-lang
fowlduck has quit [Remote host closed the connection]