khuenguyen Posted October 26, 2010 Share Posted October 26, 2010 Hi all, I use function ReadUntil in my app. When I run app I got error "Timeout". Please help me solve this problem. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 26, 2010 Share Posted October 26, 2010 Whatever you are reading until never occurs, at least not within the timeout value. What does the line look like? Link to comment Share on other sites More sharing options...
khuenguyen Posted October 26, 2010 Author Share Posted October 26, 2010 this is error: C1136 Timeout: MIO_ONOFF Line 7 - Uncaught error in sequence MIO_ONOFF here: - MIO_ONOFF is my sequence name - Line 7: strText = Device.COM1.ReadUntil(13) Link to comment Share on other sites More sharing options...
AzeoTech Posted October 26, 2010 Share Posted October 26, 2010 Well, a carriage return (ASCII 13) is not appearing in your data stream within the timeout value for the port. Just look at the monitor. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 26, 2010 Author Share Posted October 26, 2010 Tx (12:09:06.314): AI2M113 Rx (12:09:06.330): AI2M1V0.00410 above is data display on monitor windows that I sent/received on COM port. When I sent, I use command Device.COM1.Write("AI2M1" + Chr(13)), my circuit return one string with content: AI2M1V0.004. How I can receive it without error. I try use Device.COM1.ReadUntil(Chr(10)) but timeout occur. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 26, 2010 Share Posted October 26, 2010 Looks like your device delimits with ascii 10, so readuntil(10) should work. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 27, 2010 Author Share Posted October 27, 2010 thanks you. This problem solved Link to comment Share on other sites More sharing options...
khuenguyen Posted October 27, 2010 Author Share Posted October 27, 2010 I have some sequences, if I run a sequence then no problem. but, I run two sequences at same time, error "timeout" occur. Two sequences read and write data to one COM port. How fix this problem. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 27, 2010 Share Posted October 27, 2010 If you run two sequences communicating with the same comm port, you have to do some synchronization. Usually this is best done using the LockPort() / UnlockPort() functions as described in the help and the serial / Ethernet manual. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 28, 2010 Author Share Posted October 28, 2010 In my sequence, I use loop while to always send command and read return data. I tried LockPort()/UnLockPort() but only one sequence can run. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 28, 2010 Author Share Posted October 28, 2010 this is my code. Timeout occur at line " strDataIn = Device.COM1.ReadUntil(Chr(10))" code: While (1) if (!Device.COM1.LockPort()) throw ("Port in use!") endif Device.COM1.Write("AI2M0" + Chr(13)) strDataIn = Device.COM1.ReadUntil(Chr(10)) // no timeout delay(1) variable1 = Mid(strDataIn,6,5) MIO_VOLT.AddValue(variable1 * 65) Device.COM1.Write("DI1M1" + Chr(13)) strDataIn = Device.COM1.ReadUntil(Chr(10)) //timeout occur delay(2) strDataPro = Mid(strDataIn,3,2) if (!Compare(strDataPro,"S1")) status1 = 1 Fire_Alarm.AddValue(status1) else status1 = 0 Fire_Alarm.AddValue(status1) endif if (status1) Device.COM1.Write("DO1S1M1" + Chr(13)) else Device.COM1.Write("DO1S0M1" + Chr(13)) endif Device.COM1.UnlockPort() delay(1) endwhile my circuit return data with end of line character is ascii 10. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 28, 2010 Share Posted October 28, 2010 ReadUntil() takes a number, so its readuntil(10), not readuntil(chr(10)). Passing it a string will cause it to evaluate the string as a regular expression. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 29, 2010 Author Share Posted October 29, 2010 I repaired ReadUntil(10) but timeout still occur. Please help me. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 29, 2010 Share Posted October 29, 2010 Look in the monitor. Its most likely that the device is simply not responding within the timeout period. Link to comment Share on other sites More sharing options...
khuenguyen Posted October 29, 2010 Author Share Posted October 29, 2010 How I can repair it? I don't want re-design hardware. I have a program wrote java language, it can send/receive 60 commands per second. In device COM1, I choose timeout is 1000ms. Link to comment Share on other sites More sharing options...
AzeoTech Posted October 29, 2010 Share Posted October 29, 2010 I'm not saying there is anything wrong with the hardware, I just can't tell you what is happening. You need to look at the comm monitor to determine why DAQFactory thinks there is no response. If you want, post a screen shot of the comm monitor. Make sure the Display Time of Tx/Rx is checked. Link to comment Share on other sites More sharing options...
khuenguyen Posted November 1, 2010 Author Share Posted November 1, 2010 this is time send/receive in monitor windows: Tx: (08:55:26.321): AI2M013 Rx: (08:55:26.341): AI2M0V3.26710 Tx: (08:55:30.368): AI2M013 Rx: (08:55:30.388): AI2M0V3.26910 Tx: (08:55:34.415): AI2M013 Rx: (08:55:34.435): AI2M0V3.30010 Tx: (08:55:38.462): AI2M013 Rx: (08:55:38.482): AI2M0V3.30110 please check it for me. Thanks. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 1, 2010 Share Posted November 1, 2010 I don't see DI1M1 ever being output? Are you sure it is? Are you sure that line is being executed? Serial doesn't really ever timeout on writes, so something isn't right here. Link to comment Share on other sites More sharing options...
khuenguyen Posted November 1, 2010 Author Share Posted November 1, 2010 this is output of Monitor window: Tx (14:11:54.218): AI2M013 Rx (14:11:54.238): AI2M0V3.27610 Tx (14:11:56.264): DI1M113 Tx (14:11:57.264): DO1S0M113 Tx (14:11:59.265): AI2M013 Rx (14:11:59.285): AI2M0V3.28610 Tx (14:12:01.311): DI1M113 Tx (14:12:02.311): DO1S0M113 Tx (14:12:04.312): AI2M013 Rx (14:12:04.332): AI2M0V3.26110 Tx (14:12:06.358): DI1M113 and this is my code, with COM1 is COM port with parameters: Baudrate: 9600, byte size: 8bits, stopbits: 1, parity: none //ignore("all") Private string strDataIn Private string strDataIn1 Private string strDataPro1 Private string strDataPro2 global status1 global var0 = 1 global var1 = 0 global gStatus global variable1 While (1) if (var0 == 1 & var1 == 0) Device.COM1.Write("DI1M1" + Chr(13)) try strDataIn = Device.COM1.ReadUntil(10) strDataIn = ReadUntil(10) catch() break endcatch strDataPro1 = Mid(strDataIn,3,2) if (!Compare(strDataPro1,"S1")) status1 = 1 Fire_Alarm.AddValue(status1) else status1 = 0 Fire_Alarm.AddValue(status1) endif if (status1) Device.COM1.Write("DO1S1M1" + Chr(13)) else Device.COM1.Write("DO1S0M1" + Chr(13)) endif var0 = 0 var1 = 0 delay(2) endif if (var0 == 0 & var1 == 1) Device.COM1.Write("AI2M0" + Chr(13)) try strDataIn1 = Device.COM1.ReadUntil(10) catch() break endcatch variable1 = Mid(strDataIn1,6,5) MIO_VOLT.AddValue(variable1 * 65) var0 = 1 var1 = 1 delay(2) endif if (var0 == 0 & var1 == 0) var1 = 1 endif if (var0 == 1 & var1 == 1) var1 = 0 endif endwhile Link to comment Share on other sites More sharing options...
AzeoTech Posted November 1, 2010 Share Posted November 1, 2010 Your problem is with the device, not the code. Just look at the monitor. There is no response from the DI command and thus the reason you get a timeout waiting for one. Maybe your device requires a line feed (chr(10)) instead of carriage return at the end? Or perhaps both? I can't say since its a custom piece of hardware. Hyperterminal I believe will send both a carriage return and linefeed when you hit "Enter", so if it works there, you probably need both. Link to comment Share on other sites More sharing options...
khuenguyen Posted November 2, 2010 Author Share Posted November 2, 2010 I don't think so. If I sent command DI1M1\13 from Monitor windows, I will receive data. If in my sequence only sent "DI1M1\13", I will receive data. So, I don't think that my hardware error with command DI1M1. Link to comment Share on other sites More sharing options...
AzeoTech Posted November 2, 2010 Share Posted November 2, 2010 I'm sorry, but I get this all the time. People think DAQFactory is not working right and it turns out that it was a hardware problem. We even had someone saying DAQFactory Modbus wasn't working with a new Unitronics device. Turns out that the Unitronics device had a bug in its Modbus implementation, which they promptly fixed. DAQFactory is very well tested, especially in the serial and Ethernet comms and especially on stuff so basic. Serial / Ethernet is used by probably 80% of the thousands of DAQFactory users with no issues. I'm telling you, from looking at the monitor, DAQFactory is sending that command but it is not getting a response, and thus you are getting a timeout. I don't know why it works manually, but there is obviously something different in the way your device responds which is a bug in your hardware implementation. My guesses would be one of the following: 1) The script is running too fast and your device can't handle it. This would be surprising since you have delay(1) in there. 2) your device doesn't like having the DI1M1 command right after the AI2M0 command. 3) you have some really basic error, a typo that isn't getting carried over into the forum, a comm setting or something Try simplifying your sequence to just poll DI1M1. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.