Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

first commit

  • Loading branch information...
commit cb856b7a0bb51afd2350cced966105a1aed4ef68 0 parents
Elias Karakoulakis authored May 17, 2012
2,371  EIBConnection.rb
... ...
@@ -0,0 +1,2371 @@
  1
+# 
  2
+#   EIBD client library
  3
+#   Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
  4
+# 
  5
+#   This program is free software; you can redistribute it and/or modify
  6
+#   it under the terms of the GNU General Public License as published by
  7
+#   the Free Software Foundation; either version 2 of the License, or
  8
+#   (at your option) any later version.
  9
+# 
  10
+#   In addition to the permissions in the GNU General Public License, 
  11
+#   you may link the compiled version of this file into combinations
  12
+#   with other programs, and distribute those combinations without any 
  13
+#   restriction coming from the use of this file. (The General Public 
  14
+#   License restrictions do apply in other respects; for example, they 
  15
+#   cover modification of the file, and distribution when not linked into 
  16
+#   a combine executable.)
  17
+# 
  18
+#   This program is distributed in the hope that it will be useful,
  19
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
  20
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21
+#   GNU General Public License for more details.
  22
+# 
  23
+#   You should have received a copy of the GNU General Public License
  24
+#   along with this program; if not, write to the Free Software
  25
+#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  26
+# 
  27
+
  28
+
  29
+require 'hexdump'
  30
+require 'socket'
  31
+include Socket::Constants
  32
+
  33
+class EIBBuffer
  34
+  attr_accessor :buffer
  35
+  def initialize(buf = [])
  36
+    @buffer = buf
  37
+  end
  38
+end
  39
+
  40
+class EIBAddr
  41
+  attr_accessor :data
  42
+  def initialize(value = 0)
  43
+    @data = value
  44
+  end
  45
+end
  46
+
  47
+class EIBInt8
  48
+  attr_accessor :data
  49
+  def initialize(value = 0)
  50
+    @data = value
  51
+  end
  52
+end
  53
+
  54
+class EIBInt16
  55
+  attr_accessor :data
  56
+  def initialize(value = 0)
  57
+    @data = value
  58
+  end
  59
+end
  60
+
  61
+class EIBInt32
  62
+  attr_accessor :data
  63
+  def initialize(value = 0)
  64
+    @data = value
  65
+  end
  66
+end
  67
+
  68
+class EIBConnection
  69
+  def initialize()
  70
+    @data = []
  71
+    @readlen = 0
  72
+    @datalen = 0
  73
+    @fd = nil
  74
+    @errno = 0
  75
+    @__complete = nil
  76
+  end
  77
+  
  78
+  def EIBSocketLocal(path)
  79
+    puts "EIBSocketLocal(path=#{path})" if $DEBUG
  80
+    if @fd != nil
  81
+      @errno = Errno::EUSERS
  82
+      return -1
  83
+    end
  84
+    fd = UNIXSocket.new(path)
  85
+    @data = []
  86
+    @readlen = 0
  87
+    @fd = fd
  88
+    return 0
  89
+  end
  90
+
  91
+  def EIBSocketRemote(host, port = 6720)
  92
+    puts "EIBSocketURL(host=#{host} port=#{port})" if $DEBUG
  93
+    if @fd != nil
  94
+      @errno = Errno::EUSERS
  95
+      return -1
  96
+    end
  97
+    fd = TCPSocket.new(host, port)
  98
+    @data = []
  99
+    @readlen = 0
  100
+    @fd = fd
  101
+    return 0
  102
+  end
  103
+  
  104
+  def EIBSocketURL(url)
  105
+    if url.start_with?('local:')
  106
+      return EIBSocketLocal(url[6..-1])
  107
+    end
  108
+    if url.start_with?('ip:')
  109
+      parts=url.split(':')
  110
+      if (parts.length == 2)
  111
+        parts << "6720"
  112
+      end
  113
+      return EIBSocketRemote(parts[1], parts[2].to_i)
  114
+    end
  115
+    @errno = Errno::EINVAL
  116
+    return -1
  117
+  end
  118
+  
  119
+  def EIBComplete()
  120
+    if @__complete == nil
  121
+      @errno = Errno::EINVAL
  122
+      return -1
  123
+    end
  124
+    return @__complete
  125
+  end
  126
+  
  127
+  def EIBClose()
  128
+    if @fd == nil
  129
+      @errno = Errno::EINVAL
  130
+      return -1
  131
+    end
  132
+    @fd.close()
  133
+    @fd = nil
  134
+  end
  135
+  
  136
+  def EIBClose_sync()
  137
+    puts "EIBClose_sync()" if $DEBUG
  138
+    EIBReset()
  139
+    return EIBClose()
  140
+  end
  141
+  
  142
+  def __EIB_SendRequest(data)
  143
+    if @fd == nil
  144
+      @errno = Errno::ECONNRESET
  145
+      return -1
  146
+    end
  147
+    if data.length < 2 or data.length > 0xffff
  148
+      @errno = Errno::EINVAL
  149
+      return -1
  150
+    end
  151
+    data = [ (data.length>>8)&0xff, (data.length)&0xff ] + data
  152
+    #puts "__EIB_SendRequest(data=#{data.inspect} length=#{data.length})" if $DEBUG
  153
+    result = data.pack("C*")
  154
+    @fd.send(result, 0)
  155
+    puts "__EIB_SendRequest sent #{result.length} bytes: #{result.hexdump}" if $DEBUG
  156
+    return 0
  157
+  end
  158
+  
  159
+  def EIB_Poll_FD()
  160
+    if @fd == nil
  161
+      @errno = Errno::EINVAL
  162
+      return -1
  163
+    end
  164
+    return @fd
  165
+  end
  166
+  
  167
+  def EIB_Poll_Complete()
  168
+    puts "__EIB_Poll_Complete()" if $DEBUG
  169
+    if __EIB_CheckRequest(false) == -1
  170
+      return -1
  171
+    end
  172
+    if @readlen < 2 or (@readlen >= 2 and @readlen < @datalen + 2)
  173
+      return 0
  174
