Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FullUpload third argument #61

Closed
chewcw opened this issue Aug 31, 2019 · 0 comments
Closed

FullUpload third argument #61

chewcw opened this issue Aug 31, 2019 · 0 comments
Assignees

Comments

@chewcw
Copy link

chewcw commented Aug 31, 2019

Peep into the s7Client.FullUpload function, we should have another argument info[2] as the size? of the block? But in the document this is not mentioned, what should be the value here?

NAN_METHOD(S7Client::FullUpload) {
S7Client *s7client = ObjectWrap::Unwrap<S7Client>(info.Holder());
if (!info[0]->IsInt32() || !info[1]->IsInt32() || !info[2]->IsInt32()) {
return Nan::ThrowTypeError("Wrong arguments");
}
char *bufferData = new char[info[2]->Int32Value()];
int size = info[2]->Int32Value();
if (!info[3]->IsFunction()) {
int returnValue = s7client->snap7Client->FullUpload(
info[0]->Int32Value(), info[1]->Int32Value(), bufferData, &size);
if (returnValue == 0) {
v8::Local<v8::Object> ret_buf;
ret_buf = Nan::NewBuffer(
bufferData
, size
, S7Client::FreeCallback
, NULL).ToLocalChecked();
info.GetReturnValue().Set(ret_buf);
} else {
delete[] bufferData;
info.GetReturnValue().Set(Nan::False());
}
} else {
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());
Nan::AsyncQueueWorker(new IOWorker(callback, s7client, FULLUPLOAD
, bufferData, info[0]->Int32Value(), info[1]->Int32Value(), size));
info.GetReturnValue().SetUndefined();
}
}

@mathiask88 mathiask88 self-assigned this Nov 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants