PDA

View Full Version : IP Communication Error - 501 Not Implemented: Only GET and POST supported



gravy
March 1st, 2014, 07:17 PM
Hoping anyone can point me in a direction here..

I'm trying to communicate via IP with my preprocessor. I've setup a transport device and it appears to connect and communicate ok, as I receive the "heartbeat" events back from the processor in the log. I've attached my transport file here:
6660

However - when I try to send a command using the following:


local txManager = ComponentManager:GetComponentUsingName('Transport Manager')
local tp = txManager:GetTransportUsingName('BrystonSP3_IP')
tp:Send("#10MPWRQS\r\n")


I receive the following feedback from the preprocessor in the LUA Interactive Log:


HTTP/1.1 501 Not Implemented
501 Not Implemented: Only GET and POST supported


Is there a change i need to my transport setup, or is the issue with my preprocessor?

Ron
March 2nd, 2014, 08:15 AM
Well use are using plain TCP on a device that requires HTTP. Try using the curl libraries in Girder.

gravy
March 2nd, 2014, 05:30 PM
Well use are using plain TCP on a device that requires HTTP. Try using the curl libraries in Girder.

OH! Right. Well using my browser, I am able to send an HTTP command such as:


http://192.168.0.77/cmd.cgi?cmd=%2310MVOLQS.


I then must issue the following command to retrieve the response to the command:


http://192.168.0.77/status.xml


This returns an xml result with a specific xml field holding the result:


<tw0>#10MVOL0800</tw0>


currently I"m trying the following code to issue the 2 commands and print the results, but I'm not having much luck.. yet...


require('luacurl')
function UrlDownloadToMemory (url)
--print("UrlDownloadToMemory using curl...", url)
local opt = {}
opt.headerlen = 0
opt.len = 0
opt.data = ''
opt.header = ''
opt.callback = callback
local c = cURL.new()
c:setopt(cURL.OPT_URL,url)
c:setopt(cURL.OPT_SSL_VERIFYPEER, false)
-- c:setopt(cURL.OPT_HEADERFUNCTION, ExtractContentLength2(opt))
-- c:setopt(cURL.OPT_WRITEFUNCTION, SaveDataToString2(opt) )
c:setopt(cURL.OPT_TIMEOUT, 60)

local v, e = c:perform()
if ( not v ) then
c:close()
return nil, e, v
end
c:close()
return opt.data, opt.len

end
local url = "http://198.162.0.77/cmd.cgi?cmd=%2310MPWRQS."
local a,b,c = UrlDownloadToMemory(url)
url = "http://192.168.0.77/status.xml"
a,b = UrlDownloadToMemory(url,cb)
print(string.format("Results: a=%s",a))
print(string.format("Results: b=%s",b))

gravy
March 3rd, 2014, 09:34 AM
OK nevermind - I think I found a much simpler answer. I'll post my LUA for others when its functioning. Thanks for pointing me in the right direction Ron.