Click here to Skip to main content
15,886,519 members
Home / Discussions / C#
   

C#

 
AnswerRe: MEF Question Pin
Mycroft Holmes7-Jan-19 14:32
professionalMycroft Holmes7-Jan-19 14:32 
AnswerRe: MEF Question Pin
Dave Kreskowiak7-Jan-19 16:40
mveDave Kreskowiak7-Jan-19 16:40 
AnswerRe: MEF Question Pin
Pete O'Hanlon7-Jan-19 19:38
mvePete O'Hanlon7-Jan-19 19:38 
QuestionFailure to recognize Toolbox controls inside the encoding environment in visual 2010 Pin
Member 141105447-Jan-19 4:15
Member 141105447-Jan-19 4:15 
AnswerRe: Failure to recognize Toolbox controls inside the encoding environment in visual 2010 Pin
BillWoodruff7-Jan-19 4:32
professionalBillWoodruff7-Jan-19 4:32 
AnswerRe: Failure to recognize Toolbox controls inside the encoding environment in visual 2010 Pin
OriginalGriff7-Jan-19 4:46
mveOriginalGriff7-Jan-19 4:46 
QuestionIP commands Pin
Member 103699864-Jan-19 12:49
Member 103699864-Jan-19 12:49 
AnswerRe: IP commands Pin
Luc Pattyn4-Jan-19 15:24
sitebuilderLuc Pattyn4-Jan-19 15:24 
Hi,

setting up a communication between two devices may be hard to bootstrap; if at first it doesn't work you typically have too little information to figure which side is failing and what should be done to remedy the problem.

However if your target device already exists, and expects HTTP GET commands (as your post suggests), then you should be able to test it from any browser, e.g. Google Chrome.

Mind you, the peripheral when receiving a GET command, is normally expected to return some web page, i.e. some data that has this structure:

<html>
<head>
... the head may be empty
</head>
<body>
... some meaningful text goes here
... counter = 102 (*)
</body>
</html>


it is wise to take care of that right away, as it will help you in debugging the system.
(*) I would also suggest to include a counter value, so each time a page is returned it is different from the previous one, in a predictable way.

Similarly I also suggest you give your peripheral an observable something, say an LED that toggles each time a page request is received (that is a one-bit counter!).


Now I see some potential problems:

1. your "command" is passed entirely as one of many possible web page URLs, and it seems to contain spaces, which are not allowed in a URL (i.e. they should be escaped, this turns every space into the sequence "%20")

I find it easier to avoid all special characters, including spaces.

2. I would prefer to work with only one page, and pass all the details (relay number, relay state) and even the password as parameters; parameters are key-value pairs, starting with a question mark and separated by ampersands, so it might look like:
http://my_peripherals_IP_address/index.html?password=1234&relay=1&state=off


3. Depending on what devices and networks might sit between your PC and your peripheral, there may be a risk of your command never reaching your peripheral, due to caching somewhere on the way. This can be remedied by some META tags in the HTML head (very tricky to get a general solution), or by adding an extra parameter which is always different, like:
http://my_peripherals_IP_address/index.html?password=1234&relay=1&state=off&sequence=72834

As the URL of consecutive commands would all be different (having an incrementing sequence number), caches can not intervene.

4. You should be aware that an HTTP command may reach your peripheral (a) not at all (internet offers no guarantees), (b) just once, (c) many times. A browser is allowed to automatically resend a command that didn't get answered soon enough. So the concept of your peripheral and its command language must allow for unintended command duplication.

A safer way is to use an HTTP POST command rather than the standard HTTP GET command. This too can be achieved through a browser (e.g. there are extensions to Chrome for this purpose).


Once you got all the above up and running fine, you can try and create C# code that replaces your browser. There are at least two ways to handle this:

1. using a WebBrowser [^] Control, which basically is the kernel of Internet Explorer with an API so you can set the URL and request a page, view it, etc. When you're done debugging, the WebBrowser can remain off-screen or be otherwise invisible.

2. using some classes from the System.Net namespace, such as HttpWebRequest[^]. I suggest you google for some examples.


Hope this helps

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 4-Jan-19 21:58pm.

QuestionUsing Google Calendar API and email send a invitation to a user Pin
Nitish Prasad Satpathy4-Jan-19 4:02
Nitish Prasad Satpathy4-Jan-19 4:02 
AnswerRe: Using Google Calendar API and email send a invitation to a user Pin
Richard MacCutchan4-Jan-19 4:16
mveRichard MacCutchan4-Jan-19 4:16 
AnswerRe: Using Google Calendar API and email send a invitation to a user Pin
Pete O'Hanlon4-Jan-19 4:54
mvePete O'Hanlon4-Jan-19 4:54 
QuestionVisual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff3-Jan-19 20:47
professionalBillWoodruff3-Jan-19 20:47 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Richard MacCutchan3-Jan-19 22:17
mveRichard MacCutchan3-Jan-19 22:17 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff3-Jan-19 22:37
professionalBillWoodruff3-Jan-19 22:37 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Richard MacCutchan3-Jan-19 22:52
mveRichard MacCutchan3-Jan-19 22:52 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff4-Jan-19 4:31
professionalBillWoodruff4-Jan-19 4:31 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Richard MacCutchan4-Jan-19 5:09
mveRichard MacCutchan4-Jan-19 5:09 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Luc Pattyn4-Jan-19 6:25
sitebuilderLuc Pattyn4-Jan-19 6:25 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Richard MacCutchan4-Jan-19 6:37
mveRichard MacCutchan4-Jan-19 6:37 
AnswerRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Luc Pattyn4-Jan-19 0:54
sitebuilderLuc Pattyn4-Jan-19 0:54 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff4-Jan-19 4:24
professionalBillWoodruff4-Jan-19 4:24 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Luc Pattyn4-Jan-19 4:54
sitebuilderLuc Pattyn4-Jan-19 4:54 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff4-Jan-19 13:01
professionalBillWoodruff4-Jan-19 13:01 
AnswerRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
Richard Deeming8-Jan-19 7:57
mveRichard Deeming8-Jan-19 7:57 
GeneralRe: Visual Studio: detecting Class/Property access during break-mode ? Pin
BillWoodruff9-Jan-19 1:39
professionalBillWoodruff9-Jan-19 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.