ntruchsess / perl-firmata

Perl implementation of the firmata client. Originally authored by Aki Mimoto (amimoto) this repository was transfered to Norbert Truchsess (ntruchsess) in 02/2013. Anybody willing to contribute is very wellcome! Please submitt pull-requests against branch 'dev'
http://www.firmata.org
Other
21 stars 11 forks source link

increased amount of readining data from 512 to 2048 bytes #18

Closed ValdasRK closed 11 years ago

ValdasRK commented 11 years ago

increased amount of readining data from 512 to 2048 bytes.

ntruchsess commented 11 years ago

not that I think increasing this size would cause any harm on a reasonable sized machine, I'm curious what usecase you have that benefits from that amount to be read at once given that firmata-messages are 64 bytes only (and the usb-buffers on Arduino are not bigger than that either)?

ValdasRK commented 11 years ago

I'm using Arduino Due. In my project I frequently reading inputs. When I read in once only 512 bytes, then I not getting all data. May be size of 1024 will be OK?

ntruchsess commented 11 years ago

I think you should also make shure FirmataPlattform->poll() is called more frequently. Assuming you are running the serial-line at standard 57600 baud poll it's sufficient to call poll 12times/sec to read all data from the serial interface (with a 512 bytes readcount). You should find out why the callbacks that are called by PerlFirmata take to long to execute (or maybe to much other stuff is done in between). The increase in readsize is just a workaround, the fact the polling-frquency is to low indicates you might have to reconsider your application design. Maybe your application might benefit from multithreadding. While perl-firmata is not designed to be threadsafe (you cannot share the Platform-object amongst threads using it concurrently), you should be able to have 1 thread that handles the interface, receives the callbacks and distributes the actual work to a pool of worker-threads.