IO Read Error


#1

GoPiGo - Java program. Unable to read encoder values or ultrasonic sensors. It gives me “IO Error trying to read your command”. I think its try to read status after my command “u” or gopigo.encoders.read(1); but failed and exit the system.

Either of them gives same error. I updated my firmware and all software recently.

Any help would be greatful… Thank you.


#2

Can you run the python examples and check if those are working. Can you also run the troubleshooting scripts by following the direction here:https://www.youtube.com/watch?v=ZMadpIEYq5o and https://www.youtube.com/watch?v=MJu8k-_UQgg and upload the test log. The java examples were contributed by the community so might have got old as we have upgraded the software.

-Karan


#3

Karan, Thank you for your help. Attached log file for your view. Yes, tested with Python commands. Both Encoder and Ultra sensor are good.

I have 2 more weird things. LED_R - On always. Servo moves to right side end after turns on. Testing Servo gives some short of sound which I think its try to move but on wrong direction.

Thank you.


#4

Hey,
Looks like you are using GoPiGo1 and it has the the LED signal ties to the Servo signal which is why the LED lights up when the servo is being used. Also, the servo software is written so that it gives the servo 10 seconds to come to the final position before turning off the servo signal and you would see some jitters there.

I think the problem might be with the Java code itself. We have never tried it out our self since this was contributed by the community. Can you send a log of the commands you are trying and the output you are getting and we can try it at our end.

-Karan


#5

Hi Karan,
Thank you again for looking into it. Attached the command log which I have tried. “u” = ultrasonic distance read. It gives IO read error and exit system.
Basically - “u” stands for both IR and Ultrasonic read. I have made IR Read as comments and tried to read from ultrasonic only… But no luck. I think problem may be with java code library or core IO reading code in java.
Thank you.


#6

Hi chand2020,
We’ll have a look at this and let you know if we are able to find the problem and solve it.

-Karan


#7

Hi Karen and chand2020, Any update on this? I’m new to gopigo and was trying to setup my java env. I’m getting the exact IO error mentioned in the new.txt log:

java.io.IOException: Error reading from /dev/i2c-1 at address 0x8 to address 0x1. Got -1.
at com.pi4j.io.i2c.impl.I2CDeviceImpl.read(I2CDeviceImpl.java:252)
at com.dexterind.gopigo.components.Board.readI2c(Board.java:137)
at com.dexterind.gopigo.components.Board.volt(Board.java:269)
at com.dexterind.gopigo.Gopigo$1$1.run(Gopigo.java:253)
at java.lang.Thread.run(Thread.java:745)

By the way, I came across this forum link first and updated that but I think this current topic is exactly related to my issue so submitting here.
Thank you for your helps!


#8

Hi gopigopi, Nope. I am not that good with Java. We may need to work with java library of gopigo. If I do resolve it will let you know. Thank you for posting your question.


#9

I’m having a similar problem, tried to run the Java example program and it throws IOException errors. I’m attaching a typescript of the run. The Python example programs (command-line and GUI) work fine.


#10

(Oops, unaccepted file type. Retrying the upload.)


#11

Exactly the problem I have. It seems the problem is with readI2c method (link)
I’m not familiar enough to know what’s going on with IO reads or how they work for that matters.
Does the following method seem correct to you guys?

public byte[] readI2c(int numberOfBytes) throws IOException {
if (Gopigo.getInstance().isHalt()) {
Gopigo.getInstance().onHalt();
}
byte[] buffer = new byte[numberOfBytes];
device.read(1, buffer, 0, buffer.length);
return buffer;
}

and device is an instance of pi4j’s I2CDevice.

Thanks


#12

Huh. I tried the baudrate change that was suggested in the “Max baudrate GoPiGo” thread, and it seems to have worked for me. Specifically, I added these lines to the /boot/config.txt file:

  • # Decrease the baud rate? dtparam=i2c_arm_baudrate=16000      # original suggestion was "dtparam=i2c_arm_baudrate=32000"
and rebooted, and now the scripts/Test.sh script seems to work fine.

But this opens some new questions:

  • What's the range of possible values for the baudrate? What is it actually doing?
  • Why does the Python test script work fine without lowering the baudrate, but Java needs it lowered? Is Python really that much faster-running?

#13

Great… Thank you Bloomu Prof… I added that line into my config file. No error what so ever. I have been waiting for so long… That baudrate is not at all in my config file… You are right…


#14

Hey guys,
Just wanted to ask if you are facing an problems or does it work perfectly. Also, which Pi are you using.

-Karan


#15

Karan, For me it’s working fine. No error. I am able to read values from ultrasonic sensors. Pi 2 Model B. Gopigo1.


#16

I’m using a RPi 3 with a GoPiGo 2 board. I haven’t done much with it, just the basic Test.sh script, but that worked flawlessly with the baudrate change.

Just added an ultrasonic sensor, so I have a whole new set of challenges to deal with now. Got it largely sorted in python, now planning to move back to java.