Sidebar

Home



Expressions


About

Functions

   expr_list()

   exec()
   return()
   if()
   for()
   loop()
   nop()

  Output
   print()
   clear()
   debug()

  Math
   abs()
   sign()

   sqr()
   sqrt()

   min()
   max()

   inc()
   dec()

   rand()

   none()
   nan()

   def()
   defnz()

   is_none()
   is_num()
   is_str()
   is_valid()

   bool()

  Rounding
   round()
   roundup()
   floor()
   ceil()
   trunc()
   center()
   centerex()

   s8()
   u8()
   s16()
   u16()
   s32()
   u32()

  Trigonometric
   pi()
   sin()
   cos()
   tan()
   asin()
   acos()
   atan()
   atan2()

   rad2deg()
   deg2rad()

  Logarithmic
   e()
   pow()
   exp()
   exp10()
   exp2()
   log()
   log10()
   log2()

  Bitwise
   bit()
   not()
   and()
   or()
   xor()
   nand()
   nor()
   xnor()
   shl()
   shr()

  Logical
   lnot()
   land()
   lor()
   lxor()
   lnand()
   lnor()
   lxnor()

  Relational
   eq()
   ne()
   gt()
   lt()
   ge()
   le()

  Date & Time
   date()
   datetime()
   year()
   month()
   day()
   hour()
   minute()
   second()
   millisec()

  Strings
   str()
   strlen()
   padleft()
   padright()
   hex()
   bin()
   chr()
   match()

  Parameters
   param_get()
   param_set()
   param_remove()
   param_persistent()

  Coordinates & Units
   to_motor()
   to_motor_xy()
   to_motor_uv()

   to_work()
   to_work_xy()
   to_work_uv()

   mm_to_unit()
   unit_to_mm()

   mm_to_setunit()
   setunit_to_mm()

   unit_to_setunit()
   setunit_to_unit()

   setunit()

  Commands
   estop()
   stop()
   pause()
   start()

   open()
   close()

   settings()
   exit()
   exitforce()

   output()
   output_pwm()
   output_rc()

   mist()
   flood()
   spindle()

   extout1()
   extout2()

   jog()
   jog_axis()
   jog_stop()

   speed_override()
   spindle_override()

   thc()

   cmd_list()
   cmd_count()

   cmd_get_id()
   cmd_get_name()
   cmd_get_displayname()

   cmd_is_enabled()
   cmd_is_checked()

   cmd_exec()

   open_file()
   open_code()
   start_file()
   start_code()
   test_file()
   test_code()

   run()

   py_list()
   py()
   py_term()
   py_msg()

  UI
   is_visible()
   show()
   hide()

   set_status()
   set_progress()

   is_ui_ready()

  Message
   msg()
   msgerr()

   msg_show()

   msg_count()
   msg_is_active()

   msg_click_ok()
   msg_click_cancel()

   bubble()

  Dialog
   dlg_file_open()
   dlg_file_save()

   dlg_new()
   dlg_init()
   dlg_update()
   dlg_clear()

   dlg_show()
   dlg_abort()

   dlg_is_valid()
   dlg_keep_open()
   dlg_callback()

   dlg_modal()
   dlg_set_resizable()
   dlg_set_pos()
   dlg_set_size()
   dlg_set_btn()
   dlg_set_name()
   dlg_set_color()

   dlg_add_separator()
   dlg_add_image()
   dlg_add_label()
   dlg_add_checkbox()
   dlg_add_num_input()
   dlg_add_txt_input()
   dlg_add_dropbox()
   dlg_add_button()

   dlg_comp_pos()
   dlg_comp_size()
   dlg_comp_color()
   dlg_comp_font()
   dlg_comp_name()
   dlg_comp_value()
   dlg_comp_callback()

   dlg_draw_line()
   dlg_draw_arrow()
   dlg_draw_circle()
   dlg_draw_rect()

   dlg_click_apply()
   dlg_click_ok()
   dlg_click_close()

   dlg_has_btn_apply()
   dlg_has_btn_ok()
   dlg_has_btn_close()

  Points
   points_count()
   points_clear()
   points_add()
   points_get()
   points_set()
   points_delete()
   points_load()
   points_save()

  File
   file_delete()
   file_open()
   file_close()
   file_read()
   file_append()
   file_flush()

  Array
   array_new()
   array_delete()
   array_isvalid()
   array_size()
   array_clear()
   array_resize()
   array_insert()
   array_remove()
   array_copy()
   array_printstring()
   array_printdata()
   array_setstring()
   array_getstring()
   array_setdata()
   array_setdata16()
   array_setdata32()
   array_setdata64()
   array_setdataflt32()
   array_setdataflt64()
   array_getdata()
   array_getdata16()
   array_getdata32()
   array_getdata64()
   array_getdataflt32()
   array_getdataflt64()
   array_crc16()
   array_crc32()

  Serial
   serial_list()
   serial_info()
   serial_open()
   serial_close()
   serial_config()
   serial_write()
   serial_writedata()
   serial_writedata16()
   serial_writedata32()
   serial_writearray()
   serial_writeflush()
   serial_read()
   serial_readdata()
   serial_readarray()
   serial_readflush()
   serial_addlistener()
   serial_remlistener()

  USB
   usb_list()
   usb_info()
   usb_open()
   usb_close()
   usb_read()
   usb_readdata()
   usb_readarray()
   usb_write()
   usb_writedata()
   usb_writearray()
   usb_addlistener()
   usb_remlistener()

  Hash
   crc16()
   crc32()
   sha256()
   sha256_f()
   md5()
   md5_f()

  Crypt
   aes256_encrypt()
   aes256_encrypt_f()
   aes256_decrypt()
   aes256_decrypt_f()

  Colors
   rgb_to_hue()
   rgb_to_saturation()
   rgb_to_lightness()
   rgb_to_name()

  Camera
   cam_grab()
   cam_color()
   cam_rect()

  Sound
   beep()
   siren()
   sound_load()
   sound_unload()
   sound_play()
   sound_stop()
   sound_is_playing()

  MIDI
   midi_note_on()
   midi_note_off()
   midi_ctrl()
   midi_prog()
   midi_play()
   midi_stop()
   midi_is_playing()

   midiin_channel()
   midiin_prog()
   midiin_note()
   midiin_ctrl()

  Misc
   sleep()

   url()
   rubik()

  PoKeys
   pk_digital()
   pk_analog()

Operators

Events

expr:functions:func-usb_addlistener

usb_addlistener()

Adds USB listener, which reads data from USB device and saves it in array. Each time device sends new data, array data is refreshed and callback function is executed.

Syntax

usb_addlistener(path, callback, hnd, size);

Parameters

path USB device path.
callback Callback function name. Callback function arguments are:
arg1 - path
arg2 - array handle
arg3 - length
hnd Array handle.
size Number of bytes to read. Special values are:
-1 - all data in packet is read
Return Value Number of listeners or zero, if adding failed.

Examples

hnd = array_new();
usb = "\\?\hid#vid_045e&pid_028e&ig_00#8&3b73941c&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}";
usb_addlistener(usb, "#On_USB_Event", hnd, 14); 
 
#On_USB_Event
result = array_getdata(.arg2,11);

result:

255

See also

expr/functions/func-usb_addlistener.txt · Last modified: 2024/06/13 10:31 by andrej

Page Tools