From a PC application to Spinneret
I finally had time to unpack my Spinneret and succeeded
with "Spinneret_Web_Server_DEMO v1.0.spin" to turn
on and off some leds.
What I want to do now is to read and write to Propeller
memory from an application on the PC so I need some
guidance on which network protocols(or whatever it is
called) and Spinneret objects as needed.
/Paul
with "Spinneret_Web_Server_DEMO v1.0.spin" to turn
on and off some leds.
What I want to do now is to read and write to Propeller
memory from an application on the PC so I need some
guidance on which network protocols(or whatever it is
called) and Spinneret objects as needed.
/Paul
Comments
This tutorial might help a bit
http://spinneret.servebeer.com:5000/
Delphi 6
Drag and drop a ClientSocket component on Form.
procedure TForm1.FormCreate(Sender: TObject); begin ClientSocket1.Port := 5555; ClientSocket1.Host := '192.168.1.120'; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); begin ClientSocket1.Active := false; end; procedure TForm1.ClientSocket1Read(Sender: TObject; Socket: TCustomWinSocket); begin Memo1.Lines.Add('Rec '+TimeToStr(Time)+': '+Socket.ReceiveText); Memo1.Lines.Add('Elapsed time: '+IntToStr(GetTickCount-startTime)+' ms'); Memo1.Lines.Add(''); end; procedure TForm1.BtnSendClick(Sender: TObject); begin ClientSocket1.Active := true; //- Temporary fix - Sleep(50); Application.ProcessMessages; Sleep(50); Application.ProcessMessages; if ClientSocket1.Active then begin startTime := GetTickCount; ClientSocket1.Socket.SendText(EditMsg.Text); Memo1.Lines.Add('Send '+TimeToStr(Time)+': '+EditMsg.Text); end else begin Memo1.Lines.Add('ClientSocket1.Active = false'); Memo1.Lines.Add(''); end; end;
Propeller Tool
Spinneret_Web_Server_DEMO v1.0.spin
PUB Main | packetSize '- Infinite loop of the server ; listen on the TCP socket - repeat repeat while !W5100.SocketTCPestablished(0) '- Initialize the buffers and bring the data over - bytefill(@data, 0, bytebuffersize) repeat packetSize := W5100.rxTCP(0, @data) while packetSize == 0 '- Terminal - pst.Str(string("Packet from browser:", PST#NL)) pst.Str(@data[0]) pst.Char(13) '--- Parse Data Packet for ... --- '--- Generate HTML data to send --- StringSend(0, string("Ok")) '- We don't support persistent connections, so disconnect here - W5100.SocketTCPdisconnect(0) PauseMSec(25) '- Connection terminated - W5100.SocketClose(0) '- Once the connection is closed, need to open socket again - OpenSocketAgain(0)