+    end
  175
+    return 1
  176
+  end
  177
+  
  178
+  def __EIB_GetRequest()
  179
+    puts "__EIB_GetRequest()" if $DEBUG
  180
+     while true
  181
+      if __EIB_CheckRequest(true) == -1
  182
+        return -1
  183
+      end
  184
+      if @readlen >= 2 and @readlen >= @datalen + 2
  185
+        @readlen = 0
  186
+        return 0
  187
+      end
  188
+    end
  189
+  end
  190
+
  191
+  def __EIB_CheckRequest(block)
  192
+    puts "__EIB_CheckRequest(block=#{block})" if $DEBUG
  193
+    if @fd == nil
  194
+      @errno = Errno::ECONNRESET
  195
+      return -1
  196
+    end
  197
+    if @readlen == 0
  198
+      @head = []
  199
+      @data = []
  200
+    end
  201
+    if @readlen < 2
  202
+      maxlen = 2-@readlen
  203
+      result = block ? @fd.recv(maxlen) : @fd.recv_nonblock(maxlen)
  204
+      raise Errno::ECONNRESET if block and (result.length == 0)
  205
+      puts "__EIB_CheckRequest received #{result.length} bytes: #{result.hexdump})" if $DEBUG
  206
+      if result.length > 0
  207
+        @head.concat(result.split('').collect{|c| c.unpack('c')[0]})
  208
+      end
  209
+      puts "__EIB_CheckRequest @head after recv. = #{@head.inspect})" if $DEBUG
  210
+      @readlen += result.length
  211
+    end
  212
+    if @readlen < 2
  213
+      return 0
  214
+    end
  215
+    @datalen = (@head[0] << 8) | @head[1]
  216
+    if @readlen < @datalen + 2
  217
+      maxlen = @datalen + 2 -@readlen
  218
+      result = block ? @fd.recv(maxlen) : @fd.recv_nonblock(maxlen)
  219
+      raise Errno::ECONNRESET if block and (result.length == 0)
  220
+      puts "__EIB_CheckRequest received #{result.length} bytes: #{result.hexdump})" if $DEBUG
  221
+      if result.length > 0
  222
+        @data.concat(result.split('').collect{|c| c.unpack('c')[0]})
  223
+	puts "__EIB_CheckRequest @data after recv. = #{@data.inspect})" if $DEBUG
  224
+      end
  225
+      @readlen += result.length
  226
+    end #if
  227
+    return 0      
  228
+  end
  229
+
  230
+  def __EIBGetAPDU_Complete()
  231
+    puts "__EIBGetAPDU_Complete()" if $DEBUG
  232
+    @__complete = nil
  233
+    if __EIB_GetRequest() == -1
  234
+      return -1
  235
+    end
  236
+    if (((@data[0])<<8)|(@data[0+1])) != 37 or @data.length < 2
  237
+      @errno = Errno::ECONNRESET
  238
+      return -1
  239
+    end
  240
+    @buf.buffer = @data[2..-1]
  241
+    return @buf.buffer.length
  242
+  end
  243
+
  244
+
  245
+  def EIBGetAPDU_async(buf)
  246
+    puts "EIBGetAPDU_async()" if $DEBUG
  247
+    ibuf = [0] * 2;
  248
+    @buf = buf
  249
+    @__complete = __EIBGetAPDU_Complete()
  250
+    return 0
  251
+  end
  252
+
  253
+  def EIBGetAPDU(buf)
  254
+    puts "EIBGetAPDU()" if $DEBUG
  255
+    if EIBGetAPDU_async(buf) == -1
  256
+      return -1
  257
+    end
  258
+    return EIBComplete()
  259
+  end
  260
+
  261
+  def __EIBGetAPDU_Src_Complete()
  262
+    puts "__EIBGetAPDU_Src_Complete()" if $DEBUG
  263
+    @__complete = nil
  264
+    if __EIB_GetRequest() == -1
  265
+      return -1
  266
+    end
  267
+    if (((@data[0])<<8)|(@data[0+1])) != 37 or @data.length < 4
  268
+      @errno = Errno::ECONNRESET
  269
+      return -1
  270
+    end
  271
+    if @ptr5 != nil
  272
+      @ptr5.data = (((@data[2])<<8)|(@data[2+1]))
  273
+    end
  274
+    @buf.buffer = @data[4..-1]
  275
+    return @buf.buffer.length
  276
+  end
  277
+
  278
+
  279
+  def EIBGetAPDU_Src_async(buf, src)
  280
+    puts "EIBGetAPDU_Src_async()" if $DEBUG
  281
+    ibuf = [0] * 2;
  282
+    @buf = buf
  283
+    @ptr5 = src
  284
+    @__complete = __EIBGetAPDU_Src_Complete()
  285
+    return 0
  286
+  end
  287
+
  288
+  def EIBGetAPDU_Src(buf, src)
  289
+    puts "EIBGetAPDU_Src()" if $DEBUG
  290
+    if EIBGetAPDU_Src_async(buf, src) == -1
  291
+      return -1
  292
+    end
  293
+    return EIBComplete()
  294
+  end
  295
+
  296
+  def __EIBGetBusmonitorPacket_Complete()
  297
+    puts "__EIBGetBusmonitorPacket_Complete()" if $DEBUG
  298
+    @__complete = nil
  299
+    if __EIB_GetRequest() == -1
  300
+      return -1
  301
+    end
  302
+    if (((@data[0])<<8)|(@data[0+1])) != 20 or @data.length < 2
  303
+      @errno = Errno::ECONNRESET
  304
+      return -1
  305
+    end
  306
+    @buf.buffer = @data[2..-1]
  307
+    return @buf.buffer.length
  308
+  end
  309
+
  310
+
  311
+  def EIBGetBusmonitorPacket_async(buf)
  312
+    puts "EIBGetBusmonitorPacket_async()" if $DEBUG
  313
+    ibuf = [0] * 2;
  314
+    @buf = buf
  315
+    @__complete = __EIBGetBusmonitorPacket_Complete()
  316
+    return 0
  317
+  end
  318
