Grab micro-controller info - c#

I have a client that is supposed to grab data from a micro-controller ( Arduino if you are familiar with it ), that transmits once a second a line of values, and send that data to a server to which the client is connected .
How should i do that ? The micro-controller when connected to the PC , 'shoots' data on one of the COMs.. should i approach the problem as a client-server ? I mean should i connect with my client to the micro-controller passing the mcontroller's port ? And if so, can anyone give me a link to such a solution ?

From what you're writing You could just download a port-analyzer to check what's coming in.
http://www.serial-port-monitor.com/
You can also write a simple macro in excel that grab data and output to sheet,
just open the com-port with the right settings.
If it's an 24/7-application, I'd recommend a simple complied program running as a service, .NET or maby compiled script, autoit3 or similar (if you're on win32).
http://www.autoitscript.com/forum/topic/19769-phone-dialer-using-com-to-modem-on-serial-port/
(3:rd post, Martin)
Regards,
//t

Related

Executing command using SSH.NET on digi 6030dx modem - what are this character sequences starting with left square bracket?

I have some large project that connect to many devices over SSH.NET
Now I have to add support for new modem witch is digi 6030dx.
I added it and I am able to connect with no issues
But when I send some/any command like show config the output is:
[16C[0K
[16C[0Ks
[17C[0Kh
[18C[0Ko
[19C[0Kw
[20C[0K
[20C[0Kc
[21C[0Ko
[22C[0Kn
[23C[0Kf
[24C[0Ki
[25C[0Kg
Commands
-------------------------------------------------------------------------------
config View and modify the configuration
exit Exit the CLI
analyzer Analyzer commands.
cli-legacy Enter the legacy Admin CLI.
cp Copy a file or directory.
help Show CLI editing and navigation commands.
ls List a directory.
mkdir Create a directory.
modem Modem commands.
more View a file.
mv Move a file or directory.
ping Ping a host.
reboot Reboot the system.
rm Remove a file or directory.
scp Copy a file or directory over SSH.
show Show instance statistics.
system System commands.
traceroute Print the route packets trace to network host.
update Update firmware.
dra.wk.0001> ashowconfigdra.wk.0001> ashowconfig
[16C[0K
Does anyone known what are this strange signs / why my command is splited by this and newlines?
It is first device that have this issue and the app support over 200 other with no issues.
I guess some coding issue or something ? putty does not show this signs so probably 'understand' them somehow?
Those are ANSI escape codes.
In general, with SSH, you get these only if your client (library) declares support for terminal emulation.
SSH.NET library does that always, when you use the "shell" channel (SshClient.CreateShell or SshClient.CreateShellStream).
In general (were you connecting to well behaving SSH server), to avoid getting the codes:
Use "exec" channel (use SshClient.RunCommand). SSH.NET does not use terminal emulation on "exec" channel. Though SSH servers on "devices" (contrary to full servers) usually do not implement the "exec" channel. See also What is the difference between exec_command and send with invoke_shell() on Paramiko?
Modify SSH.NET code not to request terminal emulation for the "shell" channel. – Remove SendPseudoTerminalRequest request from Shell.Start implementation.
Though as you are connecting to some "device" and telneting further to another device and the codes probably come from the far device, the question is whether this will in fact have any effect on that device at all. Possibly you won't be able to avoid getting the codes. Lack of terminal emulation on the first SSH connection possibly won't have any effect on the second telnet connection.
In the end, you may have to deal with the codes.
See also How to strip ANSI escape codes from AIX topas command result in C#.
i did for now
this.answer = Regex.Replace(this.answer, #"\r\[\d{0,3}C\[0K", "", RegexOptions.IgnoreCase);
will see if have any negative impact but looks perfect for now :D

How would I start Garry's Mod and connected to an address on launch?

I'm currently in the middle of making a game launcher for my Garry's Mod server. Right now, when you press Launch all it does is start Garry's Mod with Process.Start("GarrysMod.exe").
Is it possible for me to start Garrys Mod with launch arguments for example that starts Garrys Mod up and connects to the server when it loads (e.g Process.Start("GarrysMod.exe -connect 1.2.3.4). If anyone knows if this is possible or how to do this, please let me know.
Thanks!
The simplest (and preferred) way of doing this is this:
steam://connect/<IP or DNS name>[:<port>][/<password>]
This will connect the user to the server specified by the IP or DNS name. You do not need to specify anything. Steam will detect on it's own that you want to connect to a GMod Server.
If GMod is already running it will just connect the user, otherwise GMod will be started.
More Information can be found here
Other Methods should not be necessary when using the official steam version of Garry's Mod

Voice call with gsm-modem by C#

im new in c# and i wanna right a code for have a voice call through the GSM modem , actually don't know about how to receive and send voice or stream that ,if any one knows about how to do it please help me with this problem.
i just found this but didn't understand enough to develop my application.
every thing i know is just to send command ,unfortunately i do not even know the AT-Commands.
Port gsmPort=new Port();
gsmPort.Name="COM3";
gsmPort.open();
gsmPort.writeLine("AT\r");
I can suggest to you read these links:
http://www.zeeman.de/wp-content/uploads/2007/09/ubinetics-at-command-set.pdf
2.https://www.sparkfun.com/datasheets/Cellular%20Modules/AT_Commands_Reference_Guide_r0.pdf
https://www.youtube.com/watch?v=_3Vn_YEh3jM

BizTalk Static send ports changing the address(URI) using WMI script or updating in bts_sendport_transport not working

I am trying to change the static send port URI from BizTalk admin console by opening the configuration, I am able to do change the URI.
But if I do the send port URIchange using WMI script in c# or directly update on bts_sendport_transport, it changes the URI in database and the change appears in the send port list also.
Bur when I open the MQ configuration, I can still find the old URI in MQ definition.
Can any one please help me to change the MQ definition in send ports without using admin console?
I think your approach to the problem is wrong they invernted dynamic ports for your problem. since your question not clear enough may be I don't understand your problem clearly.
Here is link for Dynamic Ports and Usage http://www.codeproject.com/Articles/502425/BizTalk-Static-and-Dynamic-FTP-Send-Port-Sample
you must focus on last part
Msg_DynamicSend(FTP.CommandLogFileName) = "D:\\BiztalkLogs\\FTPLog\\DynamicFTPLog.txt";
Msg_DynamicSend(FTP.UserName) = "FTPUSER";
Msg_DynamicSend(FTP.Password) = "Pass1234";
Msg_DynamicSend(FTP.SpoolingFolder) = "/IN/";
Msg_DynamicSend(FTP.RepresentationType) = "ASCII";
DynSendPort(Microsoft.XLANGs.BaseTypes.Address)= "ftp://inhydeshrilata";
DynSendPort(Microsoft.XLANGs.BaseTypes.TransportType) = "FTP"

How can i know the actual geographical location of a database?

I am tasked to get the location where our SQL Server database is geographically located via C# code because it may vary time to time due to frequent relocation of our database to protect it from physical and cyber harm. Is this possible or another dream of my boss thanks in advance.
1 - Buy somethihng like this. It's a UPS GPS receiver.
2 - Connect it to the server machine.
3 - Write a batch or shell script that will call the GPS software and return the current position.
4 - Use xp_cmdshell to call this script and return the current position via SQL Server query.
Buy an iPhone/Android phone and have it sellotaped to the top of the machine that has the database on it. Write a quick app to have it look at the GPS API and post it's position to the database the phone is connected on using some kind of JSON/SOAP API over HTTPS (for security purposes).
You can then access the GPS information from where you are using C#.
Edit
Working with the GPS on Mono/iPhone: http://drdobbs.com/mobility/222600599
Example code, GPS on Mono/Android: https://github.com/gshackles/Sample-Projects/blob/master/MonoDroid/MonoDroidSamples/MonoDroidSamples/DemoActivities/LocationDemo/LocationActivity.cs
The simplest solution is to do a DNS lookup, then use an IP location service as Cody suggested. Try this:
var foo = Dns.GetHostEntry("database.windows.net");
Once you've got your IP address, you'll need to load something like http://www.iplocationfinder.com/65.55.23.107 using an HttpWebRequest, unless you want to pay for an IP location database. Once you've got the response to the HttpWebRequest, you can use a regular expression to parse the location name, or latitude and longitude if you need that instead.
Do you have so many servers which are moved around overnight in your company or is this for a cloud db setup? the IP address is probably a basic inaccurate-better than nothing starting point.
As Davide Piras mentioned you can use for example this site : http://ip-lookup.net/ to trace the IP Address of you're DB Server and you can grab the Output maybe using Regular Expresion's or http://htmlagilitypack.codeplex.com/ .
Bu that works only if you can get you're DB Server IP Address ,which i think shouldn't be an Issue because you need the IP for the Connection String .
To achieve that use a WebBrowser Control ,do webbrowser1.navigate("http://ip-lookup.net/");
than :
HtmlElementCollection elc = this.webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement el in elc)
{
if (el.GetAttribute("type").Equals("text") && el.GetAttribute("name").Equals("ip"))
{
el.InnerText = "Server IP";
}
}
next :
HtmlElement form = webBrowser1.Document.GetElementById("form_single_IP");
if (form != null)
form.InvokeMember("submit");
//Submit the form
and try to filter the output because im not very good using Regex .You can capture the Output by using webbrowser1.DocumentText;
Why not use the database to tell you the location? To clarify what I mean:
Using SQL CLR Stored Procedure To Track IP Address - but make the CLR sproc return the ipaddress of the server its hosted on.
I saw the azure connection string you mentioned to Cody and thought these would be a handy links:
http://blogs.msdn.com/b/windowsazure/archive/2011/07/06/windows-azure-deployments-and-the-virtual-ip-address.aspx
Get Azure public IP address from deployed app
Determining the time zone is probably the best you can do from SQL Server, but that could be enough for you based on your description. You can use this query to get the GMT offset of the time zone where the server is located:
SELECT DATEDIFF(hh, GETUTCDATE(), GETDATE()) AS ServerTimeZone
From this result, you can easily add some logic to return the time zone abbreviation, i.e. EST, CST, etc. I know this isn't much, but hopefully it helps.
If someone already physically moves the server, why not write some script that writes the corresponding location to DB? When the machine starts up, auto-start that tool and have the "mover" select a location.

Categories

Resources