Simple syntax errors I guess. Leave out the spaces too.
var str = "0184008000280000000000009a102404"; var a = []; for (var i = 0; i
<str.length; i += 2) a.push("0x"+ str.substr (i, 2));
Also, keep in mind that while strings are parsed as arrays, they themselves
are not mutable.
P.S. Duck, Duck, Go is safe but not as cool.
On Thu, Sep 5, 2013 at 3:22 PM, Felipe Silveira <[email protected]>wrote:
> 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 = '0184008000280000000000009a102404 ";
> 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.