+
  319
+  def EIBGetBusmonitorPacket(buf)
  320
+    puts "EIBGetBusmonitorPacket()" if $DEBUG
  321
+    if EIBGetBusmonitorPacket_async(buf) == -1
  322
+      return -1
  323
+    end
  324
+    return EIBComplete()
  325
+  end
  326
+
  327
+  def __EIBGetGroup_Src_Complete()
  328
+    puts "__EIBGetGroup_Src_Complete()" if $DEBUG
  329
+    @__complete = nil
  330
+    if __EIB_GetRequest() == -1
  331
+      return -1
  332
+    end
  333
+    if (((@data[0])<<8)|(@data[0+1])) != 39 or @data.length < 6
  334
+      @errno = Errno::ECONNRESET
  335
+      return -1
  336
+    end
  337
+    if @ptr5 != nil
  338
+      @ptr5.data = (((@data[2])<<8)|(@data[2+1]))
  339
+    end
  340
+    if @ptr6 != nil
  341
+      @ptr6.data = (((@data[4])<<8)|(@data[4+1]))
  342
+    end
  343
+    @buf.buffer = @data[6..-1]
  344
+    return @buf.buffer.length
  345
+  end
  346
+
  347
+
  348
+  def EIBGetGroup_Src_async(buf, src, dest)
  349
+    puts "EIBGetGroup_Src_async()" if $DEBUG
  350
+    ibuf = [0] * 2;
  351
+    @buf = buf
  352
+    @ptr5 = src
  353
+    @ptr6 = dest
  354
+    @__complete = __EIBGetGroup_Src_Complete()
  355
+    return 0
  356
+  end
  357
+
  358
+  def EIBGetGroup_Src(buf, src, dest)
  359
+    puts "EIBGetGroup_Src()" if $DEBUG
  360
+    if EIBGetGroup_Src_async(buf, src, dest) == -1
  361
+      return -1
  362
+    end
  363
+    return EIBComplete()
  364
+  end
  365
+
  366
+  def __EIBGetTPDU_Complete()
  367
+    puts "__EIBGetTPDU_Complete()" if $DEBUG
  368
+    @__complete = nil
  369
+    if __EIB_GetRequest() == -1
  370
+      return -1
  371
+    end
  372
+    if (((@data[0])<<8)|(@data[0+1])) != 37 or @data.length < 4
  373
+      @errno = Errno::ECONNRESET
  374
+      return -1
  375
+    end
  376
+    if @ptr5 != nil
  377
+      @ptr5.data = (((@data[2])<<8)|(@data[2+1]))
  378
+    end
  379
+    @buf.buffer = @data[4..-1]
  380
+    return @buf.buffer.length
  381
+  end
  382
+
  383
+
  384
+  def EIBGetTPDU_async(buf, src)
  385
+    puts "EIBGetTPDU_async()" if $DEBUG
  386
+    ibuf = [0] * 2;
  387
+    @buf = buf
  388
+    @ptr5 = src
  389
+    @__complete = __EIBGetTPDU_Complete()
  390
+    return 0
  391
+  end
  392
+
  393
+  def EIBGetTPDU(buf, src)
  394
+    puts "EIBGetTPDU()" if $DEBUG
  395
+    if EIBGetTPDU_async(buf, src) == -1
  396
+      return -1
  397
+    end
  398
+    return EIBComplete()
  399
+  end
  400
+
  401
+  def __EIB_Cache_Clear_Complete()
  402
+    puts "__EIB_Cache_Clear_Complete()" if $DEBUG
  403
+    @__complete = nil
  404
+    if __EIB_GetRequest() == -1
  405
+      return -1
  406
+    end
  407
+    if (((@data[0])<<8)|(@data[0+1])) != 114 or @data.length < 2
  408
+      @errno = Errno::ECONNRESET
  409
+      return -1
  410
+    end
  411
+    return 0
  412
+  end
  413
+
  414
+
  415
+  def EIB_Cache_Clear_async()
  416
+    puts "EIB_Cache_Clear_async()" if $DEBUG
  417
+    ibuf = [0] * 2;
  418
+    ibuf[0] = 0
  419
+    ibuf[1] = 114
  420
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  421
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  422
+    if __EIB_SendRequest(ibuf) == -1
  423
+      return -1
  424
+    end
  425
+    @__complete = __EIB_Cache_Clear_Complete()
  426
+    return 0
  427
+  end
  428
+
  429
+  def EIB_Cache_Clear()
  430
+    puts "EIB_Cache_Clear()" if $DEBUG
  431
+    if EIB_Cache_Clear_async() == -1
  432
+      return -1
  433
+    end
  434
+    return EIBComplete()
  435
+  end
  436
+
  437
+  def __EIB_Cache_Disable_Complete()
  438
+    puts "__EIB_Cache_Disable_Complete()" if $DEBUG
  439
+    @__complete = nil
  440
+    if __EIB_GetRequest() == -1
  441
+      return -1
  442
+    end
  443
+    if (((@data[0])<<8)|(@data[0+1])) != 113 or @data.length < 2
  444
+      @errno = Errno::ECONNRESET
  445
+      return -1
  446
+    end
  447
+    return 0
  448
+  end
  449
+
  450
+
  451
+  def EIB_Cache_Disable_async()
  452
+    puts "EIB_Cache_Disable_async()" if $DEBUG
  453
+    ibuf = [0] * 2;
  454
+    ibuf[0] = 0
  455
+    ibuf[1] = 113
  456
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  457
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  458
+    if __EIB_SendRequest(ibuf) == -1
  459
+      return -1
  460
+    end
  461
+    @__complete = __EIB_Cache_Disable_Complete()
  462
+    return 0
  463
+  end
  464
+
  465
+  def EIB_Cache_Disable()
  466
+    puts "EIB_Cache_Disable()" if $DEBUG
  467
+    if EIB_Cache_Disable_async() == -1
  468
+      return -1
  469
+    end
  470
+    return EIBComplete()
  471
+  end
  472
+
  473
+  def __EIB_Cache_Enable_Complete()
  474
