|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Dual rs232<->EthernetHi all.
For my home automation i need to use 2 rs232<->ethernet converters I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic TCP Server and Serial Port Monitor examples. Using that i need to do this in dedicated threads, because i'm use other ethernut's digital pins to get home events. All my tries fails, i have lags using my remote rs232's. Can anyone with code or part of code, that's can help me to resolve my problem? Great thanks! _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Dual rs232<->EthernetHi!
I am not sure, if I understand that correctly: You'd like to communicate with two RS232 ports via TCP/IP. In nut/app/rs232d there is a demo for doing that with one single port. So you can duplicate the THREAD and assign the second one to a different port. As a connection like that cannot be shared, only one client can access one RS232 port. So you do not need to take care of launching several threads per port. To access GPIOs of the CPU there are different options. You can watch the RS322 communication an catch special commands, that are not routet to the RS232 port but are used to control or read GPIOs. Or you can launch a third server thread that controls the GPIOs. If your code doesn't work, you can post parts of the code in here, so we can help. Regards Ulrich asdus schrieb: > Hi all. > For my home automation i need to use 2 rs232<->ethernet converters > I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic > TCP Server and Serial Port Monitor examples. > Using that i need to do this in dedicated threads, because i'm use > other ethernut's digital pins to get home events. All my tries fails, > i have lags using my remote rs232's. > > Can anyone with code or part of code, that's can help me to resolve my > problem? Great thanks! > _______________________________________________ > http://lists.egnite.de/mailman/listinfo/en-nut-discussion http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Dual rs232<->EthernetYep, you're right. But rs232d primer have some troubles.
Yes, it's have buffers to resolve different speed problems, but connection stucks, if ethernet client disconnect unclean, and, sometimes, i'm have strange data freezes, when i receive sended data only on next connection. 2009/10/30 Ulrich Prinz <uprinz2@...>: > I am not sure, if I understand that correctly: > You'd like to communicate with two RS232 ports via TCP/IP. > In nut/app/rs232d there is a demo for doing that with one single port. > So you can duplicate the THREAD and assign the second one to a different > port. As a connection like that cannot be shared, only one client can > access one RS232 port. So you do not need to take care of launching > several threads per port. > > To access GPIOs of the CPU there are different options. You can watch > the RS322 communication an catch special commands, that are not routet > to the RS232 port but are used to control or read GPIOs. > > Or you can launch a third server thread that controls the GPIOs. > > If your code doesn't work, you can post parts of the code in here, so we > can help. > > Regards > Ulrich > > asdus schrieb: >> Hi all. >> For my home automation i need to use 2 rs232<->ethernet converters >> I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic >> TCP Server and Serial Port Monitor examples. >> Using that i need to do this in dedicated threads, because i'm use >> other ethernut's digital pins to get home events. All my tries fails, >> i have lags using my remote rs232's. >> >> Can anyone with code or part of code, that's can help me to resolve my >> problem? Great thanks! http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Dual rs232<->EthernetHi!
Yes, if you take a look at the previous discussion of the last few weeks, you'll see, that there are some problems existing in the TCP/IP stack. But what you tell is that connections are not completely handled, as a TCP COnnection may break at any time. So try to find a good point where to monitor that situation and clean up the system to a default where it accepts new data and connection. But without code it's hard to tell. Regards, Ulrich asdus schrieb: > Yep, you're right. But rs232d primer have some troubles. > Yes, it's have buffers to resolve different speed problems, but > connection stucks, if ethernet client disconnect unclean, and, > sometimes, i'm have strange data freezes, when i receive sended data > only on next connection. > > 2009/10/30 Ulrich Prinz <uprinz2@...>: >> I am not sure, if I understand that correctly: >> You'd like to communicate with two RS232 ports via TCP/IP. >> In nut/app/rs232d there is a demo for doing that with one single port. >> So you can duplicate the THREAD and assign the second one to a different >> port. As a connection like that cannot be shared, only one client can >> access one RS232 port. So you do not need to take care of launching >> several threads per port. >> >> To access GPIOs of the CPU there are different options. You can watch >> the RS322 communication an catch special commands, that are not routet >> to the RS232 port but are used to control or read GPIOs. >> >> Or you can launch a third server thread that controls the GPIOs. >> >> If your code doesn't work, you can post parts of the code in here, so we >> can help. >> >> Regards >> Ulrich >> >> asdus schrieb: >>> Hi all. >>> For my home automation i need to use 2 rs232<->ethernet converters >>> I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic >>> TCP Server and Serial Port Monitor examples. >>> Using that i need to do this in dedicated threads, because i'm use >>> other ethernut's digital pins to get home events. All my tries fails, >>> i have lags using my remote rs232's. >>> >>> Can anyone with code or part of code, that's can help me to resolve my >>> problem? Great thanks! > _______________________________________________ > http://lists.egnite.de/mailman/listinfo/en-nut-discussion http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Dual rs232<->EthernetHi all!
After some tries I'm get fully workable code. You can see that here: http://pastebin.mozilla-russia.org/102504 But I still have rare freezes, and need to manually reset my device. Have a chance to resolve this? 2009/10/27 asdus <asdusik@...>: > Hi all. > For my home automation i need to use 2 rs232<->ethernet converters > I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic > TCP Server and Serial Port Monitor examples. > Using that i need to do this in dedicated threads, because i'm use > other ethernut's digital pins to get home events. All my tries fails, > i have lags using my remote rs232's. _______________________________________________ http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
|
|
Re: Dual rs232<->EthernetHi!
Only had a short look into your code: You should set NutThreadSetPriority() inside the Threads. Probably the same priority for all of them. You should not rise the main() routines priority to 128. Background is, that NutThreadSetPriority() sets the priority of the task it is called from. And calling it in main will modify the prio of the main task, that is doing nothing in your application. So delete line 143 and do a NutSleep(5000), or if you have a blinking LED for giving an 'alive' signal, toggle it there and do a NutSleep( 1000) there. Insert NutThreadSetPriority(50) in the two tasks before going into the main loop of the task ( i.e. for(;;) {) at lines 54 and 74. So all four tasks have same priority and are called round and round. You're using NutThreadYeald() so, if this function is reached, the thread releases the CPU to the next waiting thread. This will normally lead to the same result than giving all tasks the same priority. Remember that if there is only one thread with a higher priority, it will always be the next called every NutThreadYeald(). Therefore it is better to actively set priorities. You do not do any buffer checking. So if one of the receiving or sending queues is running out of buffer, you have no chance to react. To find out, what is happening on the crashes, you should enable some debug and may be constantly printf your free memory. You could add a line of code in StreamCopy() to check if the buff=malloc() did return something != NULL, as NULL means that there was not enough memory to reserve as requested. Put a debug inside to see if that condition happens. And, I think, if a free(NULL) is issued, something crashes. I am not sure, but put that while(){} loop inside an: if( buff) { loop } else { Debug() <- could be printf("No MEM!\n") free(buff) } If the debug comes, you know two things: 1) You run into conditions, where no memory is available anymore 2) I was was wrong and the free(buff) can be called when the malloc failed and buff is NULL. If it still crashes, and there is only a part of the debug or no debug, add a fflush( stdout) behind the debug and try again. If now the debug comes, you put free(buff) out of else into if and if now debug works you have only one problem left: You need to find out, why now the system does not crash, but looses data cause there are no buffers available. Please check the behavior of fread. I am mixing that up often, but there are functions that _wait_ for data to arrive and have a timeout and are blocking and there are ones that take what is available and do not block if there is no data available. So if you use one of the blocking ones to read from usart or network, the buffer of the other thread may fill up, while the thread is waiting, blocked by the active thread. It is better to use the non-blocking function or set a timeout of a very low to nothing value for the blocking ones. So you will more often switch from one task to the other but you work with smaller buffers and higher 'sampling' of data to transfer. Best regards Ulrich asdus schrieb: > Hi all! > After some tries I'm get fully workable code. You can see that here: > http://pastebin.mozilla-russia.org/102504 > > But I still have rare freezes, and need to manually reset my device. > Have a chance to resolve this? > > 2009/10/27 asdus <asdusik@...>: >> Hi all. >> For my home automation i need to use 2 rs232<->ethernet converters >> I'm buy Ethernut V 1.3 H board and try to make it, using rs232d, Basic >> TCP Server and Serial Port Monitor examples. >> Using that i need to do this in dedicated threads, because i'm use >> other ethernut's digital pins to get home events. All my tries fails, >> i have lags using my remote rs232's. > _______________________________________________ > http://lists.egnite.de/mailman/listinfo/en-nut-discussion http://lists.egnite.de/mailman/listinfo/en-nut-discussion |
| Free embeddable forum powered by Nabble | Forum Help |