Shop OBEX P1 Docs P2 Docs Learn Events
W5100 TCP Server: How to Receive Data (byte) Coreectly? — Parallax Forums

W5100 TCP Server: How to Receive Data (byte) Coreectly?

Dave D'AmatoDave D'Amato Posts: 6
edited 2013-02-07 05:45 in Propeller 1
Hey all,

Ok, here we go...
First off I have tried various samples/spin object demo's/searched the forums/read etc... and I still can't get this right.... lol!

Using a prop spin P8x32A interfaced using the WIZ812MJ network module for TCP/IP Server - Client communications.
Using W5100_SPI_Driver.
The prop/WIZ812MJ network module serves as the Server.
Using VB Winsock for the client side.

For the most part, all setup communications, IP/Sub/Gateway addressing good, connect, send.data, DataArrival and A/D field measurement data (bytes & string) is being received at the client side netwroked computer with no issues. All good.

Where I'm getting stuck is where I need to remotely change stored variable settings, IP/Sub/Gatewya Addressing, A/D Threshold byte settings etc...back in the Prop Server.

For the time being, only trying to receive one byte from the client (computer VB Winsock), and Serial Terminal print the received byte...
This is where it goes weird....

Client side VB Winsock:
txtsend = byte 192 .....for example
Winsock.SendData txtsend


Extracted from the "Spinnerete_TCP_Client_Demo.spin"
Have tried various configurations of this, still no luck.

VAR
BYTE text[8192]
LONG len

OBJ
TCP : "Spinneret_Simple_TCP"
PST : "Parallax Serial Terminal"

if TCP.Connect(pertinent info correct) = true

' Receive and display text until connection is lost
repeat while TCP.isConnected(0)
len:=TCP.RecvStr(0, @text)
if len > 0
PST.Str(@text)

PST.Str(String("Closing socket...", 13))
TCP.Close(0)
else
PST.Str(String("Could not connect..."))


Server Serial Terminal Results...

Connection established.

Waiting for TCP data.
Read 1 bytes from TCP

PST.Str(@text) displays this..... 21071 21072 21073 21074 21075 21076

SO the byte came in fine but not the expected data 192 byte....

Ideas...?

Thanks in advance,

Dave

Comments

  • Mike GMike G Posts: 2,702
    edited 2013-02-06 19:11
    Demo code attached. You'll have to update the pin IO defined in the CON block to match your setup.
      { Spinneret PIN IO }   
      SPI_MISO          = 0 ' SPI master in serial out from slave 
      SPI_MOSI          = 1 ' SPI master out serial in to slave
      SPI_CS            = 2 ' SPI chip select (active low)
      SPI_SCK           = 3  ' SPI clock from master to all slaves
      WIZ_INT           = 13
      WIZ_RESET         = 14
      WIZ_SPI_MODE      = 15
    

    Fire it up, DHCP will take over and assign your network parameters. Make sure you have the Parallax Serial Terminal open once the code loads so you can see the assigned IP etc. Then Simply open a browser and enter the IP shown in the serial terminal. You'll see a bunch of bytes fly on the screen, the HTTP header.

    Next, enter your IP and a simple query string to see PIN 0's register values.
    ie. http:/ / 192. 168. 1. 113/pinstate.xml?led=0&value=-1

    You can find a ton of information in the Spinneret forum.

    If the byes still do not show up correctly then you might have a bug in your socket program or a configuration issue.

    Try it yourself...
    http://spinneret.servebeer.com:8080
    http://spinneret.servebeer.com:8080/pinstate.xml?led=23&value=0
  • Dave D'AmatoDave D'Amato Posts: 6
    edited 2013-02-07 05:10
    Excellent... thanks Mike!

    Yeah I've read through the Servebeer.com but not really what I was looking for. In this project design I'm working on, I need to be able to install the parallax/network modules at different locations throughout the country with the ability for TCP/IP networking, remote live feed observations of input measurements, user insert of networking addressing/configurations while on location (no brainer) and the ability to change threshold settings as required....

    Noticed some differences/addtions in your W5100 spin, will give them a go and post the results...

    Thanks again!

    Dave
  • Mike GMike G Posts: 2,702
    edited 2013-02-07 05:28
    Dave, the code is designed for users like yourself. Sockets.spin provide access to TCP/UDP comm without having to deal with HTTP. You'll also find some light weight XML services that are invoked via HTTP. These are ideal for remote monitoring and configuration.
  • Mike GMike G Posts: 2,702
    edited 2013-02-07 05:45
    I put the site back up. Here's an example of remote XML services. It just monitors PIN IO state.
    http://spinneret.servebeer.com:8080/epin.htm
Sign In or Register to comment.