+    puts "__EIB_Cache_Enable_Complete()" if $DEBUG
  475
+    @__complete = nil
  476
+    if __EIB_GetRequest() == -1
  477
+      return -1
  478
+    end
  479
+    if (((@data[0])<<8)|(@data[0+1])) != 1
  480
+      @errno = Errno::EBUSY
  481
+      return -1
  482
+    end
  483
+    if (((@data[0])<<8)|(@data[0+1])) != 112 or @data.length < 2
  484
+      @errno = Errno::ECONNRESET
  485
+      return -1
  486
+    end
  487
+    return 0
  488
+  end
  489
+
  490
+
  491
+  def EIB_Cache_Enable_async()
  492
+    puts "EIB_Cache_Enable_async()" if $DEBUG
  493
+    ibuf = [0] * 2;
  494
+    ibuf[0] = 0
  495
+    ibuf[1] = 112
  496
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  497
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  498
+    if __EIB_SendRequest(ibuf) == -1
  499
+      return -1
  500
+    end
  501
+    @__complete = __EIB_Cache_Enable_Complete()
  502
+    return 0
  503
+  end
  504
+
  505
+  def EIB_Cache_Enable()
  506
+    puts "EIB_Cache_Enable()" if $DEBUG
  507
+    if EIB_Cache_Enable_async() == -1
  508
+      return -1
  509
+    end
  510
+    return EIBComplete()
  511
+  end
  512
+
  513
+  def __EIB_Cache_Read_Complete()
  514
+    puts "__EIB_Cache_Read_Complete()" if $DEBUG
  515
+    @__complete = nil
  516
+    if __EIB_GetRequest() == -1
  517
+      return -1
  518
+    end
  519
+    if (((@data[0])<<8)|(@data[0+1])) != 117 or @data.length < 2
  520
+      @errno = Errno::ECONNRESET
  521
+      return -1
  522
+    end
  523
+    if (((@data[4])<<8)|(@data[4+1])) == 0
  524
+      @errno = Errno::ENODEV
  525
+      return -1
  526
+    end
  527
+    if @data.length <= 6
  528
+      @errno = Errno::ENOENT
  529
+      return -1
  530
+    end
  531
+    if @ptr5 != nil
  532
+      @ptr5.data = (((@data[2])<<8)|(@data[2+1]))
  533
+    end
  534
+    @buf.buffer = @data[6..-1]
  535
+    return @buf.buffer.length
  536
+  end
  537
+
  538
+
  539
+  def EIB_Cache_Read_async(dst, src, buf)
  540
+    puts "EIB_Cache_Read_async()" if $DEBUG
  541
+    ibuf = [0] * 4;
  542
+    @buf = buf
  543
+    @ptr5 = src
  544
+    ibuf[2] = ((dst>>8)&0xff)
  545
+    ibuf[3] = ((dst)&0xff)
  546
+    ibuf[0] = 0
  547
+    ibuf[1] = 117
  548
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  549
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  550
+    if __EIB_SendRequest(ibuf) == -1
  551
+      return -1
  552
+    end
  553
+    @__complete = __EIB_Cache_Read_Complete()
  554
+    return 0
  555
+  end
  556
+
  557
+  def EIB_Cache_Read(dst, src, buf)
  558
+    puts "EIB_Cache_Read()" if $DEBUG
  559
+    if EIB_Cache_Read_async(dst, src, buf) == -1
  560
+      return -1
  561
+    end
  562
+    return EIBComplete()
  563
+  end
  564
+
  565
+  def __EIB_Cache_Read_Sync_Complete()
  566
+    puts "__EIB_Cache_Read_Sync_Complete()" if $DEBUG
  567
+    @__complete = nil
  568
+    if __EIB_GetRequest() == -1
  569
+      return -1
  570
+    end
  571
+    if (((@data[0])<<8)|(@data[0+1])) != 116 or @data.length < 2
  572
+      @errno = Errno::ECONNRESET
  573
+      return -1
  574
+    end
  575
+    if (((@data[4])<<8)|(@data[4+1])) == 0
  576
+      @errno = Errno::ENODEV
  577
+      return -1
  578
+    end
  579
+    if @data.length <= 6
  580
+      @errno = Errno::ENOENT
  581
+      return -1
  582
+    end
  583
+    if @ptr5 != nil
  584
+      @ptr5.data = (((@data[2])<<8)|(@data[2+1]))
  585
+    end
  586
+    @buf.buffer = @data[6..-1]
  587
+    return @buf.buffer.length
  588
+  end
  589
+
  590
+
  591
+  def EIB_Cache_Read_Sync_async(dst, src, buf, age)
  592
+    puts "EIB_Cache_Read_Sync_async()" if $DEBUG
  593
+    ibuf = [0] * 6;
  594
+    @buf = buf
  595
+    @ptr5 = src
  596
+    ibuf[2] = ((dst>>8)&0xff)
  597
+    ibuf[3] = ((dst)&0xff)
  598
+    ibuf[4] = ((age>>8)&0xff)
  599
+    ibuf[5] = ((age)&0xff)
  600
+    ibuf[0] = 0
  601
+    ibuf[1] = 116
  602
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  603
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  604
+    if __EIB_SendRequest(ibuf) == -1
  605
+      return -1
  606
+    end
  607
+    @__complete = __EIB_Cache_Read_Sync_Complete()
  608
+    return 0
  609
+  end
  610
+
  611
+  def EIB_Cache_Read_Sync(dst, src, buf, age)
  612
+    puts "EIB_Cache_Read_Sync()" if $DEBUG
  613
+    if EIB_Cache_Read_Sync_async(dst, src, buf, age) == -1
  614
+      return -1
  615
+    end
  616
+    return EIBComplete()
  617
+  end
  618
+
  619
+  def __EIB_Cache_Remove_Complete()
  620
+    puts "__EIB_Cache_Remove_Complete()" if $DEBUG
  621
+    @__complete = nil
  622
+    if __EIB_GetRequest() == -1
  623
+      return -1
  624
+    end
  625
+    if (((@data[0])<<8)|(@data[0+1])) != 115 or @data.length < 2
  626
