The arguments you're providing to writeRead() are wrong. Sorry for the
unfriendly error message.
Specifically, make sure that the "total length" argument is at least as big
as the maximum of request length and response length.

On Sun, Mar 8, 2015 at 6:51 PM, Renato Sapienza <
renato.sapie...@marttrend.com.br> wrote:

> Hi,
>
> I'm trying to implement a code to communicate with a RFID MFRC522 sensor
> via SPI, but I'm having some issues. The board model is exactly like this
> one
> *http://aura-comms.com/media/catalog/product/r/f/rfid-rc522-pinout.png*
> <http://aura-comms.com/media/catalog/product/r/f/rfid-rc522-pinout.png>,
> The reason I chose this model, it's because of it's popularity and
> affordability, but I couldn't find any implementation of it for IOIO, so I
> decided to port a code from Arduino to IOIO.
>
> There are several Arduino implementations, but, for the sake of
> simplicity, I chose the simplest one, in order to test the communication
> first. When I try to communicate with the board, IOIO always returns the
> following message:
>
> [D/IOIOConnectionRegistry] Successfully added bootstrap class:
> ioio.lib.pc.SerialPortIOIOConnectionBootstrap
> [D/SerialPortIOIOConnectionBootstrap] Adding serial port
> /dev/tty.usbmodemfd121
> [D/IOIOImpl] Waiting for IOIO connection
> [V/IOIOImpl] Waiting for underlying connection
> [V/IOIOImpl] Waiting for handshake
> [I/IncomingState] IOIO Connection established. Hardware ID: SPRK0020
> Bootloader ID: IOIO0400 Firmware ID: IOIO0500
> [V/IOIOImpl] Querying for required interface ID
> [V/IOIOImpl] Required interface ID is supported
> [I/IOIOImpl] IOIO connection established
> [E/IOIOProtocol] Protocol error:
> ioio.lib.impl.IOIOProtocol$ProtocolError:
> java.lang.ArrayIndexOutOfBoundsException
>     at ioio.lib.impl.IOIOProtocol$IncomingThread.run(IOIOProtocol.java:941)
> Caused by: java.lang.ArrayIndexOutOfBoundsException
>     at java.lang.System.arraycopy(Native Method)
>     at ioio.lib.impl.SpiMasterImpl.dataReceived(SpiMasterImpl.java:156)
>     at
> ioio.lib.impl.IncomingState$DataModuleState.dataReceived(IncomingState.java:120)
>     at ioio.lib.impl.IncomingState.handleSpiData(IncomingState.java:412)
>     at ioio.lib.impl.IOIOProtocol$IncomingThread.run(IOIOProtocol.java:807)
> [D/IOIOImpl] Physical disconnect.
>
> Doing some basic debug, I found that apparently the board is returning
> more bytes than expected.
>
> Here are my ports configuration: 10 -> SDA, 13 -> SCK, 11 -> MOSI, 12 ->
> MISO, 5 -> RST.
> Here is the Arduino code (which works perfectly):
> *http://pastebin.com/BpVUUCwa* <http://pastebin.com/BpVUUCwa>
> Here is my ported IOIO code: *http://pastebin.com/5AJKZXnR*
> <http://pastebin.com/5AJKZXnR>
>
> I tried several parameter variarions of openSpiMaster, but the results
> were always the same. I also tried the MISO-MOSI loopback and it worked
> fine. Spite of having a good Java knowledge, I'm not an expert on
> peripheral communication, so I might be screwing some bitwise operation.
>
> Could someone, please, help me to solve this or point me to a direction
> where I could find some solution.
>
> Thanks in advance,
> Renato
>
> --
> You received this message because you are subscribed to the Google Groups
> "ioio-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ioio-users+unsubscr...@googlegroups.com.
> To post to this group, send email to ioio-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/ioio-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ioio-users+unsubscr...@googlegroups.com.
To post to this group, send email to ioio-users@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to