Problem of Windows vs Mac OS with socket read/write and LabView
HelloI inherited, multithreaded code, with a singleton that communicates with LabView via few ports/sockets. I don't know (but don't think) mention it in this case multithreading issues, but in case you think there could be a problem. All communications to the LabView through LabView class (instance) singleton.
When we run the code on the same box of MS Windows XP as the LabView so, it works properly; This means that LabView receives orders and the java receives the results. When we run it on a Windows XP box in another room with another subnet it works fine as well. When we run a Mac OS in the same room/network reader.ready () is not true in the time-out period. (see the line of reader.ready () in the original code).
Does anyone know why it would work for Windows but not Mac OS?
A current "guess" what is bad on my part, is that code below (taken out of context, otherwise the position would be really long) needs of some rethinking. Any help/comments/advice on how it is encoded is greatly appreciated.
Here are the existing code.
// some declarations.
long t0, t1;
long waittime = 5000;
BufferedReader reader;
public synchronized void connectCommPort() {
if (commportconnected != true) {
try {
sock = new Socket();
InetSocketAddress endpoint = new InetSocketAddress(IPaddress, commPort);
sock.connect(endpoint, 4000); // try to connect with a timeout of 4 seconds.
reader = new BufferedReader(new InputStreamReader(sock.getInputStream()));
writer = new PrintWriter(sock.getOutputStream());
System.out.println("mec: LabV: SUCCESS - network connection to Labview command port succeeded");
commportconnected = true;
errorstatus = false;
} catch (IOException ex) {
logwriter("LabV: WARNING - network connection to Labview command port failed."+ex.toString());
System.out.println("mec: LabV: WARNING - network connection to Labview command port failed."+ex.toString());
commportconnected = false;
errorstatus = true;
}
}
}
public synchronized float readpot(int potnumber) {
String smotor = Integer.toString(potnumber);
if (potnumber >= 0 && potnumber <= 5) {
String message = "pot " + smotor;
connectCommPort();
if (commportconnected) {
try {
writer.print(message + "\r\n");
writer.flush();
logwriter("LabV: [sent] " + message);
potvalue = potlistener();
} catch (Exception ex) {
System.out.println("mec: Exception while sending command "+ex.getLocalizedMessage());
}
disconnectCommPort();
}
} else {
if (potnumber == 7 || potnumber == 6) {
potvalue = 5.f;
logwriter("Faked pot reading for potnumber " + potnumber);
} else {
logwriter("WARNING: " + potnumber + " is not a valid pot number (must be 0 to 6)");
}
}
return potvalue;
}
public synchronized float potlistener() {
String message = null;
t0 = System.currentTimeMillis();
t1 = System.currentTimeMillis();
boolean donereading = false;
while ((t1 - t0) < (waittime) & donereading != true) {
t1 = System.currentTimeMillis();
try {
while (reader.ready()) {
message = reader.readLine();
logwriter("LabV: [received] " + message);
if (message.contains(".")) {
potvalue = Float.parseFloat(message);
}
donereading = true;
} // close reader-ready-while
} catch (Exception ex) {
System.err.println("Exeption in potlistener() "+ex.getLocalizedMessage());
}
} // close timeout while loop
return potvalue;
}
In particular, I have readLine() in a loop where I catch the exception if it is not read and just keep trying? What is the "best way" to do?Here's what I thought, something like:
while ( ((t1 - t0) < waittime) && !donereading ) {
t1 = System.currentTimeMillis();
try {
message = reader.readLine();
logwriter("LabV: [received] " + message);
if (message.contains(".")) {
potvalue = Float.parseFloat(message);
donereading = true;
}
} catch (Exception ex) {
System.err.println("Exeption in potlistener() "+ex.getLocalizedMessage());
}
} // close timeout while loop
(a) No, but I would look into the configuration of the network itself rather than the Java code.
(b) the correct way to enforce a timeout of read is through Socket.setSoTimeout ().
Tags: Java
Similar Questions
-
Will there be another windows coming out soon with the floppy drives and DVD players.
Will there be another Windows coming out soon with the floppy drives and DVD players.
Hello
Disks: I don't think so. I always keep 25 floppy disks for Windows 95, should be a few thousand disks for Windows 10. Very, very, very expensive to store files and transport.
Of DVD: would soon come out, new machines will have 10 Windows (who knows) pre-installed or downloaded. You can always find Windows 10 DVD in some countries where users will still have to use dial-up Modem.
Hope it makes sense.
-
Hello
I am writing a VI to control PWM with a microcontroller via a serial port. I wrote a simple code for the microcontroller that allows me to set the ratio of duty cycle on a scale of 0-65535. It works very well with Termite of Compuphase (RS-232 plug); The microcontroller invited me to an entry, expected that I would one, updates and expected another entry when I decided to send him. Now, I'm trying to get the same functionality on a LabVIEW vi but hit a snag.
When I tried to send my orders with a series read base and an example of writing, everything worked fine. I could see the prompt entry, write an entry and if I was quick enough, check out the update message. Even when I was not fast enough, I was able to check the update by monitoring the PWM pin with a Logic Analyzer. The problem with the basic example, however, is that I need to update the report to aura cyclical ratio, so I went for an example of reading continues writing. The problem I've met; is that I have to switch between reading and writing to make it work. When I do that, either I don't hold write it down long enough and nothing happens, or I get several updates when I switch to reading. Some of these updates don't even match and produce updates to defective upgrades for example; 16000 16000, 16000, 16000, 6000, 600, 60, 16000, 1600, 60, 0, 0, 0, 16000, 60, 0, 0 etc.
I tried which allows characters of endpoint in the hope that the writing would end at the end and go to reading where he would receive a termination character and wait for me allow writing once again, but nothing helped. I still have to alternate between the two and either get no response on reading several updates of variable accuracy. I tried to remove her allows read/write and their structures of matter in the hope that the loop flow, associated with the characters of endpoint would the case, but then the updates don't register at all. The funny thing is I did a VI like this before with an Arduino and that there not even no need to switch between writing and reading (I'm now using a Board of Freescale FRDM).
I was also the frequency of timeout errors; Error-1073807339 at VISA Read, reason Possible: VISA Hex 0xBFFF0015. I removed the option to stop the while loop if there is an error so I can run but always pops up an error on the judgment occasionally. Could the problem of synchronization always cause me problems?
Would appreciate all advice really, I am providing my slightly modified example screws and can provide the code for microcontroller on request, even if it's very simple.
Thanks in advance, it is
Yusif NurizadeIn other words, frankly, a good bad example you according to your code. Also, you have the order of writing and read upside down in your amendment if the instrument requires a command to return something. It should really be using a structure of the event. The structure of the event around a write and read and use a value change event. I have attached a quick change. This mod is still a reading after writing. If necessary, you may have two separate events to write and read.
-
Printing problems with Adobe read XI and Adobe Reader DC
I try to print with Adobe Reader XI as well as Adobe Reader CD on another computer and for some reason it wont let me print more. I get a window that says "the document could not be printed" then click OK and another window with 'There were no pages selected' on the printed page where it says printing Pages, I choose 'All' on the page I want to print. Can someone help me please. Never had this problem on my laptop with Adobe Reader XI. Thank you
Hi carolj54323846,
Please try the steps in this article:https://www.adobe.com/support/techdocs/333236.html
If this does not work, then the uninstall using cleaning drive tool.
https://www.Adobe.com/support/techdocs/333236.html
After uninstalling with the cleaning tool, install drive DC or XI from here.
http://get.Adobe.com/reader/Enterprise/
Thank you
Abhishek
-
Windows 7 & MS keyboard with fingerprint reader
Hi - running Win7 Ultimate - clean install - I have the Microsoft keyboard with fingerprint reader - anyone know if this is supported (fingerprint reader that is - not only the keyboard) and if not, MS have plans to support it and when?
Mike
Thanks for your reply. I am running 32-bit. IntelliPoint s/w is available for the item of keyboard, but just what is fingerprint reader (which requires the persona digital s/w) is not supported under win7. I refer to my question above - does anyone have an idea if MS will support it in the near future or the product of by MS fingerprint reader is a lost cause.
AFAIK, there is no intention to provide the software for this device for Windows 7. For more information, you can try to contact the number here:
http://www.Microsoft.com/hardware/support/FingerprintReader.mspx
Want to know if your hardware current & software will work with Windows 7? Click on these links: *Windows 7 Upgrade Advisor * *Windows 7 Compatibility Center*.
-
How to use the kit sensor Bioinstrumentation Vernier with NI ELVIS II and LABview on a CPU?
So I have the NI ELVIS II + and a box full of Bioinstrumentation sensor, including Kit sensors: Analog Proto board connector (s), pressure sensor, hand dynamometer, hand grip monitor heart rate, EKG sensors, Surface temperature probe, among others.
I can't seem to get all the sensor data to my PC that I use, I'm not too familiar with electrical circuits but I followed the manual directions for the specific sensor but it seems as if it doesn't have a difference. I'm with copper son crochet and so that they know the places appropriate (according to the manual) but nothing.
Am I missing something? I have also the is open regardless of the specific LABview laboratory (Surface Temp lab for example), but when I press run it is as the sensors are not recognized or even be recognized. The sensors are plugged into the connectors on the analog Proto Board also. What I am doing wrong, and how can I get these sensors to work?
Any help will be greatly appreciated.
From what I see, it looks like a typing mistake in the manual.
Try to connect GND AI0 - and NOT ALWAYS.
It should look like this.
Connect the following pins for wire connector:
AI0 + SIG1 analog connector Proto Board
+ 5V power supply DC to 5V analog Proto card connector
Power supply to the GROUND to GND of the analog Proto board connector
AI0 - GND of the analog connector Proto Board
-
I had some virus that wiped out my computer and began to delete files .exe for evrything and started to interfere with my network connections that made me unable to get on the internet. I've got rid of the virus, but still not able to get on the internet, so I decided to reinstall Windows XP from the service pack CD that I got with the computer. Now that I did it, it seems that all the components of windows have disappeared from my list of programs in the control panel. I still have everything that was on the hard drive on it, but I can't seem to get things to transfer to the new XP operating. My biggest thing I found is that my soundcard has seemed to disappear and my volume control will not work because it says I have no mixers or equipment installed. Help, please.
You don't have a clean install of Windows. Backup your data and do a clean install according to the instructions below. Once installation is complete, you will then need to install the drivers for all your hardware.
http://michaelstevenstech.com/cleanxpinstall.html - Clean install - how-to
http://www.elephantboycomputers.com/page2.html#Reinstalling_Windows - you will need at hand MS - MVP - Elephant Boy computers - Don ' t Panic! -
How to control a Mac mini with HDMI ports fries and lightning? (The rest is ok)
Recently, a lightning strike fried video output (HDMI and lightning) ports on my Mac Mini end of 2012. As far as I know, the rest of the machine works fine. It's just blind. I can't have everyone working on this, but I don't want to throw a perfectly (well, almost perfectly) computer works.
If I can get a control over the Mac Mini for a few days, I could set up as a dedicated time Machine or maybe even an iTunes or media Server. How can I achieve this?
Configure the screen sharing on the Mac.
To do this, you must have another recent Mac.
You can start the problem Mac in target disk mode, connect the two Mac by FireWire or Thunderbolt, boot the Mac problem with button down T, boot the first Mac since the Mac HD problem and sharing Setup screen
http://www.macissues.com/2014/05/07/how-to-set-up-and-use-screen-sharing-in-OS-x /.
http://www.TechRadar.com/us/news/computing/Apple/how-to-use-screen-sharing-in-Ma c-os-x-1296285
Alternatively, you can take the drive out of the Mac problem and start another Mac that and configure sharing screen.
You can also get a USB video card and put in place by the target disk mode or by removing the similar disk for screen sharing
-
My system is not working too, before a return Wea? I try to fix it, through, Fixit online, got the massage (automatically repair Windows Search problems, such as corruption failures, crashes and database startup)
I don't know what to do, please help me Salove problem, thank U, Best looks
:):):)
first run checkdisk
If you have not installed recovery console, and then run from the start menu
go to start, run, type cmd
in cmd type chkdsk c:/r, and press enter
type y for Yes and press enter
Type exit, and press enter
restart the pc, let checkdisk finish and run again.
restart the pc and the error persists there?
Please give an EXACT error message.
also, make sure that your pc is clean
!. What is your current antivirus?
2 follow these steps:
Download, install, update and scan with these full free malware detection programs:
Malwarebytes (MMFA): http://www.malwarebytes.org/products/malwarebytes_free
SUPERAntiSpyware: (SAS): http://www.superantispyware.com/
Remove all found, restart, and run again until analyses race clean, these can be removed later if you wish. Perform analyses to one at a time, please.
-
in live mail: page w / emails becomes black. upper part is ok (host-files-display-accounts) rest becomes black. I can close the program, re open and may be authorized.
Hey Dano,
The question you posted would be better suited to the Windows Live community. Please visit the link below to find a community that will support what ask you
http://windowslivehelp.com/product.aspx?ProductID=15 -
I have a laptop that has Windows 7 OEM Home. The laptop had a hardware failure and is not repairable. Can I transfer the operating system of a new generation of computer laptop?
Sorry, but a Windows 7 OEM is not transferable to another PC because it is related to the 1st computer on which it is installed.
Here is the current information System Builders/OEMS 'use' of Microsoft
OEM System Builder licensing
http://OEM.Microsoft.com/script/contentPage.aspx?PageID=552816Licensing for lovers
http://OEM.Microsoft.com/script/contentPage.aspx?PageID=563841The great Goodby:
Your motherboard breaks down, unless the replacement card is the same your OEM version will no longer turn on and can not be moved or transferred to another computer.OEM of Windows 7 versions have the following limitations of 'important ':
(1) OEM versions don't offer any free direct support from Microsoft technical support Microsoft
(2) OEM licenses are tied to the computer 1 you install and activate it on.
(3) you cannot reuse/reinstall an OEM version on another computer or another/replacement motherboard.
(4) the OEM versions cannot be used to upgrade an earlier version of Windows, you must perform a
Clean install (this means that your data is saved and the application must be reinstalled).What is software OEM: http://support.microsoft.com/gp/oemsupport_1/en-gb
Licensing FAQ: http://www.microsoft.com/OEM/en/licensing/sblicensing/Pages/licensing_faq.aspx
J W Stuart: http://www.pagestart.com
-
Report Generation Toolkit compatibility with Microsoft Office 2013 and LabVIEW 2011
Hello
I design the 2011 Version of LabView to test solid state device and need to create test data after this unit tested.
When I save the test data in the configuration of Excel after you run the Laview program, it created an error like "error - 41007 is is produced in NI_report.lvclass:New Report.v->... OR reports; Musr you have the LabVIEW Report Generation Toolkit for Microsoft Office installed to create this type of report. The musr toolkit also have an activated license or be in trial mode. »
Questions: Do I need to install LabView Report Generation Toolkit for Microsoft Office on my computer? If Yes, what is the LabView Report Generation Toolkit for Microsoft Office Version. Where can I find this software?. I use Labview 2011, Windows 7, MS 2013 in the computer.
Thank you
Jonathan Tran
You can try this: http://download.ni.com/evaluation/labview/ekit/other/downloader/2011RGT.exe
From this link: http://download.ni.com/evaluation/labview/ekit/other/downloader/
-
sr830 connected with rs232, read freq and tension doesnot happen simultaneously
Hello
I'm having a problem, try to set the frequency and voltage in the auxiliary output simultaneously. I wrote two codes, one to determine the frequency and another to set the voltage of the auxiliary output and used them as void / screws in my main program that, at the moment, contains only these two elements. When I run the program the first time, the two frequencies and voltages are defined, but during subsequent runs that one has the value whilw the other keeps the old value and I have to run the program again to set this parameter. What is the problem? can u please help me. I'm just a week in the labview programming, but I have to implement hysterysis C - V in time very short, which these controls are a part. Please find attached programs.
The next problem is your termination characters. Your string constants indicate a \r\n, but the problem is that they are in normal mode and so please send 4 bytes of a backslash backslash, r, n. You must edit these constants to be in mode '\mode' of the backslash so that when you enter \r\n, it is in fact two bytes, consisting of a carriage return (ASCII 13) and line feed (ASCII 10)
-
Repeat the Scans with DAQmx read/write
Hello:
I use DAQmx vi to generate signals on channels ao0/1 a reading of the signals of the channels ai0/1 a card NI USB DAQ of 6251. I do this by using the read and write of vi and a trigger vi. This vi will run successfully for a single analysis. Now, I need to be able to perform multiple scans with the same settings but separated by 5 seconds or more. When I click on Scan, the vi analysis. However, when I click scan again once it does nothing and I don't know how to scan again.
The vi VU RAMP MOD (not included) is simply used to generate the shape of the signal.
Thank you!
-
What is the black box near the cursor with pixel reading that and how do I get rid of him?
It's this box. It's always in the way. What is the official name for him and how to hide or disable or at least somewhere move elsewhere?
Thank you!
Photoshop > Preferences > Interface > display values of going > never
Maybe you are looking for
-
How can I create a group in my address book?
I am looking at the help page, and he has "contacts" in the list, but no link to something useful. How can I create a group? I want to send something to a group of people, but I don't want them to see all the other people who are part of the group.
-
. MAB imported address book file is empty in Thunderbird, why?
I'm using Linux Mint 17. I recently updated from a previous version. I tried to import my old address book, but when I open it there is no information there. I can open it in my text editor, and they're all here! What is the problem? It seems that al
-
How can I stop redirected to 'my filestore.
I have been using linux mint for a week or two. I can sometimes be re-directedin what we call "my filestore. HP cenetr PC dual boot windows media up toI'm used to Linux. Some have done research on forums and havn't found a lotabout this problem, is t
-
10 on Satellite click Mini L9W - B - all Windows problems?
Everyone got the upgrade to Windows 10 yet? Problems with the drivers, etc?
-
Spectrum of HP 13-v013tu: USB port not working not not the spectrum 13
Hello. I bought the HP 13-v013tu a few months ago spectrum and in general the laptop works very well. However, I noticed that 3 C type USB ports in the back, one of them do not work. The USB port for the electrical connection to the right is fine,