+      @errno = Errno::ECONNRESET
  627
+      return -1
  628
+    end
  629
+    return 0
  630
+  end
  631
+
  632
+
  633
+  def EIB_Cache_Remove_async(dest)
  634
+    puts "EIB_Cache_Remove_async()" if $DEBUG
  635
+    ibuf = [0] * 4;
  636
+    ibuf[2] = ((dest>>8)&0xff)
  637
+    ibuf[3] = ((dest)&0xff)
  638
+    ibuf[0] = 0
  639
+    ibuf[1] = 115
  640
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  641
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  642
+    if __EIB_SendRequest(ibuf) == -1
  643
+      return -1
  644
+    end
  645
+    @__complete = __EIB_Cache_Remove_Complete()
  646
+    return 0
  647
+  end
  648
+
  649
+  def EIB_Cache_Remove(dest)
  650
+    puts "EIB_Cache_Remove()" if $DEBUG
  651
+    if EIB_Cache_Remove_async(dest) == -1
  652
+      return -1
  653
+    end
  654
+    return EIBComplete()
  655
+  end
  656
+
  657
+  def __EIB_Cache_LastUpdates_Complete()
  658
+    puts "__EIB_Cache_LastUpdates_Complete()" if $DEBUG
  659
+    @__complete = nil
  660
+    if __EIB_GetRequest() == -1
  661
+      return -1
  662
+    end
  663
+    if (((@data[0])<<8)|(@data[0+1])) != 118 or @data.length < 2
  664
+      @errno = Errno::ECONNRESET
  665
+      return -1
  666
+    end
  667
+    if @ptr4 != nil
  668
+      @ptr4.data = (((@data[2])<<8)|(@data[2+1]))
  669
+    end
  670
+    @buf.buffer = @data[4..-1]
  671
+    return @buf.buffer.length
  672
+  end
  673
+
  674
+
  675
+  def EIB_Cache_LastUpdates_async(start, timeout, buf, ende)
  676
+    puts "EIB_Cache_LastUpdates_async()" if $DEBUG
  677
+    ibuf = [0] * 5;
  678
+    @buf = buf
  679
+    @ptr4 = ende
  680
+    ibuf[2] = ((start>>8)&0xff)
  681
+    ibuf[3] = ((start)&0xff)
  682
+    ibuf[4] = ((timeout)&0xff)
  683
+    ibuf[0] = 0
  684
+    ibuf[1] = 118
  685
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  686
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  687
+    if __EIB_SendRequest(ibuf) == -1
  688
+      return -1
  689
+    end
  690
+    @__complete = __EIB_Cache_LastUpdates_Complete()
  691
+    return 0
  692
+  end
  693
+
  694
+  def EIB_Cache_LastUpdates(start, timeout, buf, ende)
  695
+    puts "EIB_Cache_LastUpdates()" if $DEBUG
  696
+    if EIB_Cache_LastUpdates_async(start, timeout, buf, ende) == -1
  697
+      return -1
  698
+    end
  699
+    return EIBComplete()
  700
+  end
  701
+
  702
+  def __EIB_LoadImage_Complete()
  703
+    puts "__EIB_LoadImage_Complete()" if $DEBUG
  704
+    @__complete = nil
  705
+    if __EIB_GetRequest() == -1
  706
+      return -1
  707
+    end
  708
+    if (((@data[0])<<8)|(@data[0+1])) != 99 or @data.length < 4
  709
+      @errno = Errno::ECONNRESET
  710
+      return -1
  711
+    end
  712
+    return (((@data[2])<<8)|(@data[2+1]))
  713
+  end
  714
+
  715
+
  716
+  def EIB_LoadImage_async(image)
  717
+    puts "EIB_LoadImage_async()" if $DEBUG
  718
+    ibuf = [0] * 2;
  719
+    if image.length < 0
  720
+      @errno = Errno::EINVAL
  721
+      return -1
  722
+    end
  723
+    @sendlen = image.length
  724
+    ibuf.concat(image)
  725
+    ibuf[0] = 0
  726
+    ibuf[1] = 99
  727
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  728
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  729
+    if __EIB_SendRequest(ibuf) == -1
  730
+      return -1
  731
+    end
  732
+    @__complete = __EIB_LoadImage_Complete()
  733
+    return 0
  734
+  end
  735
+
  736
+  def EIB_LoadImage(image)
  737
+    puts "EIB_LoadImage()" if $DEBUG
  738
+    if EIB_LoadImage_async(image) == -1
  739
+      return -1
  740
+    end
  741
+    return EIBComplete()
  742
+  end
  743
+
  744
+  def __EIB_MC_Authorize_Complete()
  745
+    puts "__EIB_MC_Authorize_Complete()" if $DEBUG
  746
+    @__complete = nil
  747
+    if __EIB_GetRequest() == -1
  748
+      return -1
  749
+    end
  750
+    if (((@data[0])<<8)|(@data[0+1])) != 87 or @data.length < 3
  751
+      @errno = Errno::ECONNRESET
  752
+      return -1
  753
+    end
  754
+    return @data[2]
  755
+  end
  756
+
  757
+
  758
+  def EIB_MC_Authorize_async(key)
  759
+    puts "EIB_MC_Authorize_async()" if $DEBUG
  760
+    ibuf = [0] * 6;
  761
+    if key.length != 4
  762
+      @errno = Errno::EINVAL
  763
+      return -1
  764
+    end
  765
+    ibuf[2..6] = key
  766
+    ibuf[0] = 0
  767
+    ibuf[1] = 87
  768
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  769
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  770
+    if __EIB_SendRequest(ibuf) == -1
  771
+      return -1
  772
+    end
  773
+    @__complete = __EIB_MC_Authorize_Complete()
  774
+    return 0
  775
+  end
  776
+
  777
+  def EIB_MC_Authorize(key)
  778
+    puts "EIB_MC_Authorize()" if $DEBUG
  779
+    if EIB_MC_Authorize_async(key) == -1
  780
+      return -1
  781
+    end
  782
+    return EIBComplete()
  783
