|
RJ11 is a basically a phone type connector - used for ADSL, telephone, and modem cables etc. You can;t connect that directly to the PC unless it magically is also USB compatible. Which is very unlikely. Even if you can, without knowing how to talk to it, you don't stand much chance at all of getting this working.
So start with the manufacturers - most will have a website and technical support who should be able to help you. But nobody else can!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Thank you for your feedback, but do you think we can convert the RJ11 to USB Virtually or we must use a hardware converter?
|
|
|
|
|
Hardware, almost certainly. USB is very different from "normal" RJ11 - but you need to talk to the manufacturers to be certain, as they might just be using the connectors and not the voltages RJ11 cabling normally does.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I was in the industry in the 90's.
The cash drawer used a telephone line that was RS232, just 6 wires I think.
2/3 and 7 for transmit and receive.
We opened the port and sent several chars to the drawer back then. The draw would check the char and actuate the solenoid. I don't remember the char code or code sequence. but I think it was all the same. Like 1 company in China made all the solenoids.
Program the port, 9600,N8P
Open the port,
check drawer status
send the code sequence if closed
check drawer status
close the port.
https://www.cashdrawer.com/wp-content/uploads/documents/serial_pro_users_guide.pdf[^]
|
|
|
|
|
I have created TcpListnear Program using SslStream Class. (Use Same Code which Define in Example TCPListnear in SSLStream )
When I execute it, It is directly exit by Environment.Exit(1).
I think its because of ssl certificate.
Or may b I did something wrong.
How to solve this? Please Suggest.
modified 21-May-16 3:44am.
|
|
|
|
|
since you dont post any code alluding to your implementation, the only thing(s) I can suggest is/are :-
Add logging to your code
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.
The debugger allow you to follow the execution line by line, inspect variables and you will see that there is a point where it stop doing what you expect.
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
|
|
|
|
|
In my question I have posted One Link of SSLStream.
In that article Example of TCPListnear is Displayed. I have used same code for my application. Even No single Line Change has been done by me.
When I run my TCP Server in Console application, It receive no arguments. So it will exit application as described in code.
Which arguments I have to pass?
I know debugger.
First Refer that code.
|
|
|
|
|
did you check the example Main program ?
certificate = args[0];
SslTcpServer.RunServer (certificate);
From the SslTcpServer Class :-
Quote: // The certificate parameter specifies the name of the file
// containing the machine certificate.
So you need to pass in a filename that holds the certificate
|
|
|
|
|
Ya,Exactly.
But how can I create ssl Certificate to attach?
|
|
|
|
|
|
Yes, the problem is with the certificate file that you are going to pass. If you read the code provided on that page,
private static void DisplayUsage()
{
Console.WriteLine("To start the server specify:");
Console.WriteLine("serverSync certificateFile.cer");
Environment.Exit(1);
}
public static int Main(string[] args)
{
string certificate = null;
if (args == null ||args.Length < 1 )
{
DisplayUsage();
}
certificate = args[0];
SslTcpServer.RunServer (certificate);
return 0;
}
In this code sample, you will see that the DisplayUsage function calls the Environment.Exit(1). This is the problem when you don't pass the certificate file as a command line argument. I would suggest that you read the remarks[^] on that document where the procedure is explained, why file is needed and how you should pass it, and read this, https://technet.microsoft.com/en-us/library/cc770735%28v=ws.11%29.aspx[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I have Certificate in my Certificates snap-in. how can I attach that???
Or I have one .pfx file downloaded from Internet. When I pass this file it display Exception --> cryptographicexception :The specified network password is not correct.
What should I Do???
|
|
|
|
|
You will pass the path to that file, because that path is being passed as the argument to certificate creation object. Just make sure, it can be used as, X.509v3 certificate. This is done by,
X509Certificate.CreateFromCertFile(certificate);
So, pass the file that can be used to be mapped against this standard.
X509Certificate.CreateFromCertFile Method (String) (System.Security.Cryptography.X509Certificates)[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Done It.
I have given path of certificate to Server as command Line Argument.
I have also given the same certificate to client as command line Argument.
server Accept Certificate from the client but at client side it gives error:
AuthenticationException was caught : The remote certificate is invalid according to the validation procedure.
|
|
|
|
|
|
Thanks.
So any other option by which I can Create Certificate which can accepted by client? Just for Testing Purpose?
|
|
|
|
|
Add the issuer as a trusted issuer on the client side. That is what is done in development and testing purposes. You don't need to get a certificate for development environment. Certificates matter when you are publishing the product.
On development environment, you just have to mimic the process. It can be done by either adding your own issuer (a software program) as a trusted one. Otherwise, ignore the request, which sadly cannot be done when the function always throws an exception.
Working with Certificates[^]
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
I saw a simple example from microsoft "How to: Populate an XML Tree from the File System (C#)".
But I cant figure out how to reverse the XML to get a list of all files with full qualified path simular to "dir /s /b" would produce:
Tmp\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe<br />
Size: 4608<br />
Tmp\ConsoleApplication1\bin\Debug\ConsoleApplication1.vshost.exe.manifest<br />
Size: 473<br />
Tmp\ConsoleApplication1\obj\Debug\TempPE\ConsoleApplication1.csproj.FileListAbsolute.txt<br />
Size: 322<br />
... and so on<br />
Can somone help with this?
Example from MSDN:
class Program
{
static XElement CreateFileSystemXmlTree(string source)
{
DirectoryInfo di = new DirectoryInfo(source);
return new XElement("Dir",
new XAttribute("Name", di.Name),
from d in Directory.GetDirectories(source)
select CreateFileSystemXmlTree(d),
from fi in di.GetFiles()
select new XElement("File",
new XElement("Name", fi.Name),
new XElement("Length", fi.Length)
)
);
}
static void Main(string[] args)
{
XElement fileSystemTree = CreateFileSystemXmlTree("C:/Tmp");
Console.WriteLine(fileSystemTree);
Console.WriteLine("------");
long totalFileSize =
(from f in fileSystemTree.Descendants("File")
select (long)f.Element("Length")).Sum();
Console.WriteLine("Total File Size:{0}", totalFileSize);
}
}
<Dir Name="Tmp">
<Dir Name="ConsoleApplication1">
<Dir Name="bin">
<Dir Name="Debug">
<File>
<Name>ConsoleApplication1.exe</Name>
<Length>4608</Length>
</File>
<File>
<Name>ConsoleApplication1.pdb</Name>
<Length>11776</Length>
</File>
<File>
<Name>ConsoleApplication1.vshost.exe</Name>
<Length>9568</Length>
</File>
<File>
<Name>ConsoleApplication1.vshost.exe.manifest</Name>
<Length>473</Length>
</File>
</Dir>
</Dir>
<Dir Name="obj">
<Dir Name="Debug">
<Dir Name="TempPE" />
<File>
<Name>ConsoleApplication1.csproj.FileListAbsolute.txt</Name>
<Length>322</Length>
</File>
<File>
<Name>ConsoleApplication1.exe</Name>
<Length>4608</Length>
</File>
<File>
<Name>ConsoleApplication1.pdb</Name>
<Length>11776</Length>
</File>
</Dir>
</Dir>
<Dir Name="Properties">
<File>
<Name>AssemblyInfo.cs</Name>
<Length>1454</Length>
</File>
</Dir>
<File>
<Name>ConsoleApplication1.csproj</Name>
<Length>2546</Length>
</File>
<File>
<Name>ConsoleApplication1.sln</Name>
<Length>937</Length>
</File>
<File>
<Name>ConsoleApplication1.suo</Name>
<Length>10752</Length>
</File>
<File>
<Name>Program.cs</Name>
<Length>269</Length>
</File>
</Dir>
</Dir>
------
Total File Size:59089
|
|
|
|
|
use FullName instead of Name
new XElement("Name", fi.FullName),
|
|
|
|
|
But that brings up next problem: You get the full path + filename.
First of all I am realy serious in finding out if there is a way to reverse the
new XElement("Name", fi.Name), version.
Secondly I want it relative to the starting path.
Maybe that was not clear. Lets say you have resulting XML (part ofthe example):
<Dir Name="Tmp">
<Dir Name="ConsoleApplication1">
<Dir Name="bin">
<Dir Name="Debug">
<File>
<Name>ConsoleApplication1.exe</Name>
<Length>4608</Length>
</File>
</Dir>
</Dir>
</Dir>
</Dir>
I want to read the results:
File.Name: temp\ConsoleApplication1\bin\Debug\ConsoleApplication1.exe
File.Length: 4608
Without the c:\.
Advantage: if you move all from c:\Temp to c:\Projects\Temp you can still find all files as in the XML if you revers the search.
Greetings
modified 22-May-16 16:55pm.
|
|
|
|
|
 I played around and did a realy dirty and probably inefficent solution for the problem (SHA256 was additionally added to XML):
using (var reader = new XmlTextReader(@"c:\Users\andre\Documents\Test3.xml"))
{
List<string> myDir = new List<string>();
bool isFile = false;
bool isFileName = false;
bool isSHA = false;
bool isLength = false;
string curFile = "";
string curLength = "";
string curSHA = "";
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.XmlDeclaration:
break;
case XmlNodeType.Element:
if (reader.Name.ToString().Equals("Dir",StringComparison.OrdinalIgnoreCase))
{
myDir.Add(reader.GetAttribute("Name"));
isFile = false;
}
else if (reader.Name.ToString().Equals("File", StringComparison.OrdinalIgnoreCase))
{
isFile = true;
}
else if (reader.Name.ToString().Equals("Name", StringComparison.OrdinalIgnoreCase))
{
if (isFile)
{
isFileName = true;
}
else
{
Console.WriteLine("error on Line {0} Name <{1}> Value{2}",reader.LineNumber,reader.Name,reader.Value);
}
}
else if (reader.Name.ToString().Equals("Length", StringComparison.OrdinalIgnoreCase))
{
if (isFile)
{
isLength = true;
}
else
{
Console.WriteLine("error on Line {0} Name <{1}> Value{2}", reader.LineNumber, reader.Name, reader.Value);
}
}
else if (reader.Name.ToString().Equals("SHA256", StringComparison.OrdinalIgnoreCase))
{
if (isFile)
{
isSHA = true;
}
else
{
Console.WriteLine("error on Line {0} Name <{1}> Value{2}", reader.LineNumber, reader.Name, reader.Value);
}
}
else
{
Console.WriteLine("Unknown Element {0} Name <{1}> Value{2}", reader.LineNumber, reader.Name, reader.Value);
}
break;
case XmlNodeType.Text:
if (isFileName)
{
curFile = reader.Value;
}
else if (isSHA){
curSHA = reader.Value;
}
else if (isLength)
{
curLength = reader.Value;
}
else
{
Console.WriteLine("Unknown Text Line {0} Name <{1}> Value{2}", reader.LineNumber, reader.Name, reader.Value);
}
break;
case XmlNodeType.EndElement:
if (reader.Name.ToString().Equals("dir", StringComparison.OrdinalIgnoreCase))
{
myDir.Remove(myDir.Last());
isFile = false;
}
else if (reader.Name.ToString().Equals("File", StringComparison.OrdinalIgnoreCase))
{
isFile = false;
Console.WriteLine("Path: {0}",string.Join("\\", myDir.ToArray()));
if (!curSHA.Equals("")) {
Console.WriteLine(" File: {0} Length: {1} SHA256: {2}",curFile,curLength,curSHA);
}
else
{
Console.WriteLine(" File: {0} Length: {1}", curFile, curLength);
}
}
else if (reader.Name.ToString().Equals("Length", StringComparison.OrdinalIgnoreCase))
{
isLength = false;
}
else if (reader.Name.ToString().Equals("SHA256", StringComparison.OrdinalIgnoreCase))
{
isSHA = false;
}
else if (reader.Name.ToString().Equals("Name", StringComparison.OrdinalIgnoreCase))
{
isFileName = false;
}
else {
Console.WriteLine("Unknown End element {0} Name <{1}> Value{2}", reader.LineNumber, reader.Name, reader.Value);
}
break;
}
}
}
(Note: string.Join()-Line destroys coloring)
Even it is not nice as it's not mucht better than just textparsing and manual decoding the XML , it works:
Path: Tmp\ConsoleApplication1\bin\Debug
File: ConsoleApplication1.exe Length: 4608
Path: Tmp\ConsoleApplication1\bin\Debug
File: ConsoleApplication1.pdb Length: 11776
Path: Tmp\ConsoleApplication1\bin\Debug
File: ConsoleApplication1.vshost.exe Length: 9568
Path: Tmp\ConsoleApplication1\bin\Debug
File: ConsoleApplication1.vshost.exe.manifest Length: 473
Path: Tmp\ConsoleApplication1\obj\Debug\TempPE
File: ConsoleApplication1.csproj.FileListAbsolute.txt Length: 322
Path: Tmp\ConsoleApplication1\obj\Debug\TempPE
File: ConsoleApplication1.exe Length: 4608
Path: Tmp\ConsoleApplication1\obj\Debug\TempPE
File: ConsoleApplication1.pdb Length: 11776
Path: Tmp\ConsoleApplication1\obj\Properties
File: AssemblyInfo.cs Length: 1454
Path: Tmp\ConsoleApplication1\obj
File: ConsoleApplication1.csproj Length: 2546
Path: Tmp\ConsoleApplication1\obj
File: ConsoleApplication1.sln Length: 937
Path: Tmp\ConsoleApplication1\obj
File: ConsoleApplication1.suo Length: 10752
Path: Tmp\ConsoleApplication1\obj
File: Program.cs Length: 269
If anyone has a better solution: youre welcome!!!
I'm still serious if theres not a easyser solution to revert back this (my current test) 1-Liner:
return new XElement("Dir",
new XAttribute("Name", di.Name),
from d in Directory.GetDirectories(source)
select CreateFileSystemXmlTree(d, progress),
from fi in di.GetFiles()
let myProgress = DoProgress(progress)
select new XElement("File",
new XElement("Name", fi.Name),
new XElement("Length", fi.Length),
new XElement("SHA256", GetChecksumBuffered(fi.FullName))
)
);
|
|
|
|
|
Member 2443306 wrote: myDir.Remove(myDir.Last());
myDir.RemoveAt(myDir.Count - 1); would be more efficient, and avoid a bug if multiple directories in the path have the same name (eg: Tmp\Path\Tmp\... ).
Better yet, replace the List<T> with Stack<T>[^], which is specifically designed for this type of scenario.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Aiks!!!
Thanks I overseen the problem with
myDir.Remove() against
myDir.RemoveAt(myDir.Count-1) .
I changed it to
Stack<T> but not realy see a advabntage.
|
|
|
|
|
|
Why not ask on the forum at the end of article? It's highly unlikely that the author is going to happen on this post?
This space for rent
|
|
|
|