Jump to content

trag1c

Member
  • Posts

    2,145
  • Joined

  • Last visited

Awards

This user doesn't have any awards

3 Followers

About trag1c

  • Birthday Mar 16, 1996

Profile Information

  • Gender
    Male
  • Location
    Calgary Alberta, Canada
  • Interests
    Computer programming (mainly C++).
    Game and game engine programming.
    Classic rock and metal music.
    Electrical engineering.
    Robotics.
  • Occupation
    Mechanic Pre RONA.
  • Member title
    Local Electronics and C++ Programming Metal Head

System

  • CPU
    Intel i7 5820k @ 4.5GHz
  • Motherboard
    MSI X99S Gaming 7
  • RAM
    Corsair DDR4 Vengeance LPX 2666MHz 32GB
  • GPU
    EVGA GTX 1080 FTW
  • Case
    Corsair 900D
  • Storage
    WD 1TB NVMe, Intel 730 series 480GB, 3TB Seagate Barracuda
  • PSU
    Corsair AX860
  • Display(s)
    BenQ XL2730Z 2560x1440 144Hz, BenQ GW2765 2560x1440 x2
  • Cooling
    Corair H80i
  • Keyboard
    Logitech G19
  • Mouse
    Corsair M95
  • Sound
    Sennheiser HD 6XX Headphones
  • Operating System
    Windows 10

Recent Profile Visitors