+  end
  784
+
  785
+  def __EIB_MC_Connect_Complete()
  786
+    puts "__EIB_MC_Connect_Complete()" if $DEBUG
  787
+    @__complete = nil
  788
+    if __EIB_GetRequest() == -1
  789
+      return -1
  790
+    end
  791
+    if (((@data[0])<<8)|(@data[0+1])) != 80 or @data.length < 2
  792
+      @errno = Errno::ECONNRESET
  793
+      return -1
  794
+    end
  795
+    return 0
  796
+  end
  797
+
  798
+
  799
+  def EIB_MC_Connect_async(dest)
  800
+    puts "EIB_MC_Connect_async()" if $DEBUG
  801
+    ibuf = [0] * 4;
  802
+    ibuf[2] = ((dest>>8)&0xff)
  803
+    ibuf[3] = ((dest)&0xff)
  804
+    ibuf[0] = 0
  805
+    ibuf[1] = 80
  806
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  807
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  808
+    if __EIB_SendRequest(ibuf) == -1
  809
+      return -1
  810
+    end
  811
+    @__complete = __EIB_MC_Connect_Complete()
  812
+    return 0
  813
+  end
  814
+
  815
+  def EIB_MC_Connect(dest)
  816
+    puts "EIB_MC_Connect()" if $DEBUG
  817
+    if EIB_MC_Connect_async(dest) == -1
  818
+      return -1
  819
+    end
  820
+    return EIBComplete()
  821
+  end
  822
+
  823
+  def __EIB_MC_Individual_Open_Complete()
  824
+    puts "__EIB_MC_Individual_Open_Complete()" if $DEBUG
  825
+    @__complete = nil
  826
+    if __EIB_GetRequest() == -1
  827
+      return -1
  828
+    end
  829
+    if (((@data[0])<<8)|(@data[0+1])) != 73 or @data.length < 2
  830
+      @errno = Errno::ECONNRESET
  831
+      return -1
  832
+    end
  833
+    return 0
  834
+  end
  835
+
  836
+
  837
+  def EIB_MC_Individual_Open_async(dest)
  838
+    puts "EIB_MC_Individual_Open_async()" if $DEBUG
  839
+    ibuf = [0] * 4;
  840
+    ibuf[2] = ((dest>>8)&0xff)
  841
+    ibuf[3] = ((dest)&0xff)
  842
+    ibuf[0] = 0
  843
+    ibuf[1] = 73
  844
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  845
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  846
+    if __EIB_SendRequest(ibuf) == -1
  847
+      return -1
  848
+    end
  849
+    @__complete = __EIB_MC_Individual_Open_Complete()
  850
+    return 0
  851
+  end
  852
+
  853
+  def EIB_MC_Individual_Open(dest)
  854
+    puts "EIB_MC_Individual_Open()" if $DEBUG
  855
+    if EIB_MC_Individual_Open_async(dest) == -1
  856
+      return -1
  857
+    end
  858
+    return EIBComplete()
  859
+  end
  860
+
  861
+  def __EIB_MC_GetMaskVersion_Complete()
  862
+    puts "__EIB_MC_GetMaskVersion_Complete()" if $DEBUG
  863
+    @__complete = nil
  864
+    if __EIB_GetRequest() == -1
  865
+      return -1
  866
+    end
  867
+    if (((@data[0])<<8)|(@data[0+1])) != 89 or @data.length < 4
  868
+      @errno = Errno::ECONNRESET
  869
+      return -1
  870
+    end
  871
+    return (((@data[2])<<8)|(@data[2+1]))
  872
+  end
  873
+
  874
+
  875
+  def EIB_MC_GetMaskVersion_async()
  876
+    puts "EIB_MC_GetMaskVersion_async()" if $DEBUG
  877
+    ibuf = [0] * 2;
  878
+    ibuf[0] = 0
  879
+    ibuf[1] = 89
  880
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  881
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  882
+    if __EIB_SendRequest(ibuf) == -1
  883
+      return -1
  884
+    end
  885
+    @__complete = __EIB_MC_GetMaskVersion_Complete()
  886
+    return 0
  887
+  end
  888
+
  889
+  def EIB_MC_GetMaskVersion()
  890
+    puts "EIB_MC_GetMaskVersion()" if $DEBUG
  891
+    if EIB_MC_GetMaskVersion_async() == -1
  892
+      return -1
  893
+    end
  894
+    return EIBComplete()
  895
+  end
  896
+
  897
+  def __EIB_MC_GetPEIType_Complete()
  898
+    puts "__EIB_MC_GetPEIType_Complete()" if $DEBUG
  899
+    @__complete = nil
  900
+    if __EIB_GetRequest() == -1
  901
+      return -1
  902
+    end
  903
+    if (((@data[0])<<8)|(@data[0+1])) != 85 or @data.length < 4
  904
+      @errno = Errno::ECONNRESET
  905
+      return -1
  906
+    end
  907
+    return (((@data[2])<<8)|(@data[2+1]))
  908
+  end
  909
+
  910
+
  911
+  def EIB_MC_GetPEIType_async()
  912
+    puts "EIB_MC_GetPEIType_async()" if $DEBUG
  913
+    ibuf = [0] * 2;
  914
+    ibuf[0] = 0
  915
+    ibuf[1] = 85
  916
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  917
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  918
+    if __EIB_SendRequest(ibuf) == -1
  919
+      return -1
  920
+    end
  921
+    @__complete = __EIB_MC_GetPEIType_Complete()
  922
+    return 0
  923
+  end
  924
+
  925
+  def EIB_MC_GetPEIType()
  926
+    puts "EIB_MC_GetPEIType()" if $DEBUG
  927
+    if EIB_MC_GetPEIType_async() == -1
  928
+      return -1
  929
+    end
  930
+    return EIBComplete()
  931
+  end
  932
+
  933
+  def __EIB_MC_Progmode_Off_Complete()
  934
+    puts "__EIB_MC_Progmode_Off_Complete()" if $DEBUG
  935
+    @__complete = nil
  936
+    if __EIB_GetRequest() == -1
  937
