On Aug 7, 2011, at 7:19 AM, John Murray wrote:
> I’ve lifted this off stackoverflow and up to a point converted it to run with 
> c#
>  
>            string[] args = {"/system/bin/cat", "/proc/cpuinfo"};

Either you're working _way_ to hard or something is seriously screwy: you 
shouldn't need to do `cat /proc/cpuinfo`. /proc/cpuinfo is a file (`cat` works 
on files). As such, you can use ye normal file I/O on it:

        // Replace TextView as appropriate
        TextView output = FindViewById<TextView> (Resource.Id.Output);
        using (var cpuinfo = File.OpenText ("/proc/cpuinfo")) {
                string line;
                while ((line = cpuinfo.ReadLine ()) != null) {
                        output.Text += line + "\n";
                }
        } 

This works pretty much as you'd expect, returning output such as:

        Processor       : ARMv7 Processor rev 2 (v7l)
        BogoMIPS        : 162.54
        Features        : swp half thumb fastmult vfp edsp thumbee neon 
        CPU implementer : 0x51
        CPU architecture: 7
        CPU variant     : 0x0
        CPU part        : 0x00f
        CPU revision    : 2

        Hardware        : mahimahi
        Revision        : 0083
        Serial          : 0000000000000000

That said...

>            cmd = new ProcessBuilder(args);
>            Java.Lang.Process process = cmd.Start(); 
> //System.IO.Stream instr ; 
> //Stream instr = new Stream();
> //StreamReader instr = new StreamReader();
> //MemoryStream instr = new MemoryStream();
> //instr= process.InputStream.;
> //process.InputStream.CopyTo(instr,1024);
> //InputStream instr = process.GetInputStream();
>         byte[] re = new byte[process.InputStream.Length];
>         long bytestoread = process.InputStream.Length;

The solution is to avoid the process.InputStream.Length call, and instead wrap 
process.InputStream in a StreamReader and read (as I do above).

 - Jon

_______________________________________________
Monodroid mailing list
[email protected]

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to