Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Can I use the Easy TCP/IP TWI and a buffered COM port?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> Easy TCP/IP Archive
View previous topic :: View next topic  
Author Message
TGJ

Bascom Member



Joined: 23 Jan 2006
Posts: 6

germany.gif
PostPosted: Thu Apr 20, 2006 3:54 pm    Post subject: Can I use the Easy TCP/IP TWI and a buffered COM port? Reply with quote

Hi,
I am working with an Easy TCP/IP TWI board for a couple of days now. I am trying to realize a virtual com port inside a network. Therefore I use a Easy TCP/IP TWI board together with MEGA163. The program is quite easy. Everything what comes from the TCP/IP gets send to the RS232 port of the MEGA163 and everything what is coming from the RS232 will get send to the TCP/IP port. So far so good. Receiving data from the TCP/IP and sending it to the RS232 works perfect. The problem is the other way around. I have set up a buffer for the RS232, but I am still loosing data. It is just like if the buffer does not work. I thought that maybe the TCP/IP drivers are disabling the RS232 buffer somehow. Here is my program:


[code]$regfile = "m163def.dat" ' specify the used micro
$crystal = 7372800 ' used crystal frequency
$baud = 9600 ' use baud rate
$hwstack = 64 ' default use 32 for the hardware stack
$swstack = 64 ' default use 10 for the SW stack
$framesize = 100 ' default use 40 for the frame space

Const Sock_stream = $01 ' Tcp
Const Sock_dgram = $02 ' Udp

Const Sel_recv = 2

'socket status
Const Sock_closed = $00 ' Status Of Connection Closed
Const Sock_listen = $02 ' Status Of Waiting For Tcp Connection Setup
Const Sock_established = $06 ' Status Of Tcp Connection Established
Const Sock_close_wait = $07 ' Status Of Closing Tcp Connection

Const Etx = 3
Const Atk = 6
Const Etb = 23

Const True = 1
Const False = 0

Config Serialin = Buffered , Size = 80

Enable Interrupts
' before we use config tcpip , we need to enable the interrupts
Config Tcpip = Int1 , Mac = 12.128.12.34.56.78 , Ip = 10.35.20.1 , Submask = 255.255.0.0 , Gateway = 10.35.200.1 , Localport = 1000 , Tx = $55 , Rx = $55 , Twi = &H80 , Clock = 400000

Dim Bclient As Byte ' socket number
Dim Idx As Byte
Dim Result As Word , Result2 As Word ' result
Dim Rx_buff(30) As Byte
Dim Rxbuff As String * 30
Dim Dummy As Integer
Dim Dummy$ As String * 2
Dim T As Integer

'Open "Com1:" For Binary As #1

Do
Idx = 0
Result = Socketstat(idx , 0) ' get status
Select Case Result
Case Sock_established

Result = Socketstat(idx , Sel_recv) ' get number of bytes waiting
If Result > 0 Then
Result2 = Tcpread(idx , Rx_buff(1) , Result)

For T = 1 To Result
Dummy$ = Chr(rx_buff(t))
Print Dummy$;
Next T

End If

Dummy = Len(rxbuff)
If Dummy > 0 Then
Result = Tcpwritestr(idx , Rxbuff , 0)
Home Lower
Lcd "RXBUF:" ; Dummy ; " Send:" ; Result
Rxbuff = ""
End If

Case Sock_close_wait

Closesocket Idx

Case Sock_closed
Bclient = Getsocket(idx , Sock_stream , 5000 , 0) ' get socket for server mode, specify port 5000
Cls
Lcd "Socket" ; Bclient ; " closed "
Socketlisten Idx
End Select

While Ischarwaiting() <> 0
Dummy = Inkey()
Rxbuff = Rxbuff + Chr(dummy)
Wend

Loop


End[/code]

It is very simple but it still does not work. Does anyone have an idea?

Thanks in advance

Thomas
Back to top
View user's profile
Frankeman

Bascom Member



Joined: 11 Aug 2004
Posts: 948
Location: the Netherlands

netherlands.gif
PostPosted: Thu Apr 20, 2006 6:45 pm    Post subject: Reply with quote

Hi, and welcome to this friendly forum.

I did not have completely checked your code but the "open com1: for binairy"is not needed.
This is for software uarts.

Frank.
Back to top
View user's profile
TGJ

Bascom Member



Joined: 23 Jan 2006
Posts: 6

germany.gif
PostPosted: Fri Apr 21, 2006 8:04 am    Post subject: Reply with quote

Hi Frank,

thanks for your reply. The open statement is just a comment and it is remarked with a "'". I was just testing every possibility. I have rewritten this program about a hundred times.

By the way, there is one more thing what I did not mention. I am loosing more characters when I use a 115200 Baud com speed. It works better on 9600 Baud. This is even more evidence that the buffer does not work right.

Regards

Thomas
Back to top
View user's profile
TGJ

Bascom Member



Joined: 23 Jan 2006
Posts: 6

germany.gif
PostPosted: Fri Apr 21, 2006 10:33 am    Post subject: Reply with quote

Here are some more information:

I have rewrote the program once more. I wrote my own URXC interrupt routine, so that I can make my own buffer for incoming data. The result was disappointing, since I got the same result. It looks like as if the “Config Tcpip” command blocks the URXC interrupt most of the time and the external interrupts INT0 und INT1 have the higher priority then the URXC interrupt.

Does anyone have a soulution?
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> Easy TCP/IP Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum