- Home /
Android Stockfish chess engine error on call
Hi,
I am trying to call the stockfish chess engine (stockfish-10-armv7) from android but getting an error (mono-io-layer-error (5)) when doing the new process at runtime. The PC build worked fine.The engine needs to be run as a detached process and the communication is done via the input output stream. Does anyone know what this mono-io-layer-error (5) is about?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Android;
public static class StockFish
{
public static Process mProcess;
public static string engineText = "";
public static void StartEngine()
{
engineLog("datapath: " + Application.dataPath);
engineLog("Streamingpath: " + Application.streamingAssetsPath);
engineLog("Persist path : " + Application.persistentDataPath);
//
string sfBin = "stockfish-10-armv7";
string sfPathFile = Path.Combine(Application.persistentDataPath, sfBin);
string sfPathAsset = Path.Combine(Application.streamingAssetsPath, sfBin);
loadWeb(sfPathAsset, sfPathFile);
if (!File.Exists(sfPathFile))
{
engineLog("-------FILE NOT FOUND--------------------");
return;
}
else
{
engineLog("FILE EXISTS -------------------------------");
}
try
{
mProcess = new Process();
ProcessStartInfo si = new ProcessStartInfo()
{
FileName = sfPathFile,
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardError = true,
RedirectStandardInput = true,
RedirectStandardOutput = true
};
mProcess.StartInfo = si;
mProcess.OutputDataReceived += new DataReceivedEventHandler(MProcess_OutputDataReceived);
mProcess.Start();
mProcess.BeginErrorReadLine();
mProcess.BeginOutputReadLine();
}
catch (Exception e)
{
engineLog("ERROR Process:" + e.Message);
return;
}
engineLog("------RUN OK----------------");
UciCmd("uci");
UciCmd("isready");
//SendLine("position fen " + forsythEdwardsNotationString);
//SendLine("go movetime 5000");
}
public static void loadWeb(string inFile, string outFile)
{
var loadingRequest = UnityWebRequest.Get(inFile);
loadingRequest.SendWebRequest();
while (!loadingRequest.isDone)
{
if (loadingRequest.isNetworkError || loadingRequest.isHttpError)
{
engineLog("While network error");
break;
}
}
if (loadingRequest.isNetworkError || loadingRequest.isHttpError)
{
engineLog("network error");
}
else
{
try
{
File.WriteAllBytes(outFile, loadingRequest.downloadHandler.data);
}
catch (Exception e)
{
engineLog("ERROR File Write:" + e.Message);
return;
}
}
}
public static void engineLog(string engString)
{
engineText = engineText + engString + "\n";
}
public static void UciCmd(string command)
{
mProcess.StandardInput.WriteLine(command);
mProcess.StandardInput.Flush();
}
private static void MProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
{
engineLog(e.Data.ToString());
}
}
moniioerror.png
(221.5 kB)
Comment
Answer by XLRLimits · Mar 01 at 10:05 PM
Hello i have the same as thing, did you managed to fix this? I think the fix is regarding ill2cpp and net also i think we might not have permissiom to access the stockfish so file.