Back again Mike. I only got looking at those demos today on the google repo. In the 'TcpSocketClientDemoDhcpDns' demo , I having some trouble with connecting the sockets.
On line 191 of the code i'm getting stuck as the socket wont connect
repeat until sock.Connect > 1
pst.dec(sock.connect)
pst.char(CR)
pause(2000)
For some reason I cant open the socket , actually this is happening with some of the other demo's so I'm sure its something on my end . Any idea of what might be causing this?
Hello, i try to connect two spinneret, both wit serial to ethernet. So I get a serial over IP
The only thing I change are crossed Ip adress and ports. sever<=>client
With tinysoket on my mac i can get communication trogh spinneret to serial terminal, but not from spin to spin..... do I missing some thing?
It is only testing befor a put an lcd 2*16 display so no heavy serial com
I'm sure Mike will explain it better and your question is a little confusing. If you just want to have the 2 spinnerets communicating serially you can just use 2 serial objects one on each spinneret. Like Mike's 'Full Duplex serial' objects which your can find on the OBEX and its pretty easy to get this up and running if this is what your trying to achieve.Set up 2 I/O lines (Rx and Tx.) on each Spinner.
If you want to communicate over a TCP network or similair , then mike also has some good code examples . Might have to slightly modify the example programs , but load one with the client demo and the other with the server demo. Or what I find easier to start out with is use some Server/client software program like Hercules which is free to download (I use docklight which i think u can download for free also) and get 1 spinneret and set it as a client and get it communicating with the Server/client software program(set as a Server obviously) and then get the other Spinneret set as server and get the Server/client software program(set as a client this time) to communicate to the 2nd Spinneret. when you have this done it should be easier to get the 2 spinneret communicating when you know how to set each one up probably
As Mike mentions depends on what your trying to achieve.
Again,but better ?
Ik can play with "UdpSerialToEthernet.spin" between a computer and a spinneret, both direction communication. I modified the code to display an LCD in stead of serial terminal, again with computer-spinneret (= one) everything fine.
Soft on computer is client/server (tinySoket on OSX)
Now I want to replace the computer wit a Spinnert (=two) and use "UdpSerialToEthernet.spin" just crossing ip and ports in one of the spinneret code .
I expected to get serial input on one side (spinneret two) and receive the message on the other side (spinneret one)
But it did not work even when I use the original "UdpSerialToEthernet.spin" and serial terminal on computers at both side of the spinnerets
Do I really have to use client and slave? Or something like "EthernetToUdpSerial.spin" ?
So yes I like to get a a serial over IP, not just communication with rs232....
Is my guess wrong? Do I have to look for other combination of soft between the two spinnerets ?
This wouldnt be rs232 levels , just serial TTL .
Anyway I havent really worked much with UDP demos but i have done what your trying to achieve with the TCP demo's I mentioned. As far as I know you will have to set one spinneret as a Server and one as a Client to get them communicating.. I not sure if you load both with the UDPserialtoEthernet demo that this will work as you need one to initiate the communication.
If you really need to use the UDP then Mike will be up out of bed shortly and probably have an answer for you because he wrote all those demo's.
But the tcp demo's are pretty easy to get going (If I can do it then so can you )
I wired up a test using the default SerialtoEthernet files. I assigned unique IP and MAC addresses to each Spinneret and it just worked. I was able to send a test string from PC1's terminal (PST) and the results showed up on PC2. Same for PC2 to PC1.
Double check your configuration. Did you remember to assign unique MAC addresses to each Spinneret, assuming they are on the same network. If you are still having issues, post your code and a schematic of your setup!
Can you making a both way serial communication, turning server and client on one spinneret ?
One cog on the demo is working as a Server and another as a Client I think.
I had a product that had no Ethernet connection on it and connected it serially to a Spinneret and this code to create a TCP connection to a VideoJet Printer and it worked great. Was getting up to 25 prints a second of Unique Data.
Anyway Mike has it tested and working now. What is the project for do you mind me asking?
Thank you Mike,
So it has to work. My issue has to do with soft or network, not on the protocol used.
With this in mind I found my issue.
For testing I was sometime sending a reset command in bin format and send it back trough the serial terminal of the other side, and guess, it reset the prop os course :-(
The bin number was random, and I do not notice the stupid choice of it
The serial to Ethernet demo expects a string ending with a 0x0D. I thought up a most robust solution where the data came be anything. I'll post the code once completed.
Dragging up a few skeletons here. I recently revisited the Spinneret TCP serial to Ethernet code and for an application and I was running some speed tests and I noticed something odd , maybe you can shed a bit of light on it.
I'm using a W5200 now with a Smart Camera and the Camera sends the read status to the W5200 and I was struggling for speed with reading the received data.
The camera acts as the Server and the W5200 as the client. I just simulated your test code with an TCP server Emulator. I had noticed this also with the Spinneret in relation to speed . I modified your TcpSocketClientDemo just for the test
PUB Main | bytesToRead, buffer, bytesSent, receiving, totalBytes
receiving := true
bytesToRead := 0
pst.Start(115_200)
pause(500)
'wiz.QS_Init
wiz.HardReset(WIZ#WIZ_RESET)
wiz.Start(WIZ#SPI_CS, WIZ#SPI_SCK, WIZ#SPI_MOSI, WIZ#SPI_MISO)
'Set network parameters
wiz.SetCommonnMode(0)
wiz.SetGateway(192, 168, 1, 1)
wiz.SetSubnetMask(255, 255, 255, 0)
wiz.SetIp(192, 168, 1, 30)
wiz.SetMac($00, $08, $DC, $16, $F8, $01)
pst.str(string("Initialize", CR))
'Initialize Socket 0 port 8080
buffer := sock.Init(0, TCP, -1)
'www.agaverobotics.com
'sock.RemoteIp(65, 98, 8, 151)
'sock.RemoteIp(74,125,224,194)
sock.RemoteIp(192,168,1,6)
sock.RemotePort(49211)
pst.str(string(CR, "Begin Client Web request", CR))
'Client
pst.str(string("Open", CR))
sock.Open
pause(200)
pst.str(string("Connect", CR))
sock.Connect
pause(500)
'Connection?
repeat until sock.Connected
pause(10)
'pst.str(string("Send HTTP Header", CR))
'bytesSent := sock.Send(@localhost, strsize(@localhost))
'pst.str(string("Bytes Sent: "))
'pst.dec(bytesSent)
'pst.char(13)
repeat 'while receiving
'Data in the buffer?
bytesToRead := sock.Available
'totalBytes += bytesToRead
'Check for a timeout
'if(bytesToRead < 0)
'receiving := false
'pst.str(string("Timeout", CR))
'return
'if(bytesToRead == 0)
'receiving := false
' pst.str(string("Done", CR))
' next
'if(bytesToRead := sock.DataReady)
'Get the Rx buffer
if(bytesToRead > 0)
pst.str(string(CR,"Data available "))
sock.Receive(@buff, bytesToRead)
buff.byte[bytesToRead]:=0
pst.str(@buff)
bytefill(@buff,0,buffer_2K)
sock.Send(@buff, strsize(@buff))'*****Even though I dont require this and i'm sending nothing without this line the speed is reduced significantly
bytesToRead~
pst.str(string("Total Bytes: "))
pst.dec(totalBytes)
pst.char(13)
pst.str(string(CR, "Disconnect", CR))
sock.Disconnect
sock.Close
I'm sending about 20 packets/sec from the Emulator and it works fine with the sock.Send(@buff, strsize(@buff)) used , but if i remove this line I can only get about 5 packets/sec received. I dont need to send any data back but I dont know why the speed is affected without it.
Comments
On line 191 of the code i'm getting stuck as the socket wont connect
For some reason I cant open the socket , actually this is happening with some of the other demo's so I'm sure its something on my end . Any idea of what might be causing this?
Using the Spinneret
Thanks
Des
Replace this...
...with
Thats seems to have done the trick. You just had what is within this loop I had added just to see what was happening .
Got the other demo working now also , the TcpSever
Kind Regards
Des
I'm communicating with my Printer now over the Network using the Spinneret , happy days. Thanks for all the help
Regards
Des
The only thing I change are crossed Ip adress and ports. sever<=>client
With tinysoket on my mac i can get communication trogh spinneret to serial terminal, but not from spin to spin..... do I missing some thing?
It is only testing befor a put an lcd 2*16 display so no heavy serial com
Somebody ?
I'm sure Mike will explain it better and your question is a little confusing. If you just want to have the 2 spinnerets communicating serially you can just use 2 serial objects one on each spinneret. Like Mike's 'Full Duplex serial' objects which your can find on the OBEX and its pretty easy to get this up and running if this is what your trying to achieve.Set up 2 I/O lines (Rx and Tx.) on each Spinner.
If you want to communicate over a TCP network or similair , then mike also has some good code examples . Might have to slightly modify the example programs , but load one with the client demo and the other with the server demo. Or what I find easier to start out with is use some Server/client software program like Hercules which is free to download (I use docklight which i think u can download for free also) and get 1 spinneret and set it as a client and get it communicating with the Server/client software program(set as a Server obviously) and then get the other Spinneret set as server and get the Server/client software program(set as a client this time) to communicate to the 2nd Spinneret. when you have this done it should be easier to get the 2 spinneret communicating when you know how to set each one up probably
As Mike mentions depends on what your trying to achieve.
Ik can play with "UdpSerialToEthernet.spin" between a computer and a spinneret, both direction communication. I modified the code to display an LCD in stead of serial terminal, again with computer-spinneret (= one) everything fine.
Soft on computer is client/server (tinySoket on OSX)
Now I want to replace the computer wit a Spinnert (=two) and use "UdpSerialToEthernet.spin" just crossing ip and ports in one of the spinneret code .
I expected to get serial input on one side (spinneret two) and receive the message on the other side (spinneret one)
But it did not work even when I use the original "UdpSerialToEthernet.spin" and serial terminal on computers at both side of the spinnerets
Do I really have to use client and slave? Or something like "EthernetToUdpSerial.spin" ?
So yes I like to get a a serial over IP, not just communication with rs232....
Is my guess wrong? Do I have to look for other combination of soft between the two spinnerets ?
Thank you
This wouldnt be rs232 levels , just serial TTL .
Anyway I havent really worked much with UDP demos but i have done what your trying to achieve with the TCP demo's I mentioned. As far as I know you will have to set one spinneret as a Server and one as a Client to get them communicating.. I not sure if you load both with the UDPserialtoEthernet demo that this will work as you need one to initiate the communication.
If you really need to use the UDP then Mike will be up out of bed shortly and probably have an answer for you because he wrote all those demo's.
But the tcp demo's are pretty easy to get going (If I can do it then so can you )
Regards
Des
Can you making a both way serial communication, turning server and client on one spinneret ?
PC1 <-> Serial1 <-> Ethernet1 <-> Ethernet2 <-> Serial2 <-> PC2
I wired up a test using the default SerialtoEthernet files. I assigned unique IP and MAC addresses to each Spinneret and it just worked. I was able to send a test string from PC1's terminal (PST) and the results showed up on PC2. Same for PC2 to PC1.
Double check your configuration. Did you remember to assign unique MAC addresses to each Spinneret, assuming they are on the same network. If you are still having issues, post your code and a schematic of your setup!
One cog on the demo is working as a Server and another as a Client I think.
I had a product that had no Ethernet connection on it and connected it serially to a Spinneret and this code to create a TCP connection to a VideoJet Printer and it worked great. Was getting up to 25 prints a second of Unique Data.
Anyway Mike has it tested and working now. What is the project for do you mind me asking?
So it has to work. My issue has to do with soft or network, not on the protocol used.
With this in mind I found my issue.
For testing I was sometime sending a reset command in bin format and send it back trough the serial terminal of the other side, and guess, it reset the prop os course :-(
The bin number was random, and I do not notice the stupid choice of it
One time more Thank you for suporting
Dragging up a few skeletons here. I recently revisited the Spinneret TCP serial to Ethernet code and for an application and I was running some speed tests and I noticed something odd , maybe you can shed a bit of light on it.
I'm using a W5200 now with a Smart Camera and the Camera sends the read status to the W5200 and I was struggling for speed with reading the received data.
The camera acts as the Server and the W5200 as the client. I just simulated your test code with an TCP server Emulator. I had noticed this also with the Spinneret in relation to speed . I modified your TcpSocketClientDemo just for the test
I'm sending about 20 packets/sec from the Emulator and it works fine with the sock.Send(@buff, strsize(@buff)) used , but if i remove this line I can only get about 5 packets/sec received. I dont need to send any data back but I dont know why the speed is affected without it.