4,709 profile views
  1. Looks like you're missing a few steps in your C program for serial communication, namely, port configuration through termios or ioctl. The reason that your program works after opening the Arduino console is that the Arduino console sets the appropriate configuration on the serial port. This configuration is applied to the terminal device itself, not the file descriptor. In other words, the configuration is persistent and system wide. That means that any application that sets a configuration on a terminal device will effect all other applications that are using the terminal device which is why the Arduino console allows your C program to function. For your application to function you will need to set the baud rate, data bits, stop bits, parity, flow control, canonical mode, echo, byte/char interpretation for input/output bytes etc. In Linux this is done through Termios (under termios.h) or ioctl. Both options utilize a structure to configure the terminal device. The difference is in how you read and write the options primarily. Termios uses tcgetattr() and tcsetattr() to read/write a struct to/from the terminal device. This struct is termios. effectively you will use tcgetattr() to fill in a termios struct that contains the existing options, you will then modify those options to your liking, and then utilize tcsetattr() to write the configuration to the terminal device. To set baud rate you will use cfsetispeed() and cfsetospeed(). struct termios { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ }; For IOCTL the its much the same except that we use ioctl() along with the appropriate flag to read/write the configuration settings. Additionally, the struct that is passed to and from ioctl includes additional fields for the baud rate. The struct that is utilized is the termios2 struct which is the exact same as termios except for the inclusion of fields for baud rates. struct termios2 { tcflag_t c_iflag; /* input mode flags */ tcflag_t c_oflag; /* output mode flags */ tcflag_t c_cflag; /* control mode flags */ tcflag_t c_lflag; /* local mode flags */ cc_t c_line; /* line discipline */ cc_t c_cc[NCCS]; /* control characters */ speed_t c_ispeed; /* input speed */ speed_t c_ospeed; /* output speed */ }; Using either method you will set or clear bits in the flag fields for a specific configuration parameter. For example this will set parity to none on the serial port. my_termios_struct.c_cflag &= ~PARENB; // Clear parity bit to disable parity. This is a solid resource for getting started with serial devices in Linux. However, I highly suggest reading up on Termios, and IOCTL so you understand all of the flags and options. There can be a lot of gotchas when working with serial ports with an OS due to the driver model being more complex than just a data port, they have also been used for things like consoles, and teletype printers (TTY). There are a lot of additional parameters that affect Kernel level processing of the data coming into and out of the serial port. Or flags like VTIME and VMIN that affect how calls to read() are handled by the kernel.
  2. I don't have a website for you but Bjarne Stroustrup who is the creator of C++ has excellent books on the subject. This one is designed for new programmers and for modern C++. https://www.stroustrup.com/programming.html Additionally, for reference material there is cppreference.com which is basically the Bible for documentation of C++ language features and the standard library.
  3. TIL that the io TLD is actually a territory specific domain along with all other 2 character domains. Always assumed io was a generic TLD. Kind of an interesting conundrum for those who that use it. Could be tricky if they didn't buy something like .com.
  4. It will augment the actual code writing aspect but that is such a miniscule piece of what software development is and a miniscule part of the day to day of a developer. I am not the least bit worried losing my job/career to a computer application. The hardest part of my job isn't writing code, that's easy. The hard part is dealing with the problem domain and requirements gathering/analysis. More specifically you're extremely lucky as a developer if you're given a well defined problem. AIs don't perform so well when you don't have a concise prompt within a well defined context. The reason being is that they're not AGIs, they're incapable of any actual intelligence. They have no reasoning or creativity, it tries to match your prompt to something in it's dataset. They're a glorified search engine. It essentially comes down to garbage in, garbage out. With current AIs there's also a non negligible chance that even with a well defined problem you will still be given garbage since it's dataset contains garbage. That's not to say they're useless, far from it. I use AI everyday in my job, often for boiler plate or random test day. Or as a tool to give search terms that I might not know of which I then use as keywords in a proper search engine. They're a good productivity booster in the hands of someone competent. But if a developer is replaced by AI, one of two things happened, either that person was dog shit as a developer, or that company will be rehiring devs in a year or two when they realize that their cost saving measure is costing them more than what a developers salary is. There's been innumerable technologies over decades that were supposed to put developers out of work. Low code solutions, no code solutions, AI, you name it. Yet, none of them have had any impact. The no/low code solutions designed for regular people to use end up needing developers anyway. Look at PLCs which were designed for electricians to program, I can tell you who isn't programming them. AI really isn't any different, it's a tool in the toolbox, and it will always be a tool, never a solution. I know this isn't what you want to hear but if your're serious about making this a career, don't bother with the bootcamp. Most are rightfully called scams, and the others just are not worth the money due the dismal job prospects. Pursue some sort of formal education from an accredited school. Preferably a bachelor's degree or at the very least a diploma or associates degree (so you can at least get credit towards a degree if needed). Bootcamps also tend to be very highly focused on specific tools and technologies for web apps. So if whatever you've been taught isn't the flavor of the month when you're looking for work you're kinda screwed. You really need to be on a level playing field, the bootcamp is a huge disadvantage. We just finished interviewing people for a junior position on my team at work. We got damn near 1000 applications at a small unknown startup, we never even looked at anyone without some form of post secondary credential from an accredited school. There was no point at looking at people from bootcamps when we have a plethora of people with masters and bachelor's degrees either in computer science or adjacent fields. For a determined individual, a reputable bootcamp could have been a solid route into the industry 4 or 5 years ago. Now they're simply a cash grab.
  5. 23 Subura WRX Sport Tech
  6. I think you're both right. Looking at the photo's of the back of router on the Ali express page there is no CE mark at all. There is the china equivalent which is the CCC mark on the bottom right. So the RF side is definitely not certified for anywhere but China and those that recognize the mark. The power supply also probably lacks the mark as well.
  7. Professional software developer currently but I am upgrading my diploma to degree through night classes. Current desktop is Ryzen 9 5900x with 128GB DDR4 3600MHz, 3080 ti, 2x samsung 980 pro 2TB, Samsung G9 Neo. Runs Windows for gaming, for tinkering Endeavor OS, for software development Ubuntu. Laptop is Lenovo Legion Slim 7i from 2023 that I forget the specs on lol. I7 or i9 with a 4060 or 4070, 16GB ram. Windows + WSL. NAS is 2x Xeon X5650, 48GB DDR3 ECC?? 5x 4TB Nas drives. I use all three in the pursuit of my degree, work and hobbies.
  8. Been a hot minute since I've seen a JSP, but my guess is that your result is null. You may need to add the JSP equivalent of an If or make sure that result is initialized before the page is sent to the user. I could be 100% out to lunch on this though.
  9. Couldn't begin to tell you as it's library dependent and I've used neither of those and I have no idea what those libraries are. If they have windows binaries available then you need to follow what I wrote in my previous reply. if not you have to figure out to build them from source for windows in order to get the libs and dlls. Edit: I would look up Application Binary Interaces (ABI) and linking so that you can understand how these things work in the context of a systems programming language like C, C++, or Rust.
  10. Unlike Linux, User libraries don't have central location that all applications can pull from (This is why just about every application folder you look into has a whole swath of DLLs). DLLs (the equivalent of .so on Linux) have to reside next your executable or in some known path (set at compile time of your application). So the process of installing shared libraries is simply build them and place them next to your executable. Additionally, you need to instruct your build system how to link to the library. Essentially you're going to set an include directory for the headers so that you can write your code using those libraries, and finally you will set a link directory pointed to the windows version of a static library (.lib) that defines an import library which allows for your executable to link with the DLL at run time. The .libs are generated by the build process for the libraries. TL;DR; Build library DLL and place next your executable Build library .lib and set your link directory/dependencies to this location. Add include directory to the libraries headers.
  11. Not just NASA, pretty much every single embedded, safety critical, or hard real time application will be written this way regardless if they run on a platform with an MMU or not.
  12. This more or less comes down to typing... or lack there of it. void* ptr = (void*)somePtr is perfectly valid because you're assigning the pointer to memory address. However, trying to access it as a pointer + offset won't work because the compiler has no idea what the stride (sizeof(void) which doesn't exist) is. However by declaring array pointer to pointer you can now address elements because it's data type is better defined as void pointer to void pointer which does exist as sizeof(void*) which is just the size of standard pointer. So if you declare your array as void** the compiler will now see its pointer to pointer and as such you can address it as pointer + offset to retrieve a pointer to an element.
  13. This will ultimately depend on your compiler. A compiler may choose to optimize much of your code away since you're only assigning to 'a' and not accessing, essentially see's it as a superfluous call that has no net effect on the outcome. GCC from -O0 to -O3 for optimization will keep the malloc call but using the same flags on clang show a much different story where the malloc disappears. See the assembly below and you can see. This with printf() commented out. GCC 13 with -O3 main: push {r4, lr} movs r0, #0 bl time bl srand .L2: movs r0, #8 bl malloc # YOUR MALLOC CALL mov r4, r0 bl rand str r0, [r4] asrs r0, r0, #31 str r0, [r4, #4] b .L2 Clang with 17 with -O3 with no Malloc main: # @main push rax xor edi, edi call time@PLT mov edi, eax call srand@PLT .LBB0_1: # =>This Inner Loop Header: Depth=1 call rand@PLT jmp .LBB0_1 Even with the printf() call uncommented Clang still does not generate the call to malloc while GCC does. If optimization is turned off Clang will happily generate the malloc call as you would expect. main: # @main push rbp mov rbp, rsp sub rsp, 32 mov dword ptr [rbp - 4], 0 xor eax, eax mov edi, eax call time@PLT mov edi, eax call srand@PLT mov qword ptr [rbp - 16], 0 .LBB0_1: # =>This Inner Loop Header: Depth=1 cmp qword ptr [rbp - 16], -1 ja .LBB0_4 mov edi, 8 call malloc@PLT mov qword ptr [rbp - 24], rax call rand@PLT movsxd rcx, eax mov rax, qword ptr [rbp - 24] mov qword ptr [rax], rcx mov rax, qword ptr [rbp - 24] mov rsi, qword ptr [rax] lea rdi, [rip + .L.str] mov al, 0 call printf@PLT mov rax, qword ptr [rbp - 16] add rax, 1 mov qword ptr [rbp - 16], rax jmp .LBB0_1 .LBB0_4: mov eax, dword ptr [rbp - 4] add rsp, 32 pop rbp ret .L.str: .asciz "%p\n"
  14. The problem is your mathematical function is not recursive or iterative, at least in this form. if you want the sum of 5 consecutive terms, you would substitute n = 5 so it would be x = n(n+1)/2 x = (5)(5+1)/2 x = 15 There is no recursion or iteration when using that formula. If you want to calculate the sum recursively for positive integers you would do the following: #include <cstdio> int sum(int n); int main(){ int n = 0; printf("Enter a number to calculate the sum of all the number from your input: "); scanf("%d", &n); printf("sum of %d terms is, %d\n", n, sum(n)); return 0; } int sum(int n){ if(n < 2 && n >= 0) { // sum of 1 or sum of 0 terms is 1 or 0 respectively return n; } else if (n < 0) { // positive ints only return 0; } return n + sum(n - 1); } edit: I would also add that your original code should segfault (attempt to write an illegal memory address) due to the fact that there is no exit condition that breaks the recursion. As such your stack will just keep on growing with every stack frame of the recursive function. Linux should report this, no idea about any other platform.
  15. Once you dive a little deeper, you'll see that it covers far more than that. Even building supplies are covered by Energy Star, I just had new Windows installed and they have ratings. See the spoiler for said window sticker. This is for Canada but Energy Star Canada is an international partner organization/rating. Additionally, here's an excerpt from the ECO declaration from Lenovo on the Legion Slim 7i Gen 8 that I just bought. It's pretty useless for many consumer products, but Energy Star definitely covers a lot more than appliances.
×