This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-30 08:08:33

asimov1981
New Scratcher
Registered: 2012-02-17
Posts: 10

SensorBoards

Hi I'm trying to use the remote Sensor Protocoll in SCRATCH to connect to a simple JAVA Middleware. It's no problem to send broadcasts from SCRATCH to the middleware. But SCRATCH crashes if i try to send something from the middleware to SCRATCH.

My Java-Code looks like:

private void sendToScratch(java.net.Socket socket, String dataOut){
         PrintWriter printWriter;
        try {
            printWriter = new PrintWriter(
                new OutputStreamWriter(
                    socket.getOutputStream()));
       
        
        byte [] sizeBytes = { 0, 0, 0, 0 };
       
          sizeBytes[3] = (byte)dataOut.length();
          System.out.println("Sende größe:"+sizeBytes[3]);
         System.out.println(dataOut);
          for (int i=0; i<4; i++) {                 
           
                printWriter.write(sizeBytes[i]);
               
                // TODO Auto-generated catch block
               
            }   
         printWriter.write(dataOut);
         printWriter.flush();
          System.out.println("send");
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
          
    }

Offline

 

#2 2012-04-13 17:04:57

Nathanator1416J
Scratcher
Registered: 2012-02-21
Posts: 100+

Re: SensorBoards

Well, if you want me to give you a dll that does it I can.
nathansaint1@gmail.com


http://wiki.scratch.mit.edu/images/Ptp.gif PEPPERTREE  Productions (PtP)
Tourmaline Scientific Research Programs

Offline

 

Board footer