Trax Posted January 26, 2021 Share Posted January 26, 2021 I have written a program that reads a serial port to obtain data. The problem is that the serial port is not multi-user. Only one person can read it at any given time. I am looking for a way to "lock" the serial port when one person is reading it so that others trying to access it will know it is "busy" and wait until it frees up. Is there a "standard" way of doing this? Link to comment Share on other sites More sharing options...
orbs Posted January 26, 2021 Share Posted January 26, 2021 if your program is the only one accessing the port, and only one instance of your program can use the port at any given time, then you can apply a locking mechanism like this: NOTE: although the title mentions locking files, this method is applicable for practically any object. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff Link to comment Share on other sites More sharing options...
junkew Posted January 27, 2021 Share Posted January 27, 2021 Can you explain more. How can 1 serial port on 1 computer be used by 2 persons at the same time? FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Trax Posted January 27, 2021 Author Share Posted January 27, 2021 It is odd. I have a Lantronix Device out in Production. It is what actually connects RS232 on one side and TCP/IP on the other. So various computers can access this "virtual" serial port at the same time but the Lantronix Box will only allow one of this computer to connect at any given time. Link to comment Share on other sites More sharing options...
Nine Posted January 27, 2021 Share Posted January 27, 2021 1 hour ago, Trax said: So various computers can access this "virtual" serial port at the same time but the Lantronix Box will only allow one of this computer to connect at any given time. It is getting clearer now. Are all those computers use the same application to access this virtual port ? Is it written in AutoIt ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
junkew Posted January 28, 2021 Share Posted January 28, 2021 hard to say without details on device type and your environment. No details in your question so quarantee that you get vague answers What happens if 2 users read at the same time? Why would it be a problem? If user A reads something whats the purpose of having user B reading the device? Shouldn't all the information come together thats read from the device? looking here https://www.lantronix.com/resources/networking-tutorials/device-servers-tutorial/ gives an idea how things can look. developer wiki seems not to be working and their forum seems not having any acitivity Are all endusers on their pc starting your program from a central network location? If so you could write a "lock" file in the folder when a users starts reading and you clean it when finished. You could have your program start with tcp/ip udf functions to communicate with each other You could make 1 PC dedicated for the communication and the other computers communicate with your central computer that dispatches FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
funkey Posted January 28, 2021 Share Posted January 28, 2021 We have same situation. Our solution is that a service is always connected to the device and the users only connect to the service. Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now