Runs fine for me in v0.10.18
var str = "0184008000280000000000009a102404";
var a = [];
for (var i = 0; i <str.length; i += 2)
a.push("0x"+ str.substr (i, 2));
console.log(a);
//c.write(a);
//c.pipe();
I don't know what c is though
On Thu, Sep 5, 2013 at 3:40 PM, Felipe Silveira <[email protected]>wrote:
> I did and same erro:
> var str = "0184008000280000000000009a102404";
> var a = [];
>
> for (var i = 0; i <str.length; i += 2)
> a.push("0x"+ str.substr (i, 2));
>
> console.log(a);
> c.write(a);
> c.pipe();
>
> Code:
>
> net.js:450
> throw new TypeError("First argument must be a buffer or a string.");
> ^
> TypeError: First argument must be a buffer or a string.
> at Socket.write (net.js:450:11)
> at Socket.<anonymous> (/var/www/node.js:34:7)
> at Socket.emit (events.js:67:17)
> at TCP.onread (net.js:367:14)
>
>
> Em quinta-feira, 5 de setembro de 2013 16h22min41s UTC-3, Felipe Silveira
> escreveu:
>
>> Hello Guys,
>>
>> I'm making a small server that listens for requests and responds devices.
>> The Code is this:
>>
>> Now I can read the data received on the server but when I send them,
>> transform them from HEX to Byte, follow the lines of code
>>
>> var str = '**0184008000280000000000009a1024**04 ";
>> var a = [];
>>
>> for (var i = 0; i <str.length; i + = 2) {
>> a.push ("0x" + str.substr (i, 2));
>> }
>>
>>
>> but nodejs give the error:
>>
>> net.js: 450
>> throw new TypeError ("First argument must be a buffer or a string.");
>> ^
>> TypeError: First argument must be a buffer or a string.
>> at Socket.write (net.js: 450:11)
>> at Socket. <anonymous> (/ var / www / node.js: 35:7)
>> at Socket.emit (Events.js: 67:17)
>> at TCP.onread (net.js: 367:14)
>>
>> Someone knows the solution?
>> Thank you a lot for pacient.
>>
> --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
--
<surgemcgee> Systems/Software Engineer
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.