+      return -1
  938
+    end
  939
+    if (((@data[0])<<8)|(@data[0+1])) != 96 or @data.length < 2
  940
+      @errno = Errno::ECONNRESET
  941
+      return -1
  942
+    end
  943
+    return 0
  944
+  end
  945
+
  946
+
  947
+  def EIB_MC_Progmode_Off_async()
  948
+    puts "EIB_MC_Progmode_Off_async()" if $DEBUG
  949
+    ibuf = [0] * 3;
  950
+    ibuf[2] = ((0)&0xff)
  951
+    ibuf[0] = 0
  952
+    ibuf[1] = 96
  953
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  954
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  955
+    if __EIB_SendRequest(ibuf) == -1
  956
+      return -1
  957
+    end
  958
+    @__complete = __EIB_MC_Progmode_Off_Complete()
  959
+    return 0
  960
+  end
  961
+
  962
+  def EIB_MC_Progmode_Off()
  963
+    puts "EIB_MC_Progmode_Off()" if $DEBUG
  964
+    if EIB_MC_Progmode_Off_async() == -1
  965
+      return -1
  966
+    end
  967
+    return EIBComplete()
  968
+  end
  969
+
  970
+  def __EIB_MC_Progmode_On_Complete()
  971
+    puts "__EIB_MC_Progmode_On_Complete()" if $DEBUG
  972
+    @__complete = nil
  973
+    if __EIB_GetRequest() == -1
  974
+      return -1
  975
+    end
  976
+    if (((@data[0])<<8)|(@data[0+1])) != 96 or @data.length < 2
  977
+      @errno = Errno::ECONNRESET
  978
+      return -1
  979
+    end
  980
+    return 0
  981
+  end
  982
+
  983
+
  984
+  def EIB_MC_Progmode_On_async()
  985
+    puts "EIB_MC_Progmode_On_async()" if $DEBUG
  986
+    ibuf = [0] * 3;
  987
+    ibuf[2] = ((1)&0xff)
  988
+    ibuf[0] = 0
  989
+    ibuf[1] = 96
  990
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  991
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  992
+    if __EIB_SendRequest(ibuf) == -1
  993
+      return -1
  994
+    end
  995
+    @__complete = __EIB_MC_Progmode_On_Complete()
  996
+    return 0
  997
+  end
  998
+
  999
+  def EIB_MC_Progmode_On()
  1000
+    puts "EIB_MC_Progmode_On()" if $DEBUG
  1001
+    if EIB_MC_Progmode_On_async() == -1
  1002
+      return -1
  1003
+    end
  1004
+    return EIBComplete()
  1005
+  end
  1006
+
  1007
+  def __EIB_MC_Progmode_Status_Complete()
  1008
+    puts "__EIB_MC_Progmode_Status_Complete()" if $DEBUG
  1009
+    @__complete = nil
  1010
+    if __EIB_GetRequest() == -1
  1011
+      return -1
  1012
+    end
  1013
+    if (((@data[0])<<8)|(@data[0+1])) != 96 or @data.length < 3
  1014
+      @errno = Errno::ECONNRESET
  1015
+      return -1
  1016
+    end
  1017
+    return @data[2]
  1018
+  end
  1019
+
  1020
+
  1021
+  def EIB_MC_Progmode_Status_async()
  1022
+    puts "EIB_MC_Progmode_Status_async()" if $DEBUG
  1023
+    ibuf = [0] * 3;
  1024
+    ibuf[2] = ((3)&0xff)
  1025
+    ibuf[0] = 0
  1026
+    ibuf[1] = 96
  1027
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  1028
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  1029
+    if __EIB_SendRequest(ibuf) == -1
  1030
+      return -1
  1031
+    end
  1032
+    @__complete = __EIB_MC_Progmode_Status_Complete()
  1033
+    return 0
  1034
+  end
  1035
+
  1036
+  def EIB_MC_Progmode_Status()
  1037
+    puts "EIB_MC_Progmode_Status()" if $DEBUG
  1038
+    if EIB_MC_Progmode_Status_async() == -1
  1039
+      return -1
  1040
+    end
  1041
+    return EIBComplete()
  1042
+  end
  1043
+
  1044
+  def __EIB_MC_Progmode_Toggle_Complete()
  1045
+    puts "__EIB_MC_Progmode_Toggle_Complete()" if $DEBUG
  1046
+    @__complete = nil
  1047
+    if __EIB_GetRequest() == -1
  1048
+      return -1
  1049
+    end
  1050
+    if (((@data[0])<<8)|(@data[0+1])) != 96 or @data.length < 2
  1051
+      @errno = Errno::ECONNRESET
  1052
+      return -1
  1053
+    end
  1054
+    return 0
  1055
+  end
  1056
+
  1057
+
  1058
+  def EIB_MC_Progmode_Toggle_async()
  1059
+    puts "EIB_MC_Progmode_Toggle_async()" if $DEBUG
  1060
+    ibuf = [0] * 3;
  1061
+    ibuf[2] = ((2)&0xff)
  1062
+    ibuf[0] = 0
  1063
+    ibuf[1] = 96
  1064
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  1065
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  1066
+    if __EIB_SendRequest(ibuf) == -1
  1067
+      return -1
  1068
+    end
  1069
+    @__complete = __EIB_MC_Progmode_Toggle_Complete()
  1070
+    return 0
  1071
+  end
  1072
+
  1073
+  def EIB_MC_Progmode_Toggle()
  1074
+    puts "EIB_MC_Progmode_Toggle()" if $DEBUG
  1075
+    if EIB_MC_Progmode_Toggle_async() == -1
  1076
+      return -1
  1077
+    end
  1078
+    return EIBComplete()
  1079
+  end
  1080
+
  1081
+  def __EIB_MC_PropertyDesc_Complete()
  1082
+    puts "__EIB_MC_PropertyDesc_Complete()" if $DEBUG
  1083
+    @__complete = nil
  1084
+    if __EIB_GetRequest() == -1
  1085
+      return -1
  1086
+    end
  1087
+    if (((@data[0])<<8)|(@data[0+1])) != 97 or @data.length < 6
  1088
+      @errno = Errno::ECONNRESET
  1089
+      return -1
  1090
+    end
  1091
+    if @ptr2 != nil
  1092
+      @ptr2.data = @data[2]
  1093
+    end
  1094
+    if @ptr4 != nil
  1095
+      @ptr4.data = (((@data[3])<<8)|(@data[3+1]))
  1096
+    end
  1097
+    if @ptr3 != nil
  1098
+      @ptr3.data = @data[5]
  1099
+    end
  1100
+    return 0
  1101
+  end
  1102
+
  1103
+
  1104
+  def EIB_MC_PropertyDesc_async(obj, propertyno, proptype, max_nr_of_elem, access)
  1105
+    puts "EIB_MC_PropertyDesc_async()" if $DEBUG
  1106
+    ibuf = [0] * 4;
  1107
+    @ptr2 = proptype
  1108
+    @ptr4 = max_nr_of_elem
  1109
+    @ptr3 = access
  1110
+    ibuf[2] = ((obj)&0xff)
  1111
+    ibuf[3] = ((propertyno)&0xff)
  1112
+    ibuf[0] = 0
  1113
+    ibuf[1] = 97
  1114
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  1115
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  1116
+    if __EIB_SendRequest(ibuf) == -1
  1117
+      return -1
  1118
+    end
  1119
+    @__complete = __EIB_MC_PropertyDesc_Complete()
  1120
+    return 0
  1121
+  end
  1122
+
  1123
+  def EIB_MC_PropertyDesc(obj, propertyno, proptype, max_nr_of_elem, access)
  1124
+    puts "EIB_MC_PropertyDesc()" if $DEBUG
  1125
+    if EIB_MC_PropertyDesc_async(obj, propertyno, proptype, max_nr_of_elem, access) == -1
  1126
+      return -1
  1127
+    end
  1128
+    return EIBComplete()
  1129
+  end
  1130
+
  1131
+  def __EIB_MC_PropertyRead_Complete()
  1132
+    puts "__EIB_MC_PropertyRead_Complete()" if $DEBUG
  1133
+    @__complete = nil
  1134
+    if __EIB_GetRequest() == -1
  1135
+      return -1
  1136
+    end
  1137
+    if (((@data[0])<<8)|(@data[0+1])) != 83 or @data.length < 2
  1138
+      @errno = Errno::ECONNRESET
  1139
+      return -1
  1140
+    end
  1141
+    @buf.buffer = @data[2..-1]
  1142
+    return @buf.buffer.length
  1143
+  end
  1144
+
  1145
+
  1146
+  def EIB_MC_PropertyRead_async(obj, propertyno, start, nr_of_elem, buf)
  1147
+    puts "EIB_MC_PropertyRead_async()" if $DEBUG
  1148
+    ibuf = [0] * 7;
  1149
+    @buf = buf
  1150
+    ibuf[2] = ((obj)&0xff)
  1151
+    ibuf[3] = ((propertyno)&0xff)
  1152
+    ibuf[4] = ((start>>8)&0xff)
  1153
+    ibuf[5] = ((start)&0xff)
  1154
+    ibuf[6] = ((nr_of_elem)&0xff)
  1155
+    ibuf[0] = 0
  1156
+    ibuf[1] = 83
  1157
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  1158
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  1159
+    if __EIB_SendRequest(ibuf) == -1
  1160
+      return -1
  1161
+    end
  1162
+    @__complete = __EIB_MC_PropertyRead_Complete()
  1163
+    return 0
  1164
+  end
  1165
+
  1166
+  def EIB_MC_PropertyRead(obj, propertyno, start, nr_of_elem, buf)
  1167
+    puts "EIB_MC_PropertyRead()" if $DEBUG
  1168
+    if EIB_MC_PropertyRead_async(obj, propertyno, start, nr_of_elem, buf) == -1
  1169
+      return -1
  1170
+    end
  1171
+    return EIBComplete()
  1172
+  end
  1173
+
  1174
+  def __EIB_MC_PropertyScan_Complete()
  1175
+    puts "__EIB_MC_PropertyScan_Complete()" if $DEBUG
  1176
+    @__complete = nil
  1177
+    if __EIB_GetRequest() == -1
  1178
+      return -1
  1179
+    end
  1180
+    if (((@data[0])<<8)|(@data[0+1])) != 98 or @data.length < 2
  1181
+      @errno = Errno::ECONNRESET
  1182
+      return -1
  1183
+    end
  1184
+    @buf.buffer = @data[2..-1]
  1185
+    return @buf.buffer.length
  1186
+  end
  1187
+
  1188
+
  1189
+  def EIB_MC_PropertyScan_async(buf)
  1190
+    puts "EIB_MC_PropertyScan_async()" if $DEBUG
  1191
+    ibuf = [0] * 2;
  1192
+    @buf = buf
  1193
+    ibuf[0] = 0
  1194
+    ibuf[1] = 98
  1195
+    md = caller[0].match(/`(\w*)'/); clr = md and md[1] or caller[0]
  1196
+    puts("#{clr} calling __EIB_SendRequest, ibuf=#{ibuf.inspect}") if $DEBUG
  1197
+    if __EIB_SendRequest(ibuf) == -1
  1198
+      return -1
  1199
+    end
  1200
+    @__complete = __EIB_MC_PropertyScan_Complete()
  1201
+    return 0
  1202
+  end
  1203
+
  1204
+  def EIB_MC_PropertyScan(buf)
  1205
+    puts "EIB_MC_PropertyScan()" if $DEBUG
  1206
+    if EIB_MC_PropertyScan_async(buf) == -1
  1207
+      return -1
  1208
+    end
  1209
+    return EIBComplete()
  1210
+  end
  1211
+
  1212
+  def __EIB_MC_PropertyWrite_Complete()
  1213
+    puts "__EIB_MC_PropertyWrite_Complete()" if $DEBUG
  1214
+    @__complete = nil
  1215
+    if __EIB_GetRequest() == -1
  1216
+      return